forked from LibreCAD/LibreCAD_3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
229 lines (183 loc) · 7.41 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
cmake_minimum_required(VERSION 3.6)
project(LC)
#https://stackoverflow.com/questions/7229571/cmake-visual-studio-debug-folder
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) #This for each is needed to avoid binary builds in bin/relDebWithInfo folder
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(WITH_QT_UI "With QT user interface" ON)
option(WITH_LUACMDINTERFACE "Build Lua command line interface" ON) #TODO fails in Ubuntu 18.04, this is why OFF #Trying out it on ON again, since now we are using 20.04
option(WITH_UNITTESTS "Build unit tests" ON)
option(WITH_RENDERING_UNITTESTS "Build rendering unit tests (require GDK)" ON)
option(WITH_LIBOPENCAD "Use libopencad" OFF)
option(WITH_CAIRO "Compile with Cairo painter" OFF)
option(WITH_COVERAGE "Compile with coverage for unit tests" OFF)
#make doc/tests ?
option(WITH_DOCUMENTATION "Build documentation" OFF)
option(WITH_PERSISTENCE "Build dxf/dwg support" ON)
# Define compiler warnings
if (NOT MSVC) # Too much warnings on MSVC
add_definitions("-Wall")
endif()
include(GNUInstallDirs)
set(FINAL_INSTALL_DIR "finalInstallDir")
if(EXISTS "${CMAKE_SOURCE_DIR}/conan/conanbuildinfo.cmake")
include(${CMAKE_SOURCE_DIR}/conan/conanbuildinfo.cmake)
set(CMAKE_FIND_LIBRARY_PREFIXES "" "lib")
set(WITH_LIBOPENCAD OFF)
set(WITH_LUACMDINTERFACE FALSE)
set(WITH_RENDERING_UNITTESTS OFF)
set(WITH_CAIRO OFF)
set(WITH_UNITTESTS ON)
set(BOOST_ROOT "${CONAN_BOOST_ROOT}")
set(Boost_USE_STATIC_LIBS ON)
add_definitions( -DBOOST_ALL_NO_LIB )
add_definitions("${CONAN_DEFINES_BOOST}")
set(EIGEN3_INCLUDE_DIR "${CONAN_INCLUDE_DIRS_EIGEN}")
set(ENV{LUA_DIR} "${CONAN_LUA_ROOT}")
set(GLEW_INCLUDE_DIR "${CONAN_INCLUDE_DIRS_GLEW}")
set(ENV{GLEW_ROOT} "${CONAN_GLEW_ROOT}")
add_definitions("${CONAN_DEFINES_GLEW}")
set(ENV{FREETYPE_DIR} "${CONAN_FREETYPE_ROOT}")
set(PNG_PNG_INCLUDE_DIR "${CONAN_INCLUDE_DIRS_LIBPNG}")
set(PNG_LIBRARY "${CONAN_LIB_DIRS_LIBPNG}/libpng16.lib")
set(ZLIB_ROOT "${CONAN_ZLIB_ROOT}")
set(BZIP2_INCLUDE_DIR "${CONAN_INCLUDE_DIRS_BZIP2}")
set(BZIP2_LIBRARIES "${CONAN_LIB_DIRS_BZIP2}/bz2.lib")
set(OPENGL_INCLUDE_DIR "${CONAN_INCLUDE_DIRS_GLM}")
set(LIBDXFRW_PATH "${CONAN_LIBDXFRW_ROOT}")
set(RAPIDJSON_INCLUDE_DIRS "${CONAN_INCLUDE_DIRS_RAPIDJSON}")
else()
set(Boost_USE_STATIC_LIBS OFF)
add_definitions(-DBOOST_ALL_DYN_LINK)
endif()
if(MSVC)
add_definitions("/bigobj")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Kaguya uses a pointer to a local variable (in object.hpp file) to store class conversions.
# When used in different modules, the variable doesn't have the same address, preventing to mix kernel and UI bindings
add_definitions("-DKAGUYA_SUPPORT_MULTIPLE_SHARED_LIBRARY=1")
endif()
# Set C++ version
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
set(Boost_USE_MULTITHREADED ON)
set(SETTINGS_PATH "") #The settings will be at the same place as executable.
# Add dirent.h if compiler is MSVC
if(MSVC)
include_directories("third_party/msvc_dirent")
endif()
#Try to find version
if(EXISTS "${CMAKE_SOURCE_DIR}/lckernel/build_constants.h")
file(READ "${CMAKE_SOURCE_DIR}/lckernel/build_constants.h" FILE_VERSION_H REGEX "^#define")
string(REGEX REPLACE ".*#define VERSION_MAJOR ([0-9]+).*" "\\1" VERSION_MAJOR ${FILE_VERSION_H})
string(REGEX REPLACE ".*#define VERSION_MINOR ([0-9]+).*" "\\1" VERSION_MINOR ${FILE_VERSION_H})
endif()
#Print infos about compilation
message("***** LibreCAD *****")
message("Version: ${VERSION_MAJOR}.${VERSION_MINOR}\n")
message("Options:")
message(" - Qt user interface: ${WITH_QT_UI}")
message(" - Lua command line interface: ${WITH_LUACMDINTERFACE}")
message(" - Unit tests: ${WITH_UNITTESTS}")
message(" - Rendering unit tests: ${WITH_RENDERING_UNITTESTS}")
message(" - Documentation: ${WITH_DOCUMENTATION}")
message(" - LibreCAD DXF/DWG support: ${WITH_LCDXFDWG}")
message(" - Use libopencad: ${WITH_LIBOPENCAD}")
message(" - Use Cairo: ${WITH_CAIRO}")
message("\n")
if(WITH_CAIRO)
add_definitions(-DWITH_CAIRO)
endif(WITH_QT_UI)
#Add each LibreCAD component
add_subdirectory("lckernel")
add_subdirectory("lcUILua")
add_subdirectory("lcadluascript")
if(WITH_PERSISTENCE)
add_subdirectory("persistence")
add_definitions(-DUSE_PERSISTENCE=1)
else()
add_definitions(-DUSE_PERSISTENCE=0)
endif()
add_subdirectory("lcviewernoqt")
if(WITH_QT_UI)
add_definitions(-DWITH_QTUI)
add_subdirectory("lcUI")
endif(WITH_QT_UI)
if(WITH_LUACMDINTERFACE)
add_subdirectory("luacmdinterface")
endif(WITH_LUACMDINTERFACE)
if(WITH_UNITTESTS)
set(CMAKE_EXPORT_COMPILE_COMMANDS OFF)
add_subdirectory("unittest")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()
# clang-tidy
find_file(
RUN_CLANG_TIDY_PY
NAMES
run-clang-tidy.py
HINTS
/usr/share/clang/
/usr/bin
DOC "Path to clang-tidy executable"
)
# Install all needed files in windows and set up some cpack variables
IF (WIN32)
#Cpack -> NSIS
#General Vars
set(CPACK_PACKAGE_NAME "LibreCAD3")
set(CPACK_PACKAGE_VENDOR "LibreCAD")
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "1")
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}) #name of the install folder
set(CPACK_PACKAGE_DESCRIPTION "LibreCAD is a free Open Source CAD application for Windows, Apple and Linux. Support and documentation are free from our large, dedicated community of users, contributors and developers.")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open Source 2D-CAD")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://librecad.org/")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
#NSIS Vars
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
set(CPACK_NSIS_MODIFY_PATH "ON")
set(CPACK_CREATE_DESKTOP_LINKS "ON")
set(CPACK_NSIS_DISPLAY_NAME ${CPACK_PACKAGE_NAME})
set(CPACK_NSIS_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
set(CPACK_NSIS_HELP_LINK "https://github.com/LibreCAD/LibreCAD_3")
set(CPACK_NSIS_URL_INFO_ABOUT ${CPACK_PACKAGE_HOMEPAGE_URL})
set(CPACK_NSIS_CONTACT "https://librecad.zulipchat.com/login/")
set(CPACK_NSIS_FINISH_TITLE "Thanks for installing LibreCAD 3")
#For the shortcut
set(CPACK_PACKAGE_EXECUTABLES
"librecad" "Librecad shortcut"
)
set(CPACK_CREATE_DESKTOP_LINKS
"librecad"
)
include(CPack)
install(
DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
DESTINATION ${CMAKE_INSTALL_BINDIR}/.. # Since we get the folder(bin) instead of the files, we must "paste" to the root install folder
PATTERN "*.pdb" EXCLUDE
PATTERN "*.exe" EXCLUDE
PATTERN "path.lua" EXCLUDE
)
install(
FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/librecad.exe
DESTINATION ${CMAKE_INSTALL_BINDIR} # install librecad in the bin folder of the installer
)
ENDIF()
install(FILES "${CMAKE_SOURCE_DIR}/path.lua"
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
#Get shaders and fonts
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/lcviewernoqt/painters/opengl/resources/shaders
DESTINATION ${CMAKE_INSTALL_BINDIR}/../resources
)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/lcviewernoqt/painters/opengl/resources/fonts
DESTINATION ${CMAKE_INSTALL_BINDIR}/../resources
)
include(InstallRequiredSystemLibraries)