-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
120 lines (90 loc) · 3.66 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# structure and content of CMakeLists.txt files adapted from
# https://stackoverflow.com/questions/55635294/how-to-create-packages-with-cmake
cmake_minimum_required(VERSION 3.9.0)
project(parallelproj LANGUAGES C)
include(CMakePackageConfigHelpers)
include(CheckLanguage)
# get standard paths for installation
include(GNUInstallDirs)
set (CMAKE_BUILD_TYPE Release CACHE STRING "build type" FORCE)
#-------------------------------------------------------------
# define the version number
set(VERSION_MAJOR 0)
set(VERSION_MINOR 5)
set(VERSION_PATCH 0-prealpha)
set(parallelproj_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
# define INSTALL dirs for libraries, public headers and documentation
# by default we use the GNUInstallDirs
set(PARALLELPROJ_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "install subdir for libs")
set(PARALLELPROJ_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "install subdir for public headers")
set(PARALLELPROJ_INSTALL_DOCDIR ${CMAKE_INSTALL_DOCDIR} CACHE PATH "install subdir for documentation")
#-------------------------------------------------------------
# user variable whether to install the doxygen docs as well
set(PARALLELPROJ_INSTALL_DOCS TRUE CACHE BOOL "install the docs generated by doxygen" )
#-------------------------------------------------------------
# checks for OpenMP, CUDA and doxygen
# find the required OpeMP
find_package(OpenMP REQUIRED)
# check if CUDA is available
check_language(CUDA)
# check if Doxygen is installed
find_package(Doxygen)
#-------------------------------------------------------------
# build the C/OpenMP lib
add_subdirectory(c)
# only build CUDA lib if CUDA is available
if(CMAKE_CUDA_COMPILER)
add_subdirectory(cuda)
endif()
#-------------------------------------------------------------
# install the targets
install(
EXPORT parallelprojTargets
DESTINATION ${PARALLELPROJ_INSTALL_LIBDIR}/cmake/parallelproj
NAMESPACE parallelproj::
FILE parallelprojTargets.cmake # Not sure if this is still needed
)
#-------------------------------------------------------------
# build the documentation with Doxygen
if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
# note the option ALL which allows to build the docs together with the application
add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
if (PARALLELPROJ_INSTALL_DOCS)
install( DIRECTORY docs/html
DESTINATION ${PARALLELPROJ_INSTALL_DOCDIR}
FILES_MATCHING
PATTERN "*")
endif (PARALLELPROJ_INSTALL_DOCS)
endif (DOXYGEN_FOUND)
#-------------------------------------------------------------
# generate and install cmake package and version files
if(CMAKE_CUDA_COMPILER)
set(CUDA_SUPPORTED ON)
endif()
configure_package_config_file(
Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/parallelprojConfig.cmake
INSTALL_DESTINATION ${PARALLELPROJ_INSTALL_LIBDIR}/cmake/parallelproj
PATH_VARS
PARALLELPROJ_INSTALL_LIBDIR
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/parallelprojConfigVersion.cmake
VERSION ${parallelproj_VERSION}
COMPATIBILITY SameMajorVersion
)
# Install Config and ConfigVersion files
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/parallelprojConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/parallelprojConfigVersion.cmake"
DESTINATION "${PARALLELPROJ_INSTALL_LIBDIR}/cmake/parallelproj"
)