-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
85 lines (74 loc) · 2.32 KB
/
Copy pathCMakeLists.txt
File metadata and controls
85 lines (74 loc) · 2.32 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
cmake_minimum_required (VERSION 3.9)
project (camp
LANGUAGES CXX
VERSION 0.1.0)
option(ENABLE_CUDA "whether to build with cuda" Off)
option(ENABLE_CLANG_CUDA "use clang cuda support rather than nvcc" Off)
if(ENABLE_CLANG_CUDA)
if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
message(ERROR "clang cuda can only be used with clang")
endif()
endif()
if(ENABLE_CUDA)
find_package(CUDA REQUIRED)
if(NOT ENABLE_CLANG_CUDA)
include(CheckLanguage)
check_language(CUDA)
enable_language(CUDA)
else()
if(NOT CUDA_ARCH)
set(CUDA_ARCH "sm_35")
endif()
set (_cuda_compile_flags -x cuda --cuda-gpu-arch=${CUDA_ARCH} --cuda-path=${CUDA_TOOLKIT_ROOT_DIR})
add_library(camp_cuda INTERFACE)
target_compile_options(camp_cuda INTERFACE ${_cuda_compile_flags})
target_link_libraries(camp_cuda INTERFACE ${CUDA_LIBRARIES})
target_include_directories(camp_cuda INTERFACE ${CUDA_INCLUDE_DIRS})
message(STATUS "CUDA LIBS: ${CUDA_LIBRARIES}")
endif(NOT ENABLE_CLANG_CUDA)
endif()
add_library (camp INTERFACE)
target_include_directories (camp INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
set_target_properties (camp PROPERTIES
INTERFACE_LIB_VERSION $camp_VERSION
INTERFACE_COMPILE_FEATURES cxx_std_11)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/campConfigVersion.cmake"
VERSION 0.1.0
COMPATIBILITY AnyNewerVersion
)
install(TARGETS camp
EXPORT campTargets
LIBRARY DESTINATION lib COMPONENT Runtime
ARCHIVE DESTINATION lib COMPONENT Development
RUNTIME DESTINATION bin COMPONENT Runtime
PUBLIC_HEADER DESTINATION include COMPONENT Development
BUNDLE DESTINATION bin COMPONENT Runtime
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/campConfig.cmake.in"
"${PROJECT_BINARY_DIR}/campConfig.cmake"
INSTALL_DESTINATION
lib/cmake/camp
)
install(EXPORT campTargets
DESTINATION lib/cmake/camp)
install(FILES
"${PROJECT_BINARY_DIR}/campConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/campConfig.cmake"
DESTINATION
lib/cmake/camp)
install(DIRECTORY
${PROJECT_SOURCE_DIR}/include/
DESTINATION
include)
SET(ENABLE_TESTS On CACHE BOOL "Test variable defaulting to '0'")
if(ENABLE_TESTS)
enable_testing()
add_subdirectory(test)
endif()