forked from EMsoft-org/EMsoftSuperbuild
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
228 lines (180 loc) · 7.83 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
if(${CMAKE_MAJOR_VERSION} STREQUAL "3")
# CMake 3.0 introduces VERSION variables for each Project.
cmake_policy(SET CMP0048 NEW)
# CMake 3.1 introduces if() policies on dereferencing variables in quotes
cmake_policy(SET CMP0054 NEW)
endif()
cmake_minimum_required(VERSION 3.8.0)
project(EMsoftSuperBuild VERSION 1.0.0.0 LANGUAGES C CXX Fortran)
# This allows us to just use the "include()" command and the name of the project
set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/projects"
${CMAKE_MODULE_PATH})
set(BUILD_TYPE ${CMAKE_BUILD_TYPE})
if("${BUILD_TYPE}" STREQUAL "")
set(BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
# Set up some standard defaults, these will be passed down into external the
# projects.
include(BuildType)
include(BuildLocation)
include(ExternalProject)
include(download_dir)
# Use multiple CPU cores to build
include(ProcessorCount)
ProcessorCount(CoreCount)
if(MSVC90)
message(FATAL_ERROR "Visual Studio Version 9 2009 is NOT supported.")
endif(MSVC90)
if(MSVC10)
message(FATAL_ERROR "Visual Studio Version 10 2010 is NOT supported.")
endif(MSVC10)
if(MSVC11)
message(FATAL_ERROR "Visual Studio Version 11 2012 is NOT supported.")
endif(MSVC11)
if(MSVC12)
message(FATAL_ERROR "Visual Studio Version 12 2013 is NOT supported.")
endif(MSVC12)
if( "${EMsoft_SDK}" STREQUAL "")
message(FATAL_ERROR "Please specify the EMsoft_SDK cmake variable which is the top level directory where all the EMsoft dependent libraries will be built")
endif()
set(EMsoft_SDK_FILE ${EMsoft_SDK}/EMsoft_SDK.cmake)
set(download_dir ${EMsoft_SDK})
message(STATUS "EMsoft_SDK Folder: ${EMsoft_SDK}")
message(STATUS "EMsoft_SDK_FILE: ${EMsoft_SDK_FILE}")
set(CLONE_EMSOFT_REPO 1)
if("${WORKSPACE_DIR}" STREQUAL "")
#get_filename_component(WORKSPACE_DIR ${EMsoftSuperBuild_SOURCE_DIR} DIRECTORY)
set(CLONE_EMSOFT_REPO 0)
endif()
message(STATUS "Workspace Folder: ${WORKSPACE_DIR}")
set(BUILD_SHARED_LIBS ON)
OPTION(INSTALL_QT5 "Download and Install Qt5" ON)
if(APPLE)
set(OSX_SDK "NOT-FOUND")
EXEC_PROGRAM(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
STRING(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
#message(STATUS "DARWIN_VERSION: ${DARWIN_VERSION}")
IF (DARWIN_VERSION EQUAL 14) # macOS 10.10 Yosemite
message(STATUS "Found macOS 10.10 Yosemite as the host. Darwin Version:${DARWIN_VERSION}")
set(OSX_SDK "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk")
ENDIF ()
IF (DARWIN_VERSION EQUAL 15) # macOS 10.11 El Capitan
message(STATUS "Found macOS 10.11 El Capitan as the host. Darwin Version:${DARWIN_VERSION}")
set(OSX_SDK "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk")
ENDIF ()
IF (DARWIN_VERSION EQUAL 16) # macOS 10.12 Sierra (Xcode 8.x or Xcode 9.x)
message(STATUS "Found macOS 10.12 Sierra as the host. Darwin Version:${DARWIN_VERSION}")
set(OSX_SDK "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
ENDIF ()
IF (DARWIN_VERSION EQUAL 17) # macOS 10.13 High Sierra (Xcode 9.x)
message(STATUS "Found macOS 10.13 High Sierra as the host. Darwin Version:${DARWIN_VERSION}")
set(OSX_SDK "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
ENDIF ()
IF (DARWIN_VERSION EQUAL 18) # macOS 10.14 Mojave (Xcode 10.x)
message(STATUS "Found macOS 10.14 Mojave as the host. Darwin Version:${DARWIN_VERSION}")
set(OSX_SDK "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
ENDIF ()
if("${OSX_SDK}" STREQUAL "NOT-FOUND")
message(FATAL_ERROR "This version of macOS (${DARWIN_VERSION}) is not recognized.\
The following versions are supported:\n\
(14) macOS 10.10 Yosemite\n\
(15) macOS 10.11 El Capitan\n\
(16) macOS 10.12 Sierra\n\
(17) macOS 10.13 High Sierra\n\
(18) macOS 10.14 Mojave\n\
Please edit ${CMAKE_CURRENT_LIST_FILE} and add this version of macOS to the detection logic.
")
endif()
set(OSX_DEPLOYMENT_TARGET "10.10")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/projects/apple/OSX_EMsoft_SDK.cmake
${EMsoft_SDK}/EMsoft_SDK.cmake @ONLY )
elseif(WIN32)
if(MSVC90)
message(FATAL_ERROR "Visual Studio Version 9 2009 is NOT supported.")
endif(MSVC90)
if(MSVC10)
message(FATAL_ERROR "Visual Studio Version 10 2010 is NOT supported.")
endif(MSVC10)
if(MSVC11)
message(FATAL_ERROR "Visual Studio Version 11 2012 is NOT supported.")
endif(MSVC11)
if(MSVC12)
message(FATAL_ERROR "Visual Studio Version 12 2013 is NOT supported.")
endif(MSVC12)
if( ${MSVC_VERSION} EQUAL "1900")
message(FATAL_ERROR "Visual Studio Version 14 2015 is NOT supported.")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/projects/win32/WIN_EMsoft_SDK.cmake
${EMsoft_SDK}/EMsoft_SDK.cmake COPYONLY )
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/projects/unix/Linux_EMsoft_SDK.cmake
${EMsoft_SDK}/EMsoft_SDK.cmake COPYONLY )
endif()
FILE(APPEND ${EMsoft_SDK_FILE} "\n#--------------------------------------------------------------------------------------------------\n")
FILE(APPEND ${EMsoft_SDK_FILE} "set(EMsoft_SDK_ROOT \"${EMsoft_SDK}\")\n")
FILE(APPEND ${EMsoft_SDK_FILE} "set(EMsoft_SDK_VERSION ${EMsoft_SDK_VERSION})\n")
FILE(APPEND ${EMsoft_SDK_FILE} "\n#--------------------------------------------------------------------------------------------------\n")
FILE(APPEND ${EMsoft_SDK_FILE} "# EMsoft does not use QtWebEngine to render the docs anymore. Let the system do it.\n")
FILE(APPEND ${EMsoft_SDK_FILE} "set(EMsoftWorkbench_USE_QtWebEngine OFF)\n")
FILE(APPEND ${EMsoft_SDK_FILE} "\n#--------------------------------------------------------------------------------------------------\n")
FILE(APPEND ${EMsoft_SDK_FILE} "# Always write out the compile_commands.json file to help out things like QtCreator and VS Code\n")
FILE(APPEND ${EMsoft_SDK_FILE} "set(CMAKE_EXPORT_COMPILE_COMMANDS ON)\n")
#------------------------------------------------------------------------------
# On Windows we are going to use Intel MKL with the FFTW interface so we do not
# need to install FFTW3
if(NOT WIN32)
include(FFTW)
endif()
include(JsonFortran)
include(Bcls)
include(CLFortran)
include(Eigen)
include(HDF5)
include(TBB)
if("${INSTALL_QT5}" STREQUAL "ON")
include(Qt5)
include(EbsdLib)
else()
message(WARNING "The EMsoft_SDK.cmake file will be incomplete as intended. The paths to your Qt installation will be missing and EMsoft will probably not build.")
endif()
#------------------------------------------------------------------------------
#
#------------------------------------------------------------------------------
function(CloneRepo)
set(options )
set(oneValueArgs DEPENDS PROJECT_NAME GIT_REPOSITORY TMP_DIR STAMP_DIR DOWNLOAD_DIR SOURCE_DIR BINARY_DIR INSTALL_DIR)
set(multiValueArgs )
cmake_parse_arguments(Z "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
set(projectName ${Z_PROJECT_NAME})
message(STATUS "Cloning ${projectName}" )
set(SOURCE_DIR "${Z_WORKSPACE_DIR}")
set_property(DIRECTORY PROPERTY EP_BASE ${SOURCE_DIR}/${projectName})
ExternalProject_Add(${projectName}
DEPENDS ${Z_DEPENDS}
TMP_DIR ${Z_TMP_DIR}
STAMP_DIR ${Z_STAMP_DIR}
DOWNLOAD_DIR ${Z_DOWNLOAD_DIR}
SOURCE_DIR ${Z_SOURCE_DIR}
BINARY_DIR ${Z_BINARY_DIR}
INSTALL_DIR ${Z_INSTALL_DIR}
GIT_PROGRESS 1
GIT_REPOSITORY "${Z_GIT_REPOSITORY}"
GIT_TAG develop
UPDATE_COMMAND ""
PATCH_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
LOG_DOWNLOAD 1
LOG_UPDATE 1
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_TEST 1
LOG_INSTALL 1
)
endfunction()
if(CLONE_EMSOFT_REPO)
endif()