-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
203 lines (174 loc) · 6.16 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
cmake_minimum_required(VERSION 3.10)
project(AeonGUI CXX C)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
cmake_policy(SET CMP0072 NEW)
endif(COMMAND cmake_policy)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON
CACHE INTERNAL "Force compilation database")
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
include(CheckIncludeFiles)
include(vscode)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL)
find_package(Git)
find_program(BASH_EXECUTABLE bash HINTS ENV MINGW_PREFIX MSYS2_PATH)
find_program(SED_EXECUTABLE sed
HINTS ENV
MINGW_PREFIX
MSYS2_PATH
ProgramFiles
PATH_SUFFIXES bin usr/bin Git/usr/bin)
find_program(GREP_EXECUTABLE grep
HINTS ENV
MINGW_PREFIX
MSYS2_PATH
ProgramFiles
PATH_SUFFIXES usr/bin Git/usr/bin)
if(WIN32)
find_program(ASTYLE_EXECUTABLE astyle
HINTS ENV ProgramData
PATH_SUFFIXES /usr/bin chocolatey/bin)
find_program(FIND_EXECUTABLE find
HINTS ENV ProgramFiles
PATH_SUFFIXES /usr/bin Git/usr/bin)
else()
find_program(FIND_EXECUTABLE find)
find_program(ASTYLE_EXECUTABLE astyle)
endif()
set(ASTYLE_OPTIONS "--options=${CMAKE_SOURCE_DIR}/astylerc")
configure_file("${CMAKE_SOURCE_DIR}/cmake/pre-commit.in"
"${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit")
find_program(XXD_EXECUTABLE xxd HINTS ENV ProgramData PATH_SUFFIXES /usr/bin chocolatey/bin)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
option(USE_ZLIB "Use the zlib compression library")
option(USE_PNG "Enable PNG image support (Requires zlib)")
option(USE_CUDA "Enable CUDA support")
option(BUILD_UNIT_TESTS "Enable Unit Tests using GTest/GMock")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "One of Debug|Release|RelWithDebInfo|MinSizeRel")
set(HTTP_PROXY "" CACHE STRING "Specify a proxy server if required for downloads")
set(HTTPS_PROXY "" CACHE STRING "Specify a proxy server if required for downloads")
if(NOT "${HTTP_PROXY}" STREQUAL "")
set(ENV{http_proxy} "${HTTP_PROXY}")
endif()
if(NOT "${HTTPS_PROXY}" STREQUAL "")
set(ENV{https_proxy} "${HTTPS_PROXY}")
endif()
set(CMAKE_DEBUG_POSTFIX "d")
if(USE_CUDA)
message(STATUS "Looking for CUDA toolkit")
find_package(CUDA)
add_definitions(-DUSE_CUDA)
endif(USE_CUDA)
if(USE_ZLIB)
find_package(zlib)
endif(USE_ZLIB)
if(USE_PNG)
find_package(libpng)
endif(USE_PNG)
# Install pkgconf from vcpkg on MSVC if the following does not work on Visual Studio Builds
# vcpkg.exe --triplet=x64-windows install pkgconf
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
if(BASH_EXECUTABLE AND MSYS)
# In order to properly use pkg-config in a msys2 environment we need to jump
# through some hoops. CMake seems to call pkg-config without any of the bash
# environment set up, so we need to set the proper pkg config path inside the
# cmake process address space.
execute_process(COMMAND ${BASH_EXECUTABLE} --login -c "echo $PKG_CONFIG_PATH"
OUTPUT_VARIABLE PKG_CONFIG_PATH)
set(ENV{PKG_CONFIG_PATH} ${PKG_CONFIG_PATH})
elseif(MSVC AND VCPKG_INSTALLED_DIR AND VCPKG_TARGET_TRIPLET)
set(ENV{PKG_CONFIG_PATH} ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/pkgconfig)
endif()
pkg_check_modules(CAIRO cairo)
endif()
find_package(Freetype)
if(FREETYPE_FOUND)
include_directories(${FREETYPE_INCLUDE_DIRS})
endif()
find_package(LibXml2)
if(LIBXML2_FOUND)
include_directories(${LIBXML2_INCLUDE_DIR})
endif()
find_package(X11)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors -Wall -Drestrict=__restrict__")
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -fomit-frame-pointer -O3")
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g -O0")
elseif(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SUPPRESS_RESTRICT -Drestrict=__restrict")
endif(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_COMPILER_IS_GNUC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -fomit-frame-pointer -O3")
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g -O0")
endif(CMAKE_COMPILER_IS_GNUC)
# TODO: Set _ALIGNED to the proper attribute if/when required
add_definitions(-D_USE_MATH_DEFINES -D_ALIGNED=)
if(BUILD_UNIT_TESTS)
add_subdirectory(tests)
endif()
function(fix_compile_commands target)
if(SED_EXECUTABLE)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${SED_EXECUTABLE} -i 's/\\/\\\(.\\\)\\//\\1:\\//g' ${CMAKE_BINARY_DIR}/compile_commands.json
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Fixing compilation Database."
)
endif()
endfunction()
if(SED_EXECUTABLE AND MINGW)
add_custom_target(fix_compile_commands ALL
COMMAND ${SED_EXECUTABLE} -i 's/\\/\\\(.\\\)\\//\\1:\\//g' ${CMAKE_BINARY_DIR}/compile_commands.json
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Fixing compilation Database."
)
endif()
include(parser)
include_directories(include common demos/common core)
add_subdirectory(css)
add_subdirectory(core)
add_subdirectory(demos/OpenGL)
install(TARGETS AeonGUI
EXPORT aeongui
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
)
install(
FILES
include/aeongui/AeonGUI.h
include/aeongui/AABB.h
include/aeongui/AttributeMap.h
include/aeongui/Attribute.hpp
include/aeongui/Window.h
include/aeongui/Document.h
include/aeongui/Platform.h
include/aeongui/Canvas.h
include/aeongui/CairoCanvas.h
include/aeongui/DrawType.h
include/aeongui/Color.h
include/aeongui/Vector2.h
include/aeongui/Element.h
include/aeongui/Transform.h
include/aeongui/Matrix2x3.h
DESTINATION include/aeongui
)
install(
EXPORT aeongui
DESTINATION share/aeongui
FILE aeongui-config.cmake
)
file(INSTALL LICENSE DESTINATION share/aeongui RENAME copyright)