diff --git a/CMakeLists.txt b/CMakeLists.txt index 03d22a43..617b12ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,7 @@ if(NOT isMultiConfig AND NOT CMAKE_BUILD_TYPE) endif() if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(ENABLE_ASSERT "ENABLE_ASSERT") + list(APPEND PRIMECOUNT_COMPILE_DEFINITIONS "ENABLE_ASSERT") endif() # primecount binary source files ##################################### @@ -173,7 +173,7 @@ endif() if(WITH_FLOAT128) set(LIB_QUADMATH "quadmath") - set(HAVE_FLOAT128 "HAVE_FLOAT128") + list(APPEND PRIMECOUNT_COMPILE_DEFINITIONS "HAVE_FLOAT128") endif() # Use 32-bit integer division ######################################## @@ -183,7 +183,7 @@ endif() # division. On most CPUs before 2020 this significantly # improves performance. if(WITH_DIV32) - set(ENABLE_DIV32 "ENABLE_DIV32") + list(APPEND PRIMECOUNT_COMPILE_DEFINITIONS "ENABLE_DIV32") endif() # Use -Wno-uninitialized with GCC compiler ########################### @@ -252,7 +252,7 @@ if(BUILD_SHARED_LIBS) set_target_properties(libprimecount PROPERTIES SOVERSION ${PRIMECOUNT_VERSION_MAJOR}) set_target_properties(libprimecount PROPERTIES VERSION ${PRIMECOUNT_VERSION}) target_compile_options(libprimecount PRIVATE "${WNO_UNINITIALIZED}") - target_compile_definitions(libprimecount PRIVATE "${HAVE_FLOAT128}" "${DISABLE_INT128}" "${ENABLE_DIV32}" "${ENABLE_ASSERT}" "${ENABLE_MULTIARCH}" "${ENABLE_INT128_OPENMP_PATCH}") + target_compile_definitions(libprimecount PRIVATE ${PRIMECOUNT_COMPILE_DEFINITIONS}) target_link_libraries(libprimecount PRIVATE primesieve::primesieve "${LIB_OPENMP}" "${LIB_QUADMATH}" "${LIB_ATOMIC}") target_compile_features(libprimecount @@ -277,7 +277,7 @@ if(BUILD_STATIC_LIBS) add_library(libprimecount-static STATIC ${LIB_SRC}) set_target_properties(libprimecount-static PROPERTIES OUTPUT_NAME primecount) target_compile_options(libprimecount-static PRIVATE "${WNO_UNINITIALIZED}") - target_compile_definitions(libprimecount-static PRIVATE "${HAVE_FLOAT128}" "${DISABLE_INT128}" "${ENABLE_DIV32}" "${ENABLE_ASSERT}" "${ENABLE_MULTIARCH}" "${ENABLE_INT128_OPENMP_PATCH}") + target_compile_definitions(libprimecount-static PRIVATE ${PRIMECOUNT_COMPILE_DEFINITIONS}) target_link_libraries(libprimecount-static PRIVATE primesieve::primesieve "${LIB_OPENMP}" "${LIB_QUADMATH}" "${LIB_ATOMIC}") if(WITH_MSVC_CRT_STATIC) @@ -313,7 +313,7 @@ endif() if(BUILD_PRIMECOUNT) add_executable(primecount ${BIN_SRC}) target_link_libraries(primecount PRIVATE primecount::primecount primesieve::primesieve) - target_compile_definitions(primecount PRIVATE "${DISABLE_INT128}" "${ENABLE_DIV32}" "${ENABLE_ASSERT}" "${ENABLE_INT128_OPENMP_PATCH}") + target_compile_definitions(primecount PRIVATE ${PRIMECOUNT_COMPILE_DEFINITIONS}) target_compile_features(primecount PRIVATE cxx_auto_type) install(TARGETS primecount DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/cmake/OpenMP.cmake b/cmake/OpenMP.cmake index fa06b32b..e90b907a 100644 --- a/cmake/OpenMP.cmake +++ b/cmake/OpenMP.cmake @@ -118,7 +118,7 @@ if(OpenMP_FOUND OR OpenMP_CXX_FOUND) }" OpenMP_int128_patch) if(OpenMP_int128_patch) - set(ENABLE_INT128_OPENMP_PATCH "ENABLE_INT128_OPENMP_PATCH") + list(APPEND PRIMECOUNT_COMPILE_DEFINITIONS "ENABLE_INT128_OPENMP_PATCH") endif() endif() endif() diff --git a/cmake/int128_t.cmake b/cmake/int128_t.cmake index 528589c4..bc1db5ff 100644 --- a/cmake/int128_t.cmake +++ b/cmake/int128_t.cmake @@ -45,7 +45,7 @@ check_cxx_source_compiles(" }" int128) if(NOT int128) - set(DISABLE_INT128 "DISABLE_INT128") + list(APPEND PRIMECOUNT_COMPILE_DEFINITIONS "DISABLE_INT128") endif() cmake_pop_check_state() diff --git a/cmake/multiarch_arm_sve.cmake b/cmake/multiarch_arm_sve.cmake index 6d52c16c..00a871e6 100644 --- a/cmake/multiarch_arm_sve.cmake +++ b/cmake/multiarch_arm_sve.cmake @@ -72,7 +72,7 @@ check_cxx_source_compiles(" " multiarch_arm_sve) if(multiarch_arm_sve) - set(ENABLE_MULTIARCH "ENABLE_MULTIARCH_ARM_SVE") + list(APPEND PRIMECOUNT_COMPILE_DEFINITIONS "ENABLE_MULTIARCH_ARM_SVE") endif() cmake_pop_check_state() diff --git a/cmake/multiarch_avx512_vpopcnt.cmake b/cmake/multiarch_avx512_vpopcnt.cmake index 49c02d6f..9666d1db 100644 --- a/cmake/multiarch_avx512_vpopcnt.cmake +++ b/cmake/multiarch_avx512_vpopcnt.cmake @@ -75,7 +75,7 @@ check_cxx_source_compiles(" " multiarch_avx512_vpopcnt) if(multiarch_avx512_vpopcnt) - set(ENABLE_MULTIARCH "${ENABLE_MULTIARCH} ENABLE_MULTIARCH_AVX512_BMI2") + list(APPEND PRIMECOUNT_COMPILE_DEFINITIONS "ENABLE_MULTIARCH_AVX512_BMI2") endif() cmake_pop_check_state() diff --git a/cmake/multiarch_x86_popcnt.cmake b/cmake/multiarch_x86_popcnt.cmake index d9bdadfd..45b6d116 100644 --- a/cmake/multiarch_x86_popcnt.cmake +++ b/cmake/multiarch_x86_popcnt.cmake @@ -47,7 +47,7 @@ check_cxx_source_compiles(" " multiarch_x86_popcnt) if(multiarch_x86_popcnt) - set(ENABLE_MULTIARCH "${ENABLE_MULTIARCH} ENABLE_MULTIARCH_x86_POPCNT") + list(APPEND PRIMECOUNT_COMPILE_DEFINITIONS "ENABLE_MULTIARCH_x86_POPCNT") endif() cmake_pop_check_state() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1ae036b0..83c21d1d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,7 +3,7 @@ file(GLOB files "*.cpp") foreach(file ${files}) get_filename_component(binary_name ${file} NAME_WE) add_executable(${binary_name} ${file}) - target_compile_definitions(${binary_name} PRIVATE "${HAVE_FLOAT128}" "${DISABLE_INT128}" "${ENABLE_DIV32}" "${ENABLE_ASSERT}" "${ENABLE_MULTIARCH}" "${ENABLE_INT128_OPENMP_PATCH}") + target_compile_definitions(${binary_name} PRIVATE ${PRIMECOUNT_COMPILE_DEFINITIONS}) target_link_libraries(${binary_name} primecount::primecount primesieve::primesieve "${LIB_OPENMP}" "${LIB_ATOMIC}") add_test(NAME ${binary_name} COMMAND ${binary_name}) endforeach() diff --git a/test/api/CMakeLists.txt b/test/api/CMakeLists.txt index dfc53803..08968987 100644 --- a/test/api/CMakeLists.txt +++ b/test/api/CMakeLists.txt @@ -4,7 +4,7 @@ file(GLOB files "*.cpp" "*.c") foreach(file ${files}) get_filename_component(binary_name ${file} NAME_WE) add_executable(${binary_name} ${file}) - target_compile_definitions(${binary_name} PRIVATE "${HAVE_FLOAT128}" "${DISABLE_INT128}" "${ENABLE_DIV32}" "${ENABLE_ASSERT}" "${ENABLE_MULTIARCH}" "${ENABLE_INT128_OPENMP_PATCH}") + target_compile_definitions(${binary_name} PRIVATE ${PRIMECOUNT_COMPILE_DEFINITIONS}) target_link_libraries(${binary_name} primecount::primecount primesieve::primesieve "${LIB_OPENMP}" "${LIB_ATOMIC}") add_test(NAME ${binary_name} COMMAND ${binary_name}) endforeach() diff --git a/test/deleglise-rivat/CMakeLists.txt b/test/deleglise-rivat/CMakeLists.txt index 91d915a8..74986746 100644 --- a/test/deleglise-rivat/CMakeLists.txt +++ b/test/deleglise-rivat/CMakeLists.txt @@ -3,7 +3,7 @@ file(GLOB files "*.cpp") foreach(file ${files}) get_filename_component(binary_name ${file} NAME_WE) add_executable(${binary_name} ${file}) - target_compile_definitions(${binary_name} PRIVATE "${HAVE_FLOAT128}" "${DISABLE_INT128}" "${ENABLE_DIV32}" "${ENABLE_ASSERT}" "${ENABLE_MULTIARCH}" "${ENABLE_INT128_OPENMP_PATCH}") + target_compile_definitions(${binary_name} PRIVATE ${PRIMECOUNT_COMPILE_DEFINITIONS}) target_link_libraries(${binary_name} primecount::primecount primesieve::primesieve "${LIB_OPENMP}" "${LIB_ATOMIC}") add_test(NAME ${binary_name} COMMAND ${binary_name}) endforeach() diff --git a/test/gourdon/CMakeLists.txt b/test/gourdon/CMakeLists.txt index 91d915a8..74986746 100644 --- a/test/gourdon/CMakeLists.txt +++ b/test/gourdon/CMakeLists.txt @@ -3,7 +3,7 @@ file(GLOB files "*.cpp") foreach(file ${files}) get_filename_component(binary_name ${file} NAME_WE) add_executable(${binary_name} ${file}) - target_compile_definitions(${binary_name} PRIVATE "${HAVE_FLOAT128}" "${DISABLE_INT128}" "${ENABLE_DIV32}" "${ENABLE_ASSERT}" "${ENABLE_MULTIARCH}" "${ENABLE_INT128_OPENMP_PATCH}") + target_compile_definitions(${binary_name} PRIVATE ${PRIMECOUNT_COMPILE_DEFINITIONS}) target_link_libraries(${binary_name} primecount::primecount primesieve::primesieve "${LIB_OPENMP}" "${LIB_ATOMIC}") add_test(NAME ${binary_name} COMMAND ${binary_name}) endforeach() diff --git a/test/lmo/CMakeLists.txt b/test/lmo/CMakeLists.txt index 91d915a8..74986746 100644 --- a/test/lmo/CMakeLists.txt +++ b/test/lmo/CMakeLists.txt @@ -3,7 +3,7 @@ file(GLOB files "*.cpp") foreach(file ${files}) get_filename_component(binary_name ${file} NAME_WE) add_executable(${binary_name} ${file}) - target_compile_definitions(${binary_name} PRIVATE "${HAVE_FLOAT128}" "${DISABLE_INT128}" "${ENABLE_DIV32}" "${ENABLE_ASSERT}" "${ENABLE_MULTIARCH}" "${ENABLE_INT128_OPENMP_PATCH}") + target_compile_definitions(${binary_name} PRIVATE ${PRIMECOUNT_COMPILE_DEFINITIONS}) target_link_libraries(${binary_name} primecount::primecount primesieve::primesieve "${LIB_OPENMP}" "${LIB_ATOMIC}") add_test(NAME ${binary_name} COMMAND ${binary_name}) endforeach()