-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCMakeLists.txt
151 lines (126 loc) · 6.17 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
cmake_policy(SET CMP0002 NEW)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0079 NEW)
cmake_policy(SET CMP0077 NEW)
cmake_minimum_required(VERSION 3.14.0)
# Request C++17 standard, using new CMake variables.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
#--------------------------------------------------------------------------------------------------
# Always write out the compile_commands.json file to help out things like QtCreator and VS Code
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# set project's name
project(EbsdLibProj VERSION 1.0.36)
# ---------- Setup output Directories -------------------------
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/Bin
CACHE PATH
"Single Directory for all Libraries"
)
# --------- Setup the Executable output Directory -------------
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/Bin
CACHE PATH
"Single Directory for all Executables."
)
# --------- Setup the Executable output Directory -------------
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/Bin
CACHE PATH
"Single Directory for all static libraries."
)
option(EbsdLib_DISABLE_MSVC_WARNINGS ON)
option(BUILD_SHARED_LIBS "Build Shared Libs" ON)
get_filename_component(EbsdLib_PARENT ${EbsdLibProj_SOURCE_DIR} DIRECTORY CACHE)
#-------------------------------------------------------------------------------
# Find the HDF5 Library as we need that.
#-------------------------------------------------------------------------------
# Extra Variables that need to be set before all the configured files are generated.
option(EbsdLib_ENABLE_HDF5 "Enable HDF5 Support in the EbsdLibProj" ON)
option(EbsdLib_BUILD_H5SUPPORT "Build H5Support Library" ON)
if(EbsdLib_ENABLE_HDF5)
if(EbsdLib_BUILD_H5SUPPORT)
if(NOT TARGET H5Support::H5Support)
#------------------------------------------------------------------------------
# If the developer has set another H5Support directory then use that, otherwise look
# for the H5Support directory at the same level as the EBSDLib directory
if("${H5Support_SOURCE_DIR}" STREQUAL "")
if(EXISTS "${EbsdLib_PARENT}/H5Support")
set(H5Support_SOURCE_DIR "${EbsdLib_PARENT}/H5Support")
elseif(EXISTS "${EbsdLib_SOURCE_DIR}/H5Support")
set(H5Support_SOURCE_DIR "${EbsdLib_SOURCE_DIR}/H5Support")
else()
message(FATAL_ERROR "H5Support_SOURCE_DIR was not set. Where is the H5Support project directory. Please set the H5Support_SOURCE_DIR variable to the CMP directory.")
endif()
message(STATUS "H5Support_SOURCE_DIR: ${H5Support_SOURCE_DIR}")
endif()
set(H5Support_INCLUDE_QT_API OFF)
add_subdirectory("${H5Support_SOURCE_DIR}" "${EbsdLibProj_BINARY_DIR}/H5Support")
endif()
else()
find_package(H5Support REQUIRED)
endif()
endif()
mark_as_advanced(EbsdLib_ENABLE_HDF5)
#-------------------------------------------------------------------------------
# Find the Eigen Library as we need that.
#-------------------------------------------------------------------------------
find_package(Eigen3 REQUIRED)
if(EIGEN3_FOUND)
message(STATUS "Eigen3 Location: ${EIGEN3_ROOT_DIR}")
message(STATUS "Eigen3 Version: ${EIGEN3_VERSION_STRING}")
set(EBSD_USE_EIGEN "1" CACHE INTERNAL "")
else()
message(WARNING "The Eigen Library is required for some algorithms to execute. These algorithms will be disabled.")
endif()
#-------------------------------------------------------------------------------
# Determine if we need the ghcFilesystem library
#-------------------------------------------------------------------------------
set(EbsdLib_USE_GHC_FILESYSTEM OFF)
if(APPLE)
exec_program(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
if(DARWIN_VERSION VERSION_LESS 19)
message(STATUS "The current macOS System is too old to compile and will fail. Please set the EbsdLib_USE_GHC_FILESYSTEM=ON variable to allow Ebsdlib to compile")
endif()
message(STATUS "EbsdLib: DARWIN_VERSION ${DARWIN_VERSION}")
message(STATUS "EbsdLib: CMAKE_OSX_DEPLOYMENT_TARGET: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
if(NOT "${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "" )
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.15)
message(STATUS "EbsdLib: CMAKE_OSX_DEPLOYMENT_TARGET less than 10.15. Enabling EbsdLib_USE_GHC_FILESYSTEM")
set(EbsdLib_USE_GHC_FILESYSTEM ON)
endif()
endif()
endif()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
set(EbsdLib_USE_GHC_FILESYSTEM ON)
endif()
message(STATUS "EbsdLib: EbsdLib_USE_GHC_FILESYSTEM: ${EbsdLib_USE_GHC_FILESYSTEM}")
if(EbsdLib_USE_GHC_FILESYSTEM)
find_package(ghcFilesystem REQUIRED NAMES ghc_filesystem ghcFilesystem)
endif()
#-------------------------------------------------------------------------------
# Are we using Parallel Algorithms.
#-------------------------------------------------------------------------------
option(EbsdLib_USE_PARALLEL_ALGORITHMS "Enable EBSDLib to use parallel algorithms" ON)
if(EbsdLib_USE_PARALLEL_ALGORITHMS) # If TBB already exists no need to look for it (e.g. EbsdLib is added as a subdirectory in DREAM3D)
find_package(TBB CONFIG REQUIRED)
get_target_property(tbb_dll_path TBB::tbb IMPORTED_LOCATION_RELEASE)
get_filename_component(tbb_dll_path "${tbb_dll_path}" DIRECTORY)
get_property(EbsdLib_EXTRA_LIBRARY_DIRS GLOBAL PROPERTY EbsdLib_EXTRA_LIBRARY_DIRS)
set_property(GLOBAL PROPERTY EbsdLib_EXTRA_LIBRARY_DIRS ${EbsdLib_EXTRA_LIBRARY_DIRS} ${tbb_dll_path})
endif()
include(${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/SourceList.cmake)
option(EbsdLib_ENABLE_TESTING "Enable the unit test" ON)
if(EbsdLib_ENABLE_TESTING)
include(${EbsdLibProj_SOURCE_DIR}/Source/Test/CMakeLists.txt)
endif()
option(EbsdLib_BUILD_TOOLS "Build example applications" ON)
if(EbsdLib_BUILD_TOOLS)
include(${EbsdLibProj_SOURCE_DIR}/Source/Apps/SourceList.cmake)
endif()
# -----------------------------------------------------------------------
# Include the packaging Cmake codes
# -----------------------------------------------------------------------
include(${EbsdLibProj_SOURCE_DIR}/cmake/Packaging.cmake)