@@ -8,15 +8,33 @@ set(camp_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
88set (camp_VERSION_MINOR ${PROJECT_VERSION_MINOR} )
99set (camp_VERSION_PATCH ${PROJECT_VERSION_PATCH} )
1010
11- # Default to C++11 if not set so GTest/GMock can build
12- if (NOT BLT_CXX_STD)
13- set (BLT_CXX_STD "c++14" CACHE STRING "" )
14- else ()
15- set (_unsupported_cxx "c++98" "c++11" )
16- if (BLT_CXX_STD IN_LIST _unsupported_cxx)
17- message (FATAL_ERROR "CAMP and the RAJA framework no longer support c++11, select a c++ standard of 14 or higher" )
11+ include (CheckCXXCompilerFlag )
12+ if (NOT DEFINED BLT_CXX_STD)
13+ set (CXX_VERSIONS 17 14)
14+ foreach (cxxver ${CXX_VERSIONS} )
15+ if ("cxx_std_${cxxver} " IN_LIST CMAKE_CXX_COMPILE_FEATURES)
16+ if (ENABLE_CUDA AND (NOT DEFINED CMAKE_CUDA_COMPILE_FEATURES OR (NOT "cuda_std_${cxxver} " IN_LIST CMAKE_CUDA_COMPILE_FEATURES)))
17+ continue ()
18+ endif ()
19+ set (CAMP_CXX_STD ${cxxver} )
20+ break ()
1821 endif ()
19- endif ()
22+ endforeach ()
23+ if (NOT DEFINED CAMP_CXX_STD)
24+ set (CAMP_CXX_STD 14)
25+ endif ()
26+ set (BLT_CXX_STD c++${CAMP_CXX_STD} CACHE STRING "Version of C++
27+ standard" )
28+ message ("Using C++ standard: ${BLT_CXX_STD} " )
29+ else () #check BLT_CXX_STD is high enough by disallowing the only invalid option
30+ set (_unsupported_cxx "c++98" "c++11" )
31+ if (BLT_CXX_STD IN_LIST _unsupported_cxx)
32+ message (FATAL_ERROR "CAMP and the RAJA framework no
33+ longer support ${_unsupported_cxx} , select a c++
34+ standard of 14 or higher" )
35+ endif ()
36+ endif (NOT DEFINED BLT_CXX_STD )
37+ set (CMAKE_CXX_EXTENSIONS OFF )
2038
2139include (cmake/load_blt.cmake )
2240
@@ -56,12 +74,16 @@ set (camp_runtime_backends cuda hip)
5674
5775foreach (backend ${camp_backends} )
5876 string (TOUPPER "${backend} " suffix)
77+ # NOTE: can't do this because of the lack of sycl support and usage upstream
78+ # in blt
79+ # cmake_dependent_option("CAMP_ENABLE_${suffix}" "Enable ${backend}
80+ # backend" On "ENABLE_${suffix}" Off)
5981 if ("${ENABLE_${suffix} }" )
6082 set ("CAMP_ENABLE_${suffix} " On )
6183 endif ()
6284 if (${CAMP_ENABLE_${suffix} })
6385 if (backend IN_LIST camp_runtime_backends)
64- set (backend ${backend} _runtime)
86+ set (backend ${backend} _runtime)
6587 endif ()
6688 if (TARGET blt::${backend} )
6789 set (backend blt::${backend} )
@@ -70,11 +92,8 @@ foreach (backend ${camp_backends})
7092 endif ()
7193endforeach ()
7294
73- if (CAMP_ENABLE_TARGET_OPENMP)
74- if (NOT CAMP_ENABLE_OPENMP)
75- message (FATAL_ERROR "OpenMP must be enabled if TARGET_OPENMP is enabled" )
76- endif ()
77- endif ()
95+ cmake_dependent_option (CAMP_ENABLE_TARGET_OPENMP "Enable OpenMP offload as
96+ device runtime" Off "CAMP_ENABLE_OPENMP" Off )
7897
7998if (ENABLE_CUDA)
8099 if ("${CUDA_VERSION_STRING} " VERSION_LESS "10.1" )
@@ -98,14 +117,17 @@ endif ()
98117
99118# Configure the config header file to allow config time options
100119configure_file (${PROJECT_SOURCE_DIR} /include/camp/config.in.hpp
101- ${PROJECT_BINARY_DIR} /include/camp/config.hpp )
120+ ${PROJECT_BINARY_DIR} /include/camp/config.hpp )
102121
103122blt_add_library (
104123 NAME camp
105124 HEADERS ${camp_headers}
106125 SOURCES ./src/errors.cpp
107126 DEPENDS_ON ${camp_depends}
108127 )
128+ if (cxx_std_${CAMP_CXX_STD} IN_LIST CMAKE_CXX_COMPILE_FEATURES)
129+ target_compile_features (camp PUBLIC cxx_std_${CAMP_CXX_STD} )
130+ endif ()
109131
110132if (COMPILER_FAMILY_IS_MSVC)
111133 if (NOT BUILD_SHARED_LIBS )
@@ -164,7 +186,7 @@ install(FILES
164186 include/camp)
165187
166188if (CAMP_ENABLE_TESTS)
167- enable_testing ()
168- add_subdirectory (test )
189+ enable_testing ()
190+ add_subdirectory (test )
169191endif ()
170192
0 commit comments