Update cmake configuration from master

This commit is contained in:
C. Antonio Sanchez
2025-02-16 11:22:08 -08:00
parent 052d91349a
commit f1922b6dac
17 changed files with 984 additions and 777 deletions

View File

@@ -28,66 +28,59 @@ macro(ei_add_test_internal testname testname_with_suffix)
set(is_gpu_test ON)
if(EIGEN_TEST_HIP)
hip_reset_flags()
hip_add_executable(${targetname} ${filename} HIPCC_OPTIONS "-DEIGEN_USE_HIP ${ARGV2}")
hip_add_executable(${targetname} ${filename} HIPCC_OPTIONS -std=c++14)
target_compile_definitions(${targetname} PRIVATE -DEIGEN_USE_HIP)
set_property(TARGET ${targetname} PROPERTY HIP_ARCHITECTURES gfx900 gfx906 gfx908 gfx90a gfx940 gfx941 gfx942 gfx1030)
elseif(EIGEN_TEST_CUDA_CLANG)
set_source_files_properties(${filename} PROPERTIES LANGUAGE CXX)
if(CUDA_64_BIT_DEVICE_CODE AND (EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/lib64"))
link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64")
else()
link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib")
endif()
if (${ARGC} GREATER 2)
add_executable(${targetname} ${filename})
else()
add_executable(${targetname} ${filename} OPTIONS ${ARGV2})
endif()
add_executable(${targetname} ${filename})
set(CUDA_CLANG_LINK_LIBRARIES "cudart_static" "cuda" "dl" "pthread")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CUDA_CLANG_LINK_LIBRARIES ${CUDA_CLANG_LINK_LIBRARIES} "rt")
endif()
target_link_libraries(${targetname} ${CUDA_CLANG_LINK_LIBRARIES})
else()
if (${ARGC} GREATER 2)
cuda_add_executable(${targetname} ${filename} OPTIONS ${ARGV2})
else()
cuda_add_executable(${targetname} ${filename})
endif()
cuda_add_executable(${targetname} ${filename})
endif()
else()
add_executable(${targetname} ${filename})
endif()
add_dependencies(buildtests ${targetname})
if (is_gpu_test)
add_dependencies(buildtests_gpu ${targetname})
endif()
if(EIGEN_NO_ASSERTION_CHECKING)
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_NO_ASSERTION_CHECKING=1")
target_compile_definitions(${targetname} PRIVATE EIGEN_NO_ASSERTION_CHECKING=1)
else()
if(EIGEN_DEBUG_ASSERTS)
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_DEBUG_ASSERTS=1")
target_compile_definitions(${targetname} PRIVATE EIGEN_DEBUG_ASSERTS=1)
endif()
endif()
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_MAX_SIZE=${EIGEN_TEST_MAX_SIZE}")
target_compile_definitions(${targetname} PRIVATE EIGEN_TEST_MAX_SIZE=${EIGEN_TEST_MAX_SIZE})
if(MSVC)
ei_add_target_property(${targetname} COMPILE_FLAGS "/bigobj")
target_compile_options(${targetname} PRIVATE "/bigobj")
endif()
# let the user pass flags.
if(${ARGC} GREATER 2)
set(compile_options "${ARGV2}")
separate_arguments(compile_options)
ei_add_target_property(${targetname} COMPILE_FLAGS ${compile_options})
separate_arguments(compile_options NATIVE_COMMAND ${ARGV2})
target_compile_options(${targetname} PRIVATE ${compile_options})
endif()
if(EIGEN_TEST_CUSTOM_CXX_FLAGS)
ei_add_target_property(${targetname} COMPILE_FLAGS ${EIGEN_TEST_CUSTOM_CXX_FLAGS})
target_compile_options(${targetname} PRIVATE ${EIGEN_TEST_CUSTOM_CXX_FLAGS})
endif()
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
@@ -99,6 +92,7 @@ macro(ei_add_test_internal testname testname_with_suffix)
if(EIGEN_TEST_CUSTOM_LINKER_FLAGS)
target_link_libraries(${targetname} ${EIGEN_TEST_CUSTOM_LINKER_FLAGS})
endif()
target_link_libraries(${targetname} Eigen3::Eigen)
if(${ARGC} GREATER 3)
set(libs_to_link ${ARGV3})
@@ -113,7 +107,7 @@ macro(ei_add_test_internal testname testname_with_suffix)
endif()
endif()
add_test(${testname_with_suffix} "${targetname}")
add_test(NAME ${testname_with_suffix} COMMAND "${targetname}")
# Specify target and test labels according to EIGEN_CURRENT_SUBPROJECT
get_property(current_subproject GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT)
@@ -126,22 +120,10 @@ macro(ei_add_test_internal testname testname_with_suffix)
# Add gpu tag for testing only GPU tests.
set_property(TEST ${testname_with_suffix} APPEND PROPERTY LABELS "gpu")
endif()
if(EIGEN_SYCL)
# Force include of the SYCL file at the end to avoid errors.
set_property(TARGET ${targetname} PROPERTY COMPUTECPP_INCLUDE_AFTER 1)
# Set COMPILE_FLAGS to COMPILE_DEFINITIONS instead to avoid having to duplicate the flags
# to the device compiler.
get_target_property(target_compile_flags ${targetname} COMPILE_FLAGS)
separate_arguments(target_compile_flags)
foreach(flag ${target_compile_flags})
if(${flag} MATCHES "^-D.*")
string(REPLACE "-D" "" definition_flag ${flag})
set_property(TARGET ${targetname} APPEND PROPERTY COMPILE_DEFINITIONS ${definition_flag})
list(REMOVE_ITEM target_compile_flags ${flag})
endif()
endforeach()
set_property(TARGET ${targetname} PROPERTY COMPILE_FLAGS ${target_compile_flags})
set_property(TARGET ${gittargetname} PROPERTY COMPUTECPP_INCLUDE_AFTER 1)
# Link against pthread and add sycl to target
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
@@ -218,12 +200,13 @@ macro(ei_add_test testname)
if( (EIGEN_SPLIT_LARGE_TESTS AND suffixes) OR explicit_suffixes)
add_custom_target(${testname})
foreach(suffix ${suffixes})
ei_add_test_internal(${testname} ${testname}_${suffix}
"${ARGV1} -DEIGEN_TEST_PART_${suffix}=1" "${ARGV2}")
ei_add_test_internal(${testname} ${testname}_${suffix} "${ARGV1}" "${ARGV2}")
add_dependencies(${testname} ${testname}_${suffix})
target_compile_definitions(${testname}_${suffix} PRIVATE -DEIGEN_TEST_PART_${suffix}=1)
endforeach()
else()
ei_add_test_internal(${testname} ${testname} "${ARGV1} -DEIGEN_TEST_PART_ALL=1" "${ARGV2}")
ei_add_test_internal(${testname} ${testname} "${ARGV1}" "${ARGV2}")
target_compile_definitions(${testname} PRIVATE -DEIGEN_TEST_PART_ALL=1)
endif()
endmacro()
@@ -249,11 +232,16 @@ macro(ei_add_failtest testname)
# Add the tests to ctest.
add_test(NAME ${test_target_ok}
COMMAND ${CMAKE_COMMAND} --build . --target ${test_target_ok} --config $<CONFIGURATION>
COMMAND ${CMAKE_COMMAND} --build . --target ${test_target_ok} --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME ${test_target_ko}
COMMAND ${CMAKE_COMMAND} --build . --target ${test_target_ko} --config $<CONFIGURATION>
COMMAND ${CMAKE_COMMAND} --build . --target ${test_target_ko} --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# Disable emulator if cross-compiling.
if (CMAKE_CROSSCOMPILING)
set_property(TEST ${test_target_ok} PROPERTY CROSSCOMPILING_EMULATOR "")
set_property(TEST ${test_target_ko} PROPERTY CROSSCOMPILING_EMULATOR "")
endif()
# Expect the second test to fail
set_tests_properties(${test_target_ko} PROPERTIES WILL_FAIL TRUE)
@@ -393,8 +381,10 @@ macro(ei_testing_print_summary)
if(EIGEN_TEST_SYCL)
if(EIGEN_SYCL_TRISYCL)
message(STATUS "SYCL: ON (using triSYCL)")
else()
elseif(EIGEN_SYCL_ComputeCpp)
message(STATUS "SYCL: ON (using computeCPP)")
elseif(EIGEN_SYCL_DPCPP)
message(STATUS "SYCL: ON (using DPCPP)")
endif()
else()
message(STATUS "SYCL: OFF")
@@ -464,15 +454,7 @@ endmacro()
macro(ei_get_compilerver VAR)
if(MSVC)
# on windows system, we use a modified CMake script
include(EigenDetermineVSServicePack)
EigenDetermineVSServicePack( my_service_pack )
if( my_service_pack )
set(${VAR} ${my_service_pack})
else()
set(${VAR} "na")
endif()
set(${VAR} "${CMAKE_CXX_COMPILER_VERSION}")
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "PGI")
set(${VAR} "${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}")
else()
@@ -541,12 +523,12 @@ macro(ei_get_compilerver_from_cxx_version_string VERSTRING CNAME CVER)
string(REGEX MATCH "[^0-9][0-9]+\\.[0-9]+" eicver ${VERSTRING})
if (NOT eicver AND ei_has_mingw)
# try to extract 1 number plus suffix:
string(REGEX MATCH "[^0-9][0-9]+-win32" eicver ${VERSTRING})
string(REGEX MATCH "[^0-9][0-9]+-win32" eicver ${VERSTRING})
endif()
endif()
endif()
endif()
if (NOT eicver)
set(eicver " _")
endif()
@@ -607,10 +589,7 @@ macro(ei_set_build_string)
ei_get_compilerver(LOCAL_COMPILER_VERSION)
ei_get_cxxflags(LOCAL_COMPILER_FLAGS)
include(EigenDetermineOSVersion)
DetermineOSVersion(OS_VERSION)
set(TMP_BUILD_STRING ${OS_VERSION}-${LOCAL_COMPILER_VERSION})
set(TMP_BUILD_STRING ${CMAKE_SYSTEM}-${LOCAL_COMPILER_VERSION})
if (NOT ${LOCAL_COMPILER_FLAGS} STREQUAL "")
set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-${LOCAL_COMPILER_FLAGS})
@@ -680,10 +659,10 @@ endmacro()
# Split all tests listed in EIGEN_TESTS_LIST into num_splits many targets
# named buildtestspartN with N = { 0, ..., num_splits-1}.
#
# The intention behind the existance of this macro is the size of Eigen's
# testsuite. Together with the relativly big compile-times building all tests
# The intention behind the existence of this macro is the size of Eigen's
# testsuite. Together with the relatively big compile-times building all tests
# can take a substantial amount of time depending on the available hardware.
#
#
# The last buildtestspartN target will build possible remaining tests.
#
# An example:
@@ -727,7 +706,7 @@ macro(ei_split_testsuite num_splits)
endforeach()
math(EXPR test_idx "${test_idx} + ${num_tests_per_target}")
endforeach()
# Handle the possibly remaining tests
math(EXPR test_idx "${num_splits} * ${num_tests_per_target}")
math(EXPR target_bound "${eigen_test_count} - 1")
@@ -739,10 +718,10 @@ endmacro(ei_split_testsuite num_splits)
# Defines the custom command buildsmoketests to build a number of tests
# specified in smoke_test_list.
#
#
# Test in smoke_test_list can be either test targets (e.g. packetmath) or
# subtests targets (e.g. packetmath_2). If any of the test are not available
# in the current configuration they are just skipped.
# in the current configuration they are just skipped.
#
# All tests added via this macro are labeled with the smoketest label. This
# allows running smoketests only using ctest.