-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
176 lines (143 loc) · 4.75 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# -*- cmake -*-
#
# michael a.g. aïvázis
# orthologue
# (c) 1998-2021 all rights reserved
#
# cmake setup
cmake_minimum_required(VERSION 3.12...3.18)
# options
option(WITH_CUDA "enable support for CUDA" OFF)
# adjust the include path
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake)
# get support
include(pyre_init)
if(NOT PYRE_VERSION)
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
message(FATAL_ERROR "git auto-versioning requires cloned repo! "
"provide a version with -DPYRE_VERSION=X.Y.Z")
endif()
# ask git for the pyre version
pyre_getVersion()
endif()
# set up the project
project(PYRE VERSION "${PYRE_VERSION}" LANGUAGES CXX)
set(MAJOR ${PROJECT_VERSION_MAJOR})
set(MINOR ${PROJECT_VERSION_MINOR})
set(MICRO ${PROJECT_VERSION_PATCH})
# is this the topmost project? (not added via e.g. add_subdirectory)
if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(PYRE_IS_ROOT_PROJECT TRUE)
else()
set(PYRE_IS_ROOT_PROJECT FALSE)
endif()
# default to build tests only when root project, but allow user to choose
option(PYRE_BUILD_TESTING "Build pyre's test suite" ${PYRE_IS_ROOT_PROJECT})
# hmmmmm
include(GNUInstallDirs)
# RPATH handling
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
if(NOT (CMAKE_INSTALL_FULL_LIBDIR IN_LIST
CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES))
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()
include(pyre_journal)
include(pyre_pyre)
include(pyre_merlin)
include(pyre_cuda)
include(pyre_mpi)
include(pyre_gsl)
include(pyre_postgres)
# programs
find_program(BASH_PROGRAM bash)
# packages
# gsl
find_package(GSL)
# mpi
find_package(MPI)
# postgres
find_package(PostgreSQL)
# python
find_package(Python 3.6 COMPONENTS Interpreter Development NumPy)
# for building bindings
# require c++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(PYBIND11_CPP_STANDARD -std=c++17)
set(PYBIND11_PYTHON_VERSION ${Python_VERSION})
set(PYBIND11_FINDPYTHON ON) # Use new FindPython if available
find_package(pybind11)
# pybind11 pre-2.5 C++17 compilation is broken under Clang
# see https://github.com/pybind/pybind11/issues/1604#issuecomment-443385783
if(pybind11_VERSION VERSION_LESS 2.5 AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(pybind11::module INTERFACE -fsized-deallocation)
endif()
# set up cmake
pyre_cmakeInit()
# set up python
pyre_pythonInit()
# initialize the variables that describe the staging directory layout
pyre_stagingInit()
# initialize the variables that describe the install directory layout
pyre_destinationInit()
# visit subdirectories
add_subdirectory(packages)
add_subdirectory(lib)
add_subdirectory(extensions)
add_subdirectory(defaults)
add_subdirectory(bin)
# make exports available in binary dir during build
export(EXPORT pyre-targets
NAMESPACE pyre::
)
# install exports to installation prefix
set(PYRE_CMAKE_DIR "share/cmake/pyre" CACHE STRING
"Installation directory for cmake files, relative to install prefix")
install(EXPORT pyre-targets
NAMESPACE pyre::
DESTINATION ${PYRE_CMAKE_DIR}
)
# set up version detection for cmake find_package
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
pyre-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion
)
# install config file for find_package
configure_package_config_file(
${PROJECT_SOURCE_DIR}/.cmake/pyre-config.cmake.in
${PROJECT_BINARY_DIR}/pyre-config.cmake
INSTALL_DESTINATION ${PYRE_CMAKE_DIR})
install(FILES ${PROJECT_BINARY_DIR}/pyre-config.cmake
${PROJECT_BINARY_DIR}/pyre-config-version.cmake
DESTINATION ${PYRE_CMAKE_DIR})
# create aliases matching the exports above
add_library(pyre::pyre ALIAS pyre)
add_library(pyre::journal ALIAS journal)
# if we are building to test
if(PYRE_BUILD_TESTING)
# needed by some {journal} test cases
enable_language(C)
# get support
include(CTest)
# and my functions
include(pyre_tests)
# initialize the variables that describe the test suite; needed so harnesses can set up the
# working directory correctly
pyre_testInit()
# add the testsuite to the pile
add_subdirectory(tests)
endif()
# end of file