1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
enable_language(C)
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 ${PRIMECOUNT_COMPILE_DEFINITIONS})
target_link_libraries(${binary_name} primecount::primecount primesieve::primesieve ${PRIMECOUNT_LINK_LIBRARIES})
target_include_directories(${binary_name}
PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/deleglise-rivat
${CMAKE_SOURCE_DIR}/src/gourdon
${CMAKE_SOURCE_DIR}/src/lmo)
add_test(NAME ${binary_name} COMMAND ${binary_name})
# Copy primecount.dll and primesieve.dll to test directory.
# On Windows the DLLs must be in the same directory as the
# binaries that depend on them.
if (WIN32 AND NOT STATICALLY_LINK_LIBPRIMECOUNT)
add_custom_command(TARGET ${binary_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:libprimecount>
$<TARGET_FILE_DIR:${binary_name}>)
add_custom_command(TARGET ${binary_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:libprimesieve>
$<TARGET_FILE_DIR:${binary_name}>)
endif()
endforeach()
|