forked from kokkos/kokkos-comm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
102 lines (86 loc) · 3.48 KB
/
CMakeLists.txt
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# 3.9: MPI::MPI_CXX
# 3.12: CMAKE_PROJECT_VERSION_MAJOR
# 3.15: PUBLIC_HEADER files for interface libraries
cmake_minimum_required(VERSION 3.12)
project(KokkosComm VERSION 0.0.2)
option(KokkosComm_ENABLE_PERFTESTS "Build KokkosComm perf tests" OFF)
option(KokkosComm_ENABLE_TESTS "Build KokkosComm perf tests" OFF)
## resolve options
set(KOKKOSCOMM_ENABLE_PERFTESTS ${KokkosComm_ENABLE_PERFTESTS} CACHE BOOL "" FORCE)
set(KOKKOSCOMM_ENABLE_TESTS ${KokkosComm_ENABLE_TESTS} CACHE BOOL "" FORCE)
find_package(Kokkos REQUIRED)
find_package(MPI REQUIRED)
message(STATUS "Kokkos Comm: MPI_VERSION = ${MPI_VERSION}")
message(STATUS "Kokkos Comm: MPI_CXX_COMPILER = ${MPI_CXX_COMPILER}")
message(STATUS "Kokkos Comm: MPI_CXX_COMPILE_OPTIONS = ${MPI_CXX_COMPILE_OPTIONS}")
message(STATUS "Kokkos Comm: MPI_CXX_COMPILE_DEFINITIONS = ${MPI_CXX_COMPILE_DEFINITIONS}")
message(STATUS "Kokkos Comm: MPI_CXX_INCLUDE_DIRS = ${MPI_CXX_INCLUDE_DIRS}")
message(STATUS "Kokkos Comm: MPI_CXX_LINK_FLAGS = ${MPI_CXX_LINK_FLAGS}")
message(STATUS "Kokkos Comm: MPI_CXX_LIBRARIES = ${MPI_CXX_LIBRARIES}")
include(cmake/flags.cmake)
add_subdirectory(src)
kokkoscomm_add_cxx_flags(TARGET KokkosComm INTERFACE)
message(STATUS ${KOKKOSCOMM_PUBLIC_HEADERS})
set_target_properties(KokkosComm PROPERTIES PUBLIC_HEADER "${KOKKOSCOMM_PUBLIC_HEADERS}")
## Version config file
set(KOKKOSCOMM_VERSION_MAJOR ${CMAKE_PROJECT_VERSION_MAJOR} CACHE STRING "" FORCE)
set(KOKKOSCOMM_VERSION_MINOR ${CMAKE_PROJECT_VERSION_MINOR} CACHE STRING "" FORCE)
set(KOKKOSCOMM_VERSION_PATCH ${CMAKE_PROJECT_VERSION_PATCH} CACHE STRING "" FORCE)
configure_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/KokkosComm_version.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/src/KokkosComm_version.hpp
@ONLY
)
# this sets CMAKE_INSTALL_[...]DIR
include(GNUInstallDirs)
target_include_directories(KokkosComm INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
## Package config file
include(CMakePackageConfigHelpers)
configure_package_config_file (
${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in
${PROJECT_BINARY_DIR}/cmake/KokkosComm/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(
${PROJECT_BINARY_DIR}/cmake/KokkosComm/${PROJECT_NAME}Version.cmake
COMPATIBILITY SameMajorVersion
)
export (
TARGETS KokkosComm
NAMESPACE "${PROJECT_NAME}::"
FILE ${PROJECT_BINARY_DIR}/cmake/KokkosComm/KokkosCommTargets.cmake
)
install(
TARGETS KokkosComm
EXPORT KokkosCommTargets # does this do anything?
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(
DIRECTORY "${PROJECT_BINARY_DIR}/src/"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.hpp")
install(
FILES
"${PROJECT_BINARY_DIR}/cmake/KokkosComm/KokkosCommConfig.cmake"
"${PROJECT_BINARY_DIR}/cmake/KokkosComm/KokkosCommVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/KokkosComm/
)
install(
EXPORT KokkosCommTargets
NAMESPACE "${PROJECT_NAME}::"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)
if(KOKKOSCOMM_ENABLE_TESTS)
enable_testing()
add_subdirectory(unit_tests)
endif()
if(KOKKOSCOMM_ENABLE_PERFTESTS)
enable_testing()
add_subdirectory(perf_tests)
endif()