forked from marcdegraef/EMsoft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
319 lines (247 loc) · 11.7 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
if(${CMAKE_MAJOR_VERSION} VERSION_GREATER_EQUAL "3.1.0")
cmake_policy(SET CMP0002 NEW)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0048 NEW)
endif()
if(${CMAKE_MAJOR_VERSION} VERSION_GREATER_EQUAL "3.12.0")
cmake_policy(SET CMP0074 NEW)
endif()
if(${CMAKE_MAJOR_VERSION} VERSION_GREATER_EQUAL "3.13.0")
cmake_policy(SET CMP0079 NEW)
endif()
cmake_minimum_required(VERSION 3.8.0)
if(NOT "${EMsoft_SDK}" STREQUAL "")
include("${EMsoft_SDK}/EMsoft_SDK.cmake")
get_property(EMsoft_SDK_STATUS_PRINTED GLOBAL PROPERTY EMsoft_SDK_STATUS_PRINTED)
if(NOT EMsoft_SDK_STATUS_PRINTED)
message(STATUS "********* STARTING EMsoft CONFIGURATION ***********************")
message(STATUS "EMsoft_SDK Location: ${EMsoft_SDK}")
set_property(GLOBAL PROPERTY EMsoft_SDK_STATUS_PRINTED TRUE)
endif()
else()
message(STATUS "You have elected to NOT set a EMsoft_SDK CMake variable. You will")
message(STATUS "need to point to the various dependecies that EMsoft requires for")
message(STATUS "building. Those that are undefined are listed next:")
if(NOT DEFINED bcls_DIR)
message(STATUS "Set bcls_DIR variable to the directory where bclsConfig.cmake is located.")
endif()
if(NOT DEFINED CLFORTRAN_DIR)
message(STATUS "Set CLFORTRAN_DIR variable to the directory where CLFortranConfig.cmake is located.")
endif()
if(NOT DEFINED EIGEN_INSTALL)
message(STATUS "Set EIGEN_INSTALL variable to the root directory of the Eigen installation.")
endif()
if(NOT DEFINED FFTW3_INSTALL)
message(STATUS "Set FFTW3_INSTALL variable to the root directory of the FFTW installation.")
endif()
if(NOT DEFINED HDF5_DIR)
message(STATUS "Set HDF5_DIR variable to the directory where the hdf5-config.cmake is located.")
endif()
if(NOT DEFINED JSONFORTRAN_DIR)
message(STATUS "Set JSONFORTRAN_DIR variable to the directory where the jsonfortran-*-config.cmake is located.")
endif()
if(NOT DEFINED Qt5_DIR)
message(STATUS "Set Qt5_DIR variable to the directory where the Qt5Config.cmake is located.")
endif()
if(NOT DEFINED TBB_DIR)
message(STATUS "Set TBB_DIR variable to the directory where TBBConfig.cmake is located.")
endif()
endif()
# Request C++11 standard, using new CMake variables.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS False)
set(EMsoft_VER_MAJOR "4")
set(EMsoft_VER_MINOR "1")
set(EMsoft_VER_PATCH "1")
project (EMsoft LANGUAGES C CXX Fortran VERSION ${EMsoft_VER_MAJOR}.${EMsoft_VER_MINOR}.${EMsoft_VER_PATCH}.0)
include(CMakeParseArguments)
set(EMsoft_TEST_DIR "EMsofttmp")
# ---------- Setup output Directories -------------------------
if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
${EMsoft_BINARY_DIR}/Bin
CACHE PATH
"Single Directory for all Libraries"
)
endif()
# --------- Setup the Executable output Directory -------------
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
${EMsoft_BINARY_DIR}/Bin
CACHE PATH
"Single Directory for all Executables."
)
endif()
# --------- Setup the Executable output Directory -------------
if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${EMsoft_BINARY_DIR}/Bin
CACHE PATH
"Single Directory for all static libraries."
)
endif()
#Enable use of Solution Folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Build shared libraries
OPTION(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
if(WIN32)
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
endif()
set(LIB_TYPE STATIC)
if(BUILD_SHARED_LIBS)
set(LIB_TYPE SHARED)
list(APPEND CMP_LIB_SEARCH_DIRS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} )
if(MSVC)
list(APPEND CMP_LIB_SEARCH_DIRS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release )
endif()
endif(BUILD_SHARED_LIBS)
get_property(EMsoftBinaryDir GLOBAL PROPERTY EMsoftBinaryDir)
if("${EMsoftBinaryDir}" STREQUAL "")
set(EMsoftBinaryDir "${EMsoftPublic_BINARY_DIR}")
set_property(GLOBAL PROPERTY EMsoftBinaryDir "${EMsoftPublic_BINARY_DIR}")
endif()
get_property(EMsoftSearchDirs GLOBAL PROPERTY EMsoftSearchDirs)
if("${EMsoftSearchDirs}" STREQUAL "")
set_property(GLOBAL PROPERTY EMsoftSearchDirs "${EMsoft_BINARY_DIR}/LibSearchDirs.txt")
get_property(EMsoftSearchDirs GLOBAL PROPERTY EMsoftSearchDirs)
file(WRITE "${EMsoftSearchDirs}" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY};")
file(APPEND "${EMsoftSearchDirs}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY};")
if(MSVC)
file(APPEND "${EMsoftSearchDirs}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug;${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release;")
endif()
endif()
if (NOT DEFINED CMP_SOURCE_DIR)
set(CMP_SOURCE_DIR ${EMsoft_SOURCE_DIR}/Support/cmp)
endif()
# Set the Application Name to with the correct icons and badges
set(CMP_HEADER_DIR ${EMsoft_BINARY_DIR})
set(PROJECT_RESOURCES_DIR "${EMsoft_SOURCE_DIR}/resources")
set(EMsoft_APPLICATION_NAME "EMsoft")
set(EMsoft_VERSION_HDR_FILE "EMsoftVersion.h")
set(EMsoft_VERSION_SRC_FILE "EMsoftVersion.cpp")
set(EXE_DEBUG_EXTENSION "_debug")
include(${CMP_SOURCE_DIR}/cmpProject.cmake)
include (${CMP_SOURCE_DIR}/cmpCMakeMacros.cmake )
#------------------------------------------------------------------------------
# There are several different Release Types that we are going to use.
# Official: This is an official release from BlueQuartz Software
# Beta: This is a Beta release that has is getting ready to be officially released.
# Development: This is currently in development and probably has bugs.
get_property(EMsoft_RELEASE_TYPE GLOBAL PROPERTY PACKAGE_RELEASE_TYPE)
if("${EMsoft_RELEASE_TYPE}" STREQUAL "")
set(EMsoft_RELEASE_TYPE "Development")
set_property(GLOBAL PROPERTY PACKAGE_RELEASE_TYPE "${EMsoft_RELEASE_TYPE}")
endif()
#------------------------------------------------------------------------------
# Find the Git Package for Versioning. It should be ok if Git is NOT found
Find_package(Git)
# -----------------------------------------------------------------------
# Generate a set of Version Cpp/H files that will be used by SIMPLView to
# get and display the proper version numbers.
cmpRevisionString( GENERATED_HEADER_FILE_PATH "${EMsoft_VERSION_HDR_FILE}"
GENERATED_SOURCE_FILE_PATH "${EMsoft_VERSION_SRC_FILE}"
NAMESPACE "EMsoft"
PROJECT_NAME "${PROJECT_NAME}"
EXPORT_MACRO "EMsoft_EXPORT")
include (${CMP_SOURCE_DIR}/cmpProject.cmake)
# --------------------------------------------------------------------
# Over ride CMake's built in module directory by prepending cmp's module
# directory first
set(CMAKE_MODULE_PATH ${EMsoft_SOURCE_DIR}/Support/CMakeModules ${CMAKE_MODULE_PATH})
# set(EXE_DEBUG_EXTENSION "_debug")
set(EXE_DEBUG_EXTENSION "")
# FFLAGS depend on the compiler
get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
if (Fortran_COMPILER_NAME MATCHES "gfortran.*")
# gfortran
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fopenmp -fno-sign-zero")
# set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -funroll-all-loops -fno-f2c -O3 -fno-sign-zero -std=gnu")
set (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -fcheck=bounds -fno-f2c -O0 -g -fno-sign-zero -std=gnu")
get_filename_component (Fortran_COMPILER_PATH ${CMAKE_Fortran_COMPILER} DIRECTORY)
set(GFortran_LIB_DIR "${Fortran_COMPILER_PATH}/../lib")
elseif (Fortran_COMPILER_NAME MATCHES "ifort.*")
# ifort (untested)
if(WIN32)
set (CMAKE_Fortran_FLAGS_RELEASE "/Qopenmp /Qdiag-disable:11082 /Qip")
set (CMAKE_Fortran_FLAGS_DEBUG "/Qopenmp /Qdiag-disable:11082 /Qip")
set (CMAKE_SHARED_LINKER_FLAGS "/ignore:4217 /ignore:4049")
else()
set (CMAKE_Fortran_FLAGS_RELEASE "-O3 -qopenmp")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -qopenmp")
endif()
else (Fortran_COMPILER_NAME MATCHES "gfortran.*")
message (STATUS "CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
message (STATUS "Fortran compiler: " ${Fortran_COMPILER_NAME})
message (STATUS "No optimized Fortran compiler flags are known.")
endif (Fortran_COMPILER_NAME MATCHES "gfortran.*")
# --------------------------------------------------------------------
# This should all be for macOS 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_PREFIX}/lib")
# 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
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
include (${PROJECT_SOURCE_DIR}/Support/ExtLib/ExtLibraries.cmake)
OPTION(EMsoft_ENABLE_TESTING "Compile the test programs" ON)
set(EMsoft_TESTING_DIR "${EMsoft_BINARY_DIR}/Testing")
# -----------------------------------------------------------------------
# Set a Global Prefix where everthing is going to get intalled. For OS X we are
# going to try to install everything into the .app package
# -----------------------------------------------------------------------
set_property(GLOBAL PROPERTY EMsoft_PACKAGE_DEST_PREFIX ".")
include(${PROJECT_SOURCE_DIR}/Source/Source.cmake)
# --------------------------------------------------------------------
# Package the needed examples
include(${PROJECT_SOURCE_DIR}/manuals/examples/SourceList.cmake)
# # --------------------------------------------------------------------
# # Package the needed IDL Files
# if(APPLE)
# include(${PROJECT_SOURCE_DIR}/IDL/SourceList.cmake)
# endif()
# --------------------------------------------------------------------
# Package the needed PDF Manuals
include(${PROJECT_SOURCE_DIR}/manuals/CMakeLists.txt)
# --------------------------------------------------------------------
# Package the OpenCL files
include(${PROJECT_SOURCE_DIR}/opencl/SourceList.cmake)
# --------------------------------------------------------------------
# Package the needed resources
include(${PROJECT_SOURCE_DIR}/resources/SourceList.cmake)
# --------------------------------------------------------------------
# Package the needed template files
include(${PROJECT_SOURCE_DIR}/NamelistTemplates/SourceList.cmake)
# --------------------------------------------------------------------
# Generate our ReadMe and License Files
configure_file(${PROJECT_SOURCE_DIR}/License.txt
${PROJECT_BINARY_DIR}/License.txt )
configure_file(${PROJECT_SOURCE_DIR}/ReadMe.md
${PROJECT_BINARY_DIR}/ReadMe.md )
#---------------------------------------------------------------------
# This sets up the two variables install_dir and lib_install_dir
EMsoft_SetupInstallDirs()
install(FILES ${PROJECT_SOURCE_DIR}/ReadMe.md ${PROJECT_SOURCE_DIR}/License.txt
DESTINATION ${install_dir}/Documentation
COMPONENT Applications)
# --------------------------------------------------------------------
# Include the CPack specific code
include(${EMsoft_SOURCE_DIR}/Support/CPack/PackageProject.cmake)
# --------------------------------------------------------------------
# This should be the last line in this file as it includes CTest for
# nightly testing.
if(EMsoft_ENABLE_TESTING)
ENABLE_TESTING()
include(CTest)
add_subdirectory(${EMsoft_SOURCE_DIR}/Source/Test ${PROJECT_BINARY_DIR}/Test)
endif()