-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
222 lines (157 loc) · 7.4 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#[[
This file is part of the Ristra tangram project.
Please see the license file at the root of this repository, or at:
https://github.com/laristra/tangram/blob/master/LICENSE
]]
cmake_minimum_required(VERSION 3.13)
project(tangram CXX C)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (CMAKE_VERSION_MAJOR GREATER_EQUAL 3.13)
CMAKE_POLICY(SET CMP0079 NEW) # allow target_link_libraries to reference
# targets from other directories
endif()
cmake_policy(SET CMP0074 NEW) # Don't ignore Pkg_ROOT variables
# SEMANTIC VERSION NUMBERS - UPDATE DILIGENTLY
# As soon as a change with a new version number is merged into the master,
# tag the central repository.
set(TANGRAM_VERSION_MAJOR 1)
set(TANGRAM_VERSION_MINOR 0)
set(TANGRAM_VERSION_PATCH 4)
# Top level target
add_library(tangram INTERFACE)
# Alias (Daniel Pfeiffer, Effective CMake) - this allows other
# projects that use Pkg as a subproject to find_package(Nmspc::Pkg)
# which does nothing because Pkg is already part of the project
add_library(tangram::tangram ALIAS tangram)
set(TANGRAM_LIBRARIES tangram::tangram)
# Find our modules first
if (CMAKE_VERSION GREATER_EQUAL 3.15)
list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
else ()
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
endif ()
#----------------------------------------------------------------------------
# Find packages here and set CMake variables. Set link dependencies
# and compile definitions for tangram_support target in
# tangram/support. Since the top level tangram::tangram target depends
# on tangram_support, the transitive dependencies will be picked up by
# projects linking to Tangram
#----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Find Wonton
#-----------------------------------------------------------------------------
# Link with an existing installation of Wonton, if provided.
find_package(WONTON QUIET REQUIRED NAMES wonton)
target_include_directories(tangram INTERFACE ${WONTON_INCLUDE_DIR})
message(STATUS "WONTON_INCLUDE_DIR=${WONTON_INCLUDE_DIR}")
target_link_libraries(tangram INTERFACE ${WONTON_LIBRARIES})
message(STATUS "WONTON_LIBRARIES=${WONTON_LIBRARIES}" )
if (TANGRAM_ENABLE_THRUST AND NOT WONTON_ENABLE_THRUST)
message(FATAL_ERROR "Thrust enabled for Tangram but Wonton is not built with Thrust")
endif ()
if (NOT TANGRAM_ENABLE_THRUST AND WONTON_ENABLE_THRUST)
message(FATAL_ERROR "Thrust disabled for Tangram but Wonton is built with Thrust")
endif ()
if (TANGRAM_ENABLE_MPI AND NOT WONTON_ENABLE_MPI)
message(FATAL_ERROR "MPI enabled for Tangram but Wonton is not compiled with MPI")
endif ()
if (NOT TANGRAM_ENABLE_MPI AND WONTON_ENABLE_MPI)
message(FATAL_ERROR "MPI disabled for Tangram but Wonton is compiled with MPI")
endif ()
if (TANGRAM_ENABLE_Jali AND NOT WONTON_ENABLE_Jali)
message(FATAL_ERROR "Jali enabled for Tangram but Wonton is not built with Jali")
endif ()
if (TANGRAM_ENABLE_FleCSI AND NOT WONTON_ENABLE_FleCSI)
message(FATAL_ERROR "FleCSI enabled for Tangram but Wonton is not built with FleCSI")
endif ()
#------------------------------------------------------------------------------#
# Configure XMOF2D
#------------------------------------------------------------------------------#
set(TANGRAM_ENABLE_XMOF2D False CACHE BOOL "Is XMOF2D enabled?")
if (TANGRAM_ENABLE_XMOF2D)
# Look for the XMOF2D package
find_package(XMOF2D REQUIRED)
message(STATUS "Located XMOF2D")
target_include_directories(tangram INTERFACE ${XMOF2D_INCLUDE_DIRS})
message(STATUS "XMOF2D_INCLUDE_DIR ${XMOF2D_INCLUDE_DIRS}")
# XMOF2D_LIBRARIES doesn't contain a real target name. Until we
# upgrade XMOF2D's cmake to export the correct target, we have to
# also specify where to find the library
target_link_directories(tangram INTERFACE ${XMOF2D_LIBRARY_DIR})
target_link_libraries(tangram INTERFACE ${XMOF2D_LIBRARIES})
if (NOT XMOF2D_ROOT)
set(XMOF2D_ROOT ${XMOF2D_INCLUDE_DIR}/../share/cmake CACHE FILEPATH "Where XMOF2D can be found")
endif ()
set(TANGRAM_ENABLE_XMOF2D True CACHE BOOL "Is XMOF2D enabled?" FORCE)
endif ()
if (ENABLE_UNIT_TESTS)
# This needs to be set in the root directory for tests to be run by
# 'make test' or ctest
enable_testing()
include(cmake/unittest.cmake)
endif ()
#-----------------------------------------------------------------------------
# Allow to set TANGRAM_DEBUG from the build script
#-----------------------------------------------------------------------------
option(TANGRAM_DEBUG "Additional checks will be performed and info will be printed" OFF)
if (TANGRAM_DEBUG)
add_definitions(-DTANGRAM_DEBUG)
endif()
#-----------------------------------------------------------------------------
# Recurse down the source directories building up dependencies
#-----------------------------------------------------------------------------
add_subdirectory(tangram)
# In addition to the include directories of the source, we need to
# include the build or directory to get the autogenerated
# tangram-config.h (The first of these is needed if Wonton is included
# as a submodule, the second is needed for the auto-generated config
# file if Tangram is included as a submodule, the third is to get the
# autogenerated config header if Tangram is being compiled separately
# and the last is for dependencies in installations)
target_include_directories(tangram INTERFACE
$<BUILD_INTERFACE:${tangram_SOURCE_DIR}>
$<BUILD_INTERFACE:${tangram_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
$<INSTALL_INTERFACE:include>)
# Tangram targets
install(TARGETS tangram
EXPORT tangram_LIBRARIES
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
PUBLIC_HEADER DESTINATION include
INCLUDES DESTINATION include
)
#-----------------------------------------------------------------------------
# Add any applications built upon tangram
#-----------------------------------------------------------------------------
add_subdirectory(app)
#-----------------------------------------------------------------------------
# Prepare output for configuration files to be used by projects importing Tangram
#-----------------------------------------------------------------------------
# Write a configuration file from template replacing only variables enclosed
# by the @ sign.
configure_file(${PROJECT_SOURCE_DIR}/cmake/tangramConfig.cmake.in
tangramConfig.cmake @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/tangramConfig.cmake DESTINATION lib/cmake/tangram)
# write out a version file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(tangramConfigVersion.cmake
VERSION "${TANGRAM_MAJOR_VERSION}.${TANGRAM_MINOR_VERSION}.${TANGRAM_PATCH_VERSION}"
COMPATIBILITY SameMajorVersion)
install(FILES ${PROJECT_BINARY_DIR}/tangramConfigVersion.cmake
DESTINATION lib/cmake/tangram)
# export targets
install(EXPORT tangram_LIBRARIES
FILE tangramTargets.cmake
NAMESPACE tangram::
EXPORT_LINK_INTERFACE_LIBRARIES
DESTINATION lib/cmake/tangram)
# Dynamically configured header files that contains defines like
# WONTON_ENABLE_MPI etc. if enabled
configure_file(${PROJECT_SOURCE_DIR}/config/tangram-config.h.in
${PROJECT_BINARY_DIR}/tangram-config.h @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/tangram-config.h
DESTINATION ${CMAKE_INSTALL_PREFIX}/include)