forked from LibreCAD/LibreCAD_3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
157 lines (122 loc) · 4.63 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
cmake_minimum_required(VERSION 3.6)
project(LC)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(WITH_QT_UI "With QT user interface" ON)
option(WITH_LUACMDINTERFACE "Build Lua command line interface" ON)
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 "${CMAKE_INSTALL_PREFIX}")
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)
# settings path
set(SETTINGS_PATH "${PROJECT_BINARY_DIR}/bin")
# 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"
)