Skip to content

Commit

Permalink
Use CMake list for macros
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Jun 22, 2024
1 parent e18c704 commit 67f5672
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 #####################################
Expand Down Expand Up @@ -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 ########################################
Expand All @@ -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 ###########################
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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})

Expand Down
2 changes: 1 addition & 1 deletion cmake/OpenMP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion cmake/int128_t.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion cmake/multiarch_arm_sve.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion cmake/multiarch_avx512_vpopcnt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion cmake/multiarch_x86_popcnt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion test/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion test/deleglise-rivat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion test/gourdon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion test/lmo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 67f5672

Please sign in to comment.