-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
225 lines (174 loc) · 6.12 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
# Description: Main CMake build file for the Pastel library
# Documentation: building.txt
cmake_minimum_required (VERSION 3.16)
if(NOT "${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD 20)
endif()
# Set up VCPKG
# ------------
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake
CACHE STRING "Vcpkg toolchain file")
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
endif()
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
endif()
project (Pastel)
# CMake build options
# -------------------
option (BuildLibraries "Build Pastel's main libraries." ON)
option (BuildMatlab "Build Pastel's Matlab-libraries." ON)
option (BuildTests "Build Pastel's tests." ON)
option (BuildExamples "Build Pastel's examples." ON)
# ECMake
# ------
# Directory for CMake to search for CMake-included() files.
list (INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake)
# Initialize ECMake.
include ("ecmake")
# Setup compilers.
include ("SetupCompilers")
message(STATUS
"Current compiler is ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
if (CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(
-DPASTEL_ENABLE_ASSERTS
)
endif()
# Dependencies
# ------------
# Range v3
find_package(range-v3 CONFIG REQUIRED)
link_libraries(range-v3::range-v3)
add_definitions(-DRANGES_NO_STD_FORWARD_DECLARATIONS)
get_target_property(RangesIncludeDirectory range-v3 INTERFACE_INCLUDE_DIRECTORIES)
# Boost
find_package(Boost REQUIRED)
link_libraries(Boost::boost)
add_definitions(
-DBOOST_BIND_GLOBAL_PLACEHOLDERS
)
set (BoostIncludeDirectory ${Boost_INCLUDE_DIRS})
# Eigen3
find_package(Eigen3 3.3 CONFIG REQUIRED NO_MODULE)
link_libraries(Eigen3::Eigen)
add_definitions (
# std::result_of was removed in C++20.
-DEIGEN_HAS_STD_RESULT_OF=0
)
# Threading Building Blocks
find_package(TBB CONFIG REQUIRED)
link_libraries(TBB::tbb)
get_target_property(TbbIncludeDirectory TBB::tbb INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(TbbMallocIncludeDirectory TBB::tbbmalloc INTERFACE_INCLUDE_DIRECTORIES)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
get_target_property(TbbLibraryPath TBB::tbb IMPORTED_LOCATION_DEBUG)
get_target_property(TbbMallocLibraryPath TBB::tbbmalloc IMPORTED_LOCATION_DEBUG)
else()
get_target_property(TbbLibraryPath TBB::tbb IMPORTED_LOCATION_RELEASE)
get_target_property(TbbMallocLibraryPath TBB::tbbmalloc IMPORTED_LOCATION_RELEASE)
endif()
get_filename_component(TbbLibraryDirectory ${TbbLibraryPath} DIRECTORY)
get_filename_component(TbbLibraryName ${TbbLibraryPath} NAME)
get_filename_component(TbbMallocLibraryDirectory ${TbbMallocLibraryPath} DIRECTORY)
get_filename_component(TbbMallocLibraryName ${TbbMallocLibraryPath} NAME)
if (UNIX)
# FIX: This is a hack to get the library name correct under Linux.
string (REPLACE lib "" TbbLibraryName ${TbbLibraryName})
string (REPLACE .a "" TbbLibraryName ${TbbLibraryName})
string (REPLACE lib "" TbbMallocLibraryName ${TbbMallocLibraryName})
string (REPLACE .a "" TbbMallocLibraryName ${TbbMallocLibraryName})
endif()
if (BuildMatlab)
set (MatlabDirectoryWindows "C:/Program Files/Polyspace/R2020b")
set (MatlabDirectoryMac "/Applications/MATLAB_R2020b.app")
set (MatlabDirectoryLinux "/usr/local/Polyspace/R2020b")
if (WIN32)
set (MatlabDirectory ${MatlabDirectoryWindows})
elseif(UNIX)
if (APPLE)
set (MatlabDirectory ${MatlabDirectoryMac})
else()
set (MatlabDirectory ${MatlabDirectoryLinux})
endif()
endif()
set (MatlabIncludeDirectory "${MatlabDirectory}/extern/include")
EcCheckPathExists("Matlab (include)" "${MatlabIncludeDirectory}")
include_directories (${MatlabIncludeDirectory})
endif()
message(STATUS "Range-v3: ${RangesIncludeDirectory}")
message(STATUS "Boost: ${Boost_INCLUDE_DIRS} ${Boost_LIBRARIES}")
message(STATUS "Eigen: ${EIGEN3_INCLUDE_DIRS}")
message(STATUS "Tbb: ${TbbIncludeDirectory} ${TbbLibraryPath}")
message(STATUS "Tbbmalloc: ${TbbMallocIncludeDirectory} ${TbbMallocLibraryPath}")
# Copy files
# ----------
set (CopySet
${ProjectDirectory}/test/pastel/gfx/lena.pcx
${ProjectDirectory}/test/pastel/gfx/resample_text.pcx
${ProjectDirectory}/test/pastel/gfx/testpcx_1bit.pcx
${ProjectDirectory}/test/pastel/gfx/testpcx_4bit.pcx
${ProjectDirectory}/test/pastel/gfx/testpcx_8bit.pcx
${ProjectDirectory}/test/pastel/gfx/testpcx_rgb.pcx
)
foreach (Filename ${CopySet})
EcCopyAsideExecutables("${Filename}")
endforeach()
# Copy some data files.
file (COPY "${ProjectDirectory}/pastelmatlab/matlab/+pastelmatlab/fish.txt"
DESTINATION "${ProjectMatlabDirectory}/+pastelmatlab")
# Source file globs
# -----------------
# The source files to include in a C++ project.
set (PastelSourceGlobSet *.cpp *.h *.hpp *.txt)
# The source files to include in a Matlab project.
set (PastelMatlabSourceGlobSet *.m *.m.cmake)
# The documentation files of the project.
set (PastelDocumentationGlobSet *.txt)
# Recurse to sub-projects
# -----------------------
add_subdirectory (pastel)
if (BuildTests)
add_subdirectory (test)
endif()
if (BuildMatlab)
add_subdirectory (pastelmatlab)
endif()
if (BuildExamples)
add_subdirectory (example)
endif()
# message (STATUS "CMAKE_INSTALL_LIBDIR = ${CMAKE_INSTALL_LIBDIR}")
# message (STATUS "CMAKE_CURRENT_BINARY_DIR = ${CMAKE_CURRENT_BINARY_DIR}")
# message (STATUS "CMAKE_INSTALL_DATADIR = ${CMAKE_INSTALL_DATADIR}")
# add_library(Pastel INTERFACE)
# add_library(Pastel::Pastel ALIAS Pastel)
# target_link_libraries(
# Pastel
# INTERFACE
# PastelSys::PastelSys
# PastelMath::PastelMath
# PastelGeometry:PastelGeometry
# PastelGfx::PastelGfx
# )
# install(
# TARGETS
# Pastel
# EXPORT PastelConfig
# ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
# RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
# )
# export(
# TARGETS
# Pastel
# NAMESPACE Pastel::
# FILE "${CMAKE_CURRENT_BINARY_DIR}/PastelConfig.cmake"
# )
# install(
# EXPORT
# PastelConfig
# DESTINATION "${CMAKE_INSTALL_DATADIR}/Pastel/cmake"
# NAMESPACE Pastel::
# )