Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CMake slightly #620

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
dependencies: "sudo apt install ninja-build"
build-type: Release
self-host: true
extra-cmake-flags: "-DSNMALLOC_BENCHMARK_INDIVIDUAL_MITIGATIONS=On -DBUILD_TESTING=Off"
extra-cmake-flags: "-DSNMALLOC_BENCHMARK_INDIVIDUAL_MITIGATIONS=On -DSNMALLOC_BUILD_TESTING=Off"
# Check that we can build specifically with libstdc++
- os: "ubuntu-latest"
variant: "libstdc++ (Build only)"
Expand Down
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include(CheckIPOSupported)
include(CMakeDependentOption)

# Name chosen for compatibility with CTest.
option(BUILD_TESTING "Build test programs as well as shims" ON)
option(SNMALLOC_BUILD_TESTING "Build test programs as well as shims" ON)

option(SNMALLOC_HEADER_ONLY_LIBRARY "Use snmalloc has a header-only library" OFF)
# Options that apply globally
Expand Down Expand Up @@ -288,7 +288,7 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY)

set(TESTDIR ${CMAKE_CURRENT_SOURCE_DIR}/src/test)

if(BUILD_TESTING)
if(SNMALLOC_BUILD_TESTING)
enable_testing()
subdirlist(TEST_CATEGORIES ${TESTDIR})
else()
Expand Down Expand Up @@ -448,7 +448,7 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY)
target_compile_definitions(snmallocshim-checks-rust PRIVATE SNMALLOC_CHECK_CLIENT)
endif()

if (BUILD_TESTING)
if (SNMALLOC_BUILD_TESTING)
if (WIN32
OR (CMAKE_SYSTEM_NAME STREQUAL NetBSD)
OR (CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
Expand Down Expand Up @@ -497,7 +497,7 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY)
set(DEFINES "SNMALLOC_CHECK_CLIENT_MITIGATIONS=${MITIGATION}")
add_shim(snmallocshim-${MITIGATION} SHARED ${SHIM_FILES})
target_compile_definitions(snmallocshim-${MITIGATION} PRIVATE ${DEFINES})
if (BUILD_TESTING)
if (SNMALLOC_BUILD_TESTING)
make_tests(${MITIGATION} ${DEFINES})
endif()
endforeach()
Expand All @@ -512,13 +512,15 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY)
set(DEFINES "-DSNMALLOC_CHECK_CLIENT_MITIGATIONS=${MITIGATIONSET}")
add_shim(snmallocshim-${MITIGATIONNAME} SHARED ${SHIM_FILES})
target_compile_definitions(snmallocshim-${MITIGATIONNAME} PRIVATE ${DEFINES})
if (BUILD_TESTING)
if (SNMALLOC_BUILD_TESTING)
make_tests(${MITIGATIONNAME} ${DEFINES})
endif()
endforeach()
endif()

clangformat_targets()
if (SNMALLOC_BUILD_TESTING)
clangformat_targets()
endif ()
endif()

install(TARGETS snmalloc EXPORT snmallocConfig)
Expand Down