-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
103 lines (89 loc) · 3.34 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
103
cmake_minimum_required(VERSION 3.14.5)
file(STRINGS "version.txt" _hwcart_version)
project(HWCart VERSION ${_hwcart_version} LANGUAGES C)
unset(_hwcart_version)
if(NOT CMAKE_BUILD_TYPE) # AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
set_property(CACHE CMAKE_C_FLAGS_RELEASE PROPERTY VALUE "-O3 -DNDEBUG -Wno-unused-parameter")
endif()
if (CMAKE_C_COMPILER_ID MATCHES "GNU")
message(STATUS "C compiler is GNU.")
set_property(CACHE CMAKE_C_FLAGS PROPERTY VALUE "-Wall -Wextra -Wpedantic -Wno-unknown-pragmas")
else ()
message(STATUS "C compiler is NOT GNU.")
set_property(CACHE CMAKE_C_FLAGS PROPERTY VALUE "-Wall -Wextra")
endif()
add_compile_definitions(_GNU_SOURCE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Fortran bindings
option (HWCART_USE_FORTRAN "Enable Fortran bindings" OFF)
if (HWCART_USE_FORTRAN)
enable_language(Fortran)
endif(HWCART_USE_FORTRAN)
find_package(MPI REQUIRED)
# do we use HWLOC?
option (HWCART_USE_HWLOC "use hwloc" ON)
if (HWCART_USE_HWLOC)
find_package(HWLOC)
if (HWLOC_FOUND)
list (APPEND DEPENDENCY_TARGETS HWLOC::libhwloc)
message(STATUS "Using HWLOC hardware locality features")
endif (HWLOC_FOUND)
else ()
message(STATUS "Using OpenMPI hardware locality features. Can only compile using OpenMPI.")
endif (HWCART_USE_HWLOC)
# main shared lib
add_library(hwcart SHARED)
add_library(HWCART::hwcart ALIAS hwcart)
target_include_directories(hwcart PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries (hwcart PUBLIC MPI::MPI_C)
add_subdirectory(src)
option(HWCART_USE_TESTS "build tests" OFF)
if (HWCART_USE_TESTS)
add_subdirectory(tests)
endif()
include(GNUInstallDirs)
install(TARGETS hwcart
EXPORT HWCART-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if (HWCART_USE_FORTRAN)
if(CMAKE_Fortran_COMPILER_ID STREQUAL "Cray")
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/HWCART_MOD.mod
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR})
else()
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/hwcart_mod.mod
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR})
endif()
endif (HWCART_USE_FORTRAN)
install(EXPORT HWCART-targets
FILE HWCART-targets.cmake
NAMESPACE HWCART::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/HWCARTConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/HWCARTConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
write_basic_package_version_file(HWCARTConfigVersion.cmake
VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/HWCARTConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/HWCARTConfigVersion.cmake
${CMAKE_CURRENT_LIST_DIR}/cmake/FindHWLOC.cmake
DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake)
export(EXPORT HWCART-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/HWCART-targets.cmake")