Improve CMake slightly (#620)

* Prefix build testing flag with SNMALLOC

* Only add clangformat target is testing enabled.
This commit is contained in:
Matthew Parkinson
2023-06-28 11:42:19 +01:00
committed by GitHub
parent 95bad423a7
commit dc1268886a
2 changed files with 9 additions and 7 deletions

View File

@@ -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)"

View File

@@ -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
@@ -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()
@@ -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)
@@ -496,7 +496,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()
@@ -511,13 +511,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)