-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCMakeLists.txt
192 lines (165 loc) · 5.99 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
# SPDX-License-Identifier: MPL-2.0
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
cmake_minimum_required(VERSION 3.16)
project(AUI)
# AUI_BUILD_AUI_ROOT intended for pulling resources by aui.build.cmake (cmake scripts, ios storyboards, etc...)
set(AUI_BUILD_AUI_ROOT ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "AUI src location" FORCE)
if(AUIB_COMPONENTS)
# adding required dependencies to the components
list(APPEND AUIB_COMPONENTS core)
if (views IN_LIST AUIB_COMPONENTS)
list(APPEND AUIB_COMPONENTS xml image)
if (NOT CMAKE_CROSSCOMPILING)
list(APPEND AUIB_COMPONENTS crypt toolbox)
endif()
elseif (toolbox IN_LIST AUIB_COMPONENTS AND NOT CMAKE_CROSSCOMPILING)
list(APPEND AUIB_COMPONENTS crypt)
endif()
if (curl IN_LIST AUIB_COMPONENTS)
list(APPEND AUIB_COMPONENTS crypt)
endif()
endif()
list(REMOVE_DUPLICATES AUIB_COMPONENTS)
include(aui.boot.cmake)
# use msvc dll
cmake_policy(SET CMP0091 NEW)
include(cmake/aui.build.cmake)
set(AUI_BUILD_EXAMPLES false CACHE BOOL "Build AUI examples")
auib_mark_var_forwardable(AUI_BUILD_EXAMPLES)
auib_mark_var_forwardable(AUI_IOS_CODE_SIGNING_REQUIRED)
function(define_aui_component AUI_COMPONENT_NAME)
if (AUIB_COMPONENTS)
if (NOT ${AUI_COMPONENT_NAME} IN_LIST AUIB_COMPONENTS)
return()
endif()
message(STATUS "[+] ${AUI_COMPONENT_NAME}")
endif()
add_subdirectory("aui.${AUI_COMPONENT_NAME}")
endfunction()
auib_import(ZLIB https://github.com/aui-framework/zlib)
# define all components
define_aui_component(core)
if (NOT CMAKE_CROSSCOMPILING)
define_aui_component(toolbox)
# define_aui_component(data) -- outdated; need reworking
define_aui_component(mysql)
# define_aui_component(data) -- outdated; need reworking
endif()
define_aui_component(network)
define_aui_component(crypt)
define_aui_component(curl)
define_aui_component(image)
define_aui_component(views)
define_aui_component(xml)
define_aui_component(json)
define_aui_component(audio)
if (NOT ANDROID AND NOT IOS)
define_aui_component(uitests)
endif()
if (AUI_BUILD_EXAMPLES)
add_subdirectory(examples/AUI.Example.Views)
#add_subdirectory(examples/AUI.Example.Fractal)
#add_subdirectory(examples/AUI.Example.Minesweeper)
endif()
if (NOT AUI_NO_TESTS)
if (AUI_BOOT)
# cleanup tests data when using aui thru aui.boot with add_subdirectory
set_property(GLOBAL PROPERTY TESTS_INCLUDE_DIRS "")
set_property(GLOBAL PROPERTY TESTS_SRCS "")
set_property(GLOBAL PROPERTY TESTS_DEPS "")
_aui_import_gtest()
endif()
endif()
# all components for exporting
set(AUI_ALL_COMPONENTS core
crypt
curl
data
image
json
mysql
network
sqlite
views
xml
uitests
toolbox
audio
)
if(NOT AUIB_COMPONENTS)
# adding all components
set(AUIB_COMPONENTS ${AUI_ALL_COMPONENTS})
# remove unexisting modules from module list (i.e. toolbox)
foreach(_module ${AUIB_COMPONENTS})
if (NOT TARGET "aui.${_module}")
list(REMOVE_ITEM AUIB_COMPONENTS ${_module})
endif()
endforeach()
else()
# remove executables from module list (i.e. toolbox)
foreach(_module ${AUIB_COMPONENTS})
if (NOT TARGET "aui.${_module}")
list(REMOVE_ITEM AUIB_COMPONENTS ${_module})
message(WARNING "aui.${_module} is either disabled or not exists")
continue()
endif()
get_target_property(_type "aui.${_module}" TYPE)
if (_type STREQUAL "EXECUTABLE")
list(REMOVE_ITEM AUIB_COMPONENTS ${_module})
endif()
endforeach()
endif()
set(AUI_CONFIG_VARS "set(AUI_ALL_COMPONENTS ${AUI_ALL_COMPONENTS})\nset(AUI_AVAILABLE_COMPONENTS ${AUIB_COMPONENTS})\n")
foreach(_module ${AUIB_COMPONENTS})
set(_target "aui.${_module}")
get_target_property(_compile_definitions ${_target} INTERFACE_COMPILE_DEFINITIONS)
get_target_property(_link_libs ${_target} INTERFACE_LINK_LIBRARIES)
get_target_property(_wholearchive ${_target} INTERFACE_AUI_WHOLEARCHIVE)
get_target_property(_link_options ${_target} INTERFACE_LINK_OPTIONS)
get_target_property(_kind ${_target} TYPE)
foreach (_kind_variant STATIC SHARED INTERFACE OBJECT)
if (_kind MATCHES "${_kind_variant}")
set(_kind ${_kind_variant})
break()
endif()
endforeach()
unset(_link_libs2)
foreach(_lib ${_link_libs})
if (_lib) # skips NOTFOUNDs
string(REPLACE "aui." "aui::" _lib ${_lib}) # use imported targets instead
string(REPLACE " " "\\ " _lib ${_lib}) # fixes -framework entries on macos
list(APPEND _link_libs2 ${_lib})
endif()
endforeach()
set(AUI_CONFIG_VARS "${AUI_CONFIG_VARS}\
set(AUI_COMPONENT_${_module}_COMPILE_DEFINITIONS ${_compile_definitions})
set(AUI_COMPONENT_${_module}_LINK_LIBS ${_link_libs2})
set(AUI_COMPONENT_${_module}_KIND ${_kind})
")
if (_link_options)
set(AUI_CONFIG_VARS "${AUI_CONFIG_VARS}\
set(AUI_COMPONENT_${_module}_LINK_OPTIONS ${_link_options})
")
endif()
if (_wholearchive)
set(AUI_CONFIG_VARS "${AUI_CONFIG_VARS}\
set(AUI_COMPONENT_${_module}_WHOLEARCHIVE ON)
")
endif()
endforeach()
auib_precompiled_binary()
# test aui.boot on ci/cd
add_subdirectory(test/)
configure_file(cmake/aui-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/aui-config.cmake @ONLY)
#install(EXPORT AUI DESTINATION cmake/)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/aui-config.cmake
DESTINATION ".")
install(DIRECTORY cmake/
DESTINATION cmake)
install(DIRECTORY platform/
DESTINATION platform)
enable_testing()