-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
160 lines (139 loc) · 5.58 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
project(E2)
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
if(NOT CMAKE_BUILD_TYPE)
message("Build type not set => setting 'Release' as default.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Release" FORCE)
endif()
message("Build type = " ${CMAKE_BUILD_TYPE})
if(CMAKE_BUILD_TYPE MATCHES "Debug")
add_definitions(-DDEBUG)
elseif(CMAKE_BUILD_TYPE MATCHES "Release")
add_definitions(-DRELEASE)
elseif(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
add_definitions(-DRELEASE)
else()
message(SEND_ERROR "Unknown build type. Use either Debug, Release, or RelWithDebInfo. E.g.: -DCMAKE_BUILD_TYPE=Release")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions("-std=c++11 -Wall -Wno-unused-local-typedefs")
if ((CMAKE_BUILD_TYPE STREQUAL Debug) OR
(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo))
add_definitions("-ggdb3")
endif()
message("Compiler = GCC")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_definitions("/bigobj")
#add_definitions("/Wall")
add_definitions("-D_ENABLE_EXTENDED_ALIGNED_STORAGE")
message("Compiler = MSVC")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_definitions("
-Wno-dangling-else
-Wno-overloaded-virtual
-Wno-unused-lambda-capture
-Wno-potentially-evaluated-expression
-Wno-#pragma-messages
-Wno-deprecated-declarations
")
message("Compiler = Clang/LLVM")
else()
message(SEND_ERROR "Unknown (unsupported) compiler detected. Supported is only GCC (on Linux) and MSVC (on Windows).")
endif()
macro(append_compiler_flags FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
endmacro()
macro(append_linker_flags FLAGS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAGS}")
endmacro()
if(EMSCRIPTEN)
message("Target platform: WEBASSEMBLY")
set(CMAKE_EXECUTABLE_SUFFIX ".html")
add_definitions("
-Wno-dangling-else
-Wno-overloaded-virtual
-Wno-unused-lambda-capture
-Wno-potentially-evaluated-expression
-Wno-#pragma-messages
-Wno-deprecated-declarations
")
add_compile_definitions(WEBASSEMBLY)
append_linker_flags("-s ALLOW_MEMORY_GROWTH=1")
append_linker_flags("-s USE_GLFW=3 -s USE_WEBGL2=1") #"-O2 -s USE_SDL=2 -s USE_WEBGL2=1"
append_linker_flags("-s MIN_WEBGL_VERSION=2 -s MAX_WEBGL_VERSION=2")
append_linker_flags("-s GL_ASSERTIONS=1")
append_linker_flags("-s GL_DEBUG=1")
append_linker_flags("-s LLD_REPORT_UNDEFINED")
append_linker_flags("-s NO_DISABLE_EXCEPTION_CATCHING")
# find and add Eigen math library
message("Searching for Eigen ...")
find_package(Eigen3 CONFIG REQUIRED)
set(EIGEN_LIST_OF_LIBRARIES_TO_LINK_WITH "Eigen3::Eigen")
message("Eigen3 found at: ${EIGEN3_INCLUDE_DIRS}")
add_definitions( ${EIGEN3_DEFINITIONS} )
include_directories("${EIGEN3_INCLUDE_DIRS}")
# find and add LODEPNG library
message("Searching for LODEPNG ...")
find_package(lodepng CONFIG REQUIRED)
find_path(lodepng_INCLUDES lodepng.h)
include_directories("${lodepng_INCLUDES}")
set(LODEPNG_LIST_OF_LIBRARIES_TO_LINK_WITH "lodepng")
#set(BOOST_LIST_OF_LIBRARIES_TO_LINK_WITH "")
set(OPENGL_LIST_OF_LIBRARIES_TO_LINK_WITH "")
set(GLAD_LIST_OF_LIBRARIES_TO_LINK_WITH "")
set(GLFW_LIST_OF_LIBRARIES_TO_LINK_WITH "")
else()
message("Target platform: PC")
# find and add Boost
message("Searching for Boost library ...")
find_package(Boost COMPONENTS
program_options
REQUIRED)
set(BOOST_LIST_OF_LIBRARIES_TO_LINK_WITH
${Boost_LIBRARIES}
)
# find and add Eigen math library
message("Searching for Eigen ...")
find_package(Eigen3 CONFIG REQUIRED)
set(EIGEN_LIST_OF_LIBRARIES_TO_LINK_WITH "Eigen3::Eigen")
# find and add OpenGL
message("Searching for OpenGL ...")
find_package(OpenGL REQUIRED)
# include_directories(${OPENGL_INCLUDE_DIRS})
link_directories(${OPENGL_LIBRARY_DIRS})
add_definitions(${OPENGL_DEFINITIONS})
set(OPENGL_LIST_OF_LIBRARIES_TO_LINK_WITH
${OPENGL_LIBRARIES}
)
if(NOT OPENGL_INCLUDE_DIR)
message("OpenGL includes were found in directory: <empty>")
else()
message("OpenGL includes were found in directory: " ${OPENGL_INCLUDE_DIR})
endif()
# find and add GLAD library
message("Searching for GLAD ...")
find_package(glad CONFIG REQUIRED)
set(GLAD_LIST_OF_LIBRARIES_TO_LINK_WITH "glad::glad")
# find and add GLFW library
message("Searching for GLFW ...")
find_package(glfw3 CONFIG REQUIRED)
set(GLFW_LIST_OF_LIBRARIES_TO_LINK_WITH "glfw")
# find and add LODEPNG library
message("Searching for LODEPNG ...")
find_package(lodepng CONFIG REQUIRED)
set(LODEPNG_LIST_OF_LIBRARIES_TO_LINK_WITH "lodepng")
endif()
set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/dist" CACHE STRING "Install path" FORCE)
set(CMAKE_INSTALL_RPATH "./")
#set(CMAKE_BINARY_DIR "${PROJECT_SOURCE_DIR}/build" CACHE STRING "Build directory" FORCE)
set(E2_3RD_INCLUDE_DIR "${CMAKE_TOOLCHAIN_FILE}/../../../installed/${VCPKG_TARGET_TRIPLET}/include")
include_directories(${E2_3RD_INCLUDE_DIR})
message("3rd includes directory = ${E2_3RD_INCLUDE_DIR}")
message("Sources directory = ${PROJECT_SOURCE_DIR}/code")
message("Install directory = ${CMAKE_INSTALL_PREFIX}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/code")
# Add project specific code
add_subdirectory(./code)
install(DIRECTORY ./data DESTINATION . PATTERN Blender EXCLUDE)
message("Generating build files ...")