diff --git a/src/madness/world/CMakeLists.txt b/src/madness/world/CMakeLists.txt index 1e7dbf0c56b..f3ad797732e 100644 --- a/src/madness/world/CMakeLists.txt +++ b/src/madness/world/CMakeLists.txt @@ -100,12 +100,17 @@ if(BUILD_TESTING) add_unittests(world "${WORLD_TEST_SOURCES}" "MADworld;MADgtest" "unittests;short") if (TARGET PaRSEC::parsec AND PARSEC_HAVE_CUDA) - CMAKE_PUSH_CHECK_STATE() - STRING(REPLACE "-std=c++1z" "" _tmp "${CMAKE_CXX_FLAGS}") - SET(CMAKE_CXX_FLAGS "${_tmp}") - cuda_add_library(MADtest_cuda hello_world.cu EXCLUDE_FROM_ALL) - CMAKE_POP_CHECK_STATE() - target_link_libraries(test_world PRIVATE MADtest_cuda) + include(CheckLanguage) + check_language(CUDA) + if(CMAKE_CUDA_COMPILER) + enable_language(CUDA) + CMAKE_PUSH_CHECK_STATE() + STRING(REPLACE "-std=c++1z" "" _tmp "${CMAKE_CXX_FLAGS}") + SET(CMAKE_CXX_FLAGS "${_tmp}") + add_library(MADtest_cuda hello_world.cu EXCLUDE_FROM_ALL) + CMAKE_POP_CHECK_STATE() + target_link_libraries(test_world PRIVATE MADtest_cuda) + endif(CMAKE_CUDA_COMPILER) endif () set_tests_properties(madness/test/world/test_googletest/run PROPERTIES WILL_FAIL TRUE)