Skip to content

Commit 3a7486e

Browse files
authored
Merge pull request #112 from trws/protect-exports
Protect exports
2 parents 98c21d3 + df75279 commit 3a7486e

File tree

3 files changed

+54
-19
lines changed

3 files changed

+54
-19
lines changed

CMakeLists.txt

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,33 @@ set(camp_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
88
set(camp_VERSION_MINOR ${PROJECT_VERSION_MINOR})
99
set(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

2139
include(cmake/load_blt.cmake)
2240

@@ -56,12 +74,16 @@ set (camp_runtime_backends cuda hip)
5674

5775
foreach (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()
7193
endforeach()
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

7998
if (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
100119
configure_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

103122
blt_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

110132
if (COMPILER_FAMILY_IS_MSVC)
111133
if (NOT BUILD_SHARED_LIBS)
@@ -164,7 +186,7 @@ install(FILES
164186
include/camp)
165187

166188
if(CAMP_ENABLE_TESTS)
167-
enable_testing()
168-
add_subdirectory(test)
189+
enable_testing()
190+
add_subdirectory(test)
169191
endif()
170192

cmake/campConfig.cmake.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
@PACKAGE_INIT@
22

33
set(camp_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" CACHE FILEPATH "camp install prefix path")
4-
4+
set(BLT_TGTS "${CMAKE_CURRENT_LIST_DIR}/bltTargets.cmake")
5+
if(EXISTS "${BLT_TGTS}")
6+
include("${BLT_TGTS}")
7+
endif()
8+
unset(BLT_TGTS)
59
include("${CMAKE_CURRENT_LIST_DIR}/campTargets.cmake")
610
check_required_components("@PROJECT_NAME@")
711

cmake/load_blt.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,13 @@ if (NOT BLT_LOADED)
1919
include(${BLT_SOURCE_DIR}/SetupBLT.cmake)
2020
endif()
2121

22-
blt_export_tpl_targets(EXPORT campTargets NAMESPACE camp)
22+
if (NOT BLT_EXPORTED)
23+
set(BLT_EXPORTED On CACHE BOOL "" FORCE)
24+
blt_import_library(NAME blt_stub EXPORTABLE On)
25+
set_target_properties(blt_stub PROPERTIES EXPORT_NAME blt::blt_stub)
26+
install(TARGETS blt_stub
27+
EXPORT bltTargets)
28+
blt_export_tpl_targets(EXPORT bltTargets NAMESPACE blt)
29+
install(EXPORT bltTargets
30+
DESTINATION lib/cmake/camp)
31+
endif()

0 commit comments

Comments
 (0)