-
Notifications
You must be signed in to change notification settings - Fork 0
/
AuroraFWBuildConfig.cmake
577 lines (511 loc) · 20.6 KB
/
AuroraFWBuildConfig.cmake
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
# ┌─┐┬ ┬┬─┐┌─┐┬─┐┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┬ ┬┌─┐┬─┐┬┌─
# ├─┤│ │├┬┘│ │├┬┘├─┤ ├┤ ├┬┘├─┤│││├┤ ││││ │├┬┘├┴┐
# ┴ ┴└─┘┴└─└─┘┴└─┴ ┴ └ ┴└─┴ ┴┴ ┴└─┘└┴┘└─┘┴└─┴ ┴
# A Powerful General Purpose Framework
# More information in: https://aurora-fw.github.io/
#
# Copyright (C) 2017 Aurora Framework, All rights reserved.
#
# This file is part of the Aurora Framework. This framework is free
# software; you can redistribute it and/or modify it under the terms of
# the GNU Lesser General Public License version 3 as published by the
# Free Software Foundation and appearing in the file LICENSE included in
# the packaging of this file. Please review the following information to
# ensure the GNU Lesser General Public License version 3 requirements
# will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
###############################################################################
# PCHSupport_FOUND
# AURORAFW_PRECOMPILE_HEADERS
# AURORAFW_FORCE_STDLIB
# AURORAFW_FORCE_NO_STDLIB
# AURORAFW_STDLIB_CC
# AURORAFW_STDLIB_CXX
# AURORAFW_PCH
# ADD_PRECOMPILED_HEADER()
###############################################################################
if(NOT DEFINED AURORAFWBUILD_LOADED)
set(AURORAFWBUILD_LOADED true)
set(AURORAFW_BUILDCONFIG_VERSION_MAJOR )
###############################################################################
# Greetings
###############################################################################
if(NOT AURORAFWBUILD_QUITE_GREETINGS)
message(STATUS "Loading aurora framework build config...")
IF(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "Windows")
MESSAGE("[32m┌─┐┬[36m ┬┬─[34m┐┌─┐[35m┬─┐[32m┌─┐[0m ┌─┐┬─┐┌─┐┌┬┐┌─┐┬ ┬┌─┐┬─┐┬┌─")
MESSAGE("[36m├─┤│[34m │├┬[35m┘│ │[32m├┬┘[36m├─┤[0m ├┤ ├┬┘├─┤│││├┤ ││││ │├┬┘├┴┐")
MESSAGE("[34m┴ ┴└[35m─┘┴└[32m─└─┘[36m┴└─[34m┴ ┴[0m └ ┴└─┴ ┴┴ ┴└─┘└┴┘└─┘┴└─┴ ┴")
MESSAGE("A Powerful General Purpose Framework")
MESSAGE("More information in: https://aurora-fw.github.io/\n")
ENDIF()
ENDIF()
IF(AURORAFW_IS_BUILDING)
project(aurorafw)
message(STATUS "Starting framework build system...")
if (NOT CONFIGURED_ONCE)
#Aurora specific flags
SET(AURORAFW_ROOT_DIR ${CMAKE_SOURCE_DIR})
#SET(AURORAFW_BUILD_DIR ${AURORAFW_ROOT_DIR}/build)
endif()
option(AURORAFW_TARGET_DOCUMENTATION "Enable documentation target" OFF)
option(AURORAFW_DOCUMENTATION_AUTO "Enable automatic documentation building" OFF)
ENDIF()
###############################################################################
# Aurora build system option flags
###############################################################################
OPTION(AURORAFW_PRECOMPILE_HEADERS "Enable precompilation of headers" OFF)
OPTION(AURORAFW_FORCE_STDLIB "Force compilation with standard libraries" OFF)
OPTION(AURORAFW_FORCE_NO_STDLIB "Force compilation without standard libraries" OFF)
OPTION(AURORAFW_STDLIB_CC "Compile with C standard library" ON)
OPTION(AURORAFW_STDLIB_CXX "Compile with C++ standard template library" ON)
OPTION(AURORAFW_PCH "Enable experimental feature: Pre-compiled headers" OFF)
OPTION(AURORAFW_VERBOSE_CODE "Enable verbose instructions" OFF)
OPTION(AURORAFW_DLANG_WRAPPER "Enable D wrapper" OFF)
OPTION(AURORAFW_DLANG "Enable D native source compilation" OFF)
###############################################################################
# General Flags
###############################################################################
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release")
ENDIF()
IF(NOT CONFIGURED_ONCE)
IF(CMAKE_GENERATOR MATCHES "Ninja")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fdiagnostics-color")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fdiagnostics-color")
ENDIF()
#Add flag for AFW_EXPORT
IF(AURORAFW_FORCE_STDLIB)
add_definitions(-DAFW__FORCE_STDLIB)
ELSEIF(AURORAFW_FORCE_NO_STDLIB)
add_definitions(-nodefaultlibs -nostdlib -lgcc -DAFW__FORCE_NO_STDLIB)
ENDIF()
IF(AURORAFW_STDLIB_CXX)
add_definitions(-DAFW__FORCE_STDLIB_CXX)
else()
SET(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER})
add_definitions(-DAFW__FORCE_NO_STDLIB_CXX)
ENDIF()
IF(AURORAFW_STDLIB_CC)
add_definitions(-DAFW__FORCE_STDLIB_CC)
else()
add_definitions(-nodefaultlibs -nostdlib -lgcc -DAFW__FORCE_NO_STDLIB_CC)
ENDIF()
#C++ 17 Standard Revision
set_property(GLOBAL PROPERTY CXX_STANDARD 17)
set_property(GLOBAL PROPERTY CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -g3 -Wall -Wextra -Wformat -pedantic -Wdouble-promotion")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g0 -w -Wl,-rpath,\"\\$$ORIGIN:\\$$ORIGIN/lib\"")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
#Add custom flags to the CXX compiler
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++17")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++17")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
#Add custom flags to the CXX compiler
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++1z")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++1z")
ENDIF()
IF(AURORAFW_CODECOVERAGE)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -coverage -fprofile-arcs -ftest-coverage -fPIC -O0")
ENDIF()
if(AURORAFW_DLANG)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${AURORAFW_ROOT_DIR}/cmake/d/cmake-d")
project(aurorafw-d D)
set(CMAKE_D_FLAGS_DEBUG "${CMAKE_D_FLAGS_DEBUG} -wi")
set(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -color=on")
endif()
#Define output directory
IF(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DAFW__DEBUG)
if(AURORAFW_VERBOSE_CODE)
add_definitions(-DAFW__VERBOSE)
endif()
SET(LIBRARY_OUTPUT_PATH ${AURORAFW_ROOT_DIR}/bin/dbg)
SET(EXECUTABLE_OUTPUT_PATH ${AURORAFW_ROOT_DIR}/bin/dbg)
else()
SET(LIBRARY_OUTPUT_PATH ${AURORAFW_ROOT_DIR}/bin)
SET(EXECUTABLE_OUTPUT_PATH ${AURORAFW_ROOT_DIR}/bin)
ENDIF()
ENDIF()
MACRO(AURORAFW_ADD_CMAKE_MODULE _name_var _type)
string(REPLACE " " "_" ___tmp ${_name_var})
string(TOUPPER ${___tmp} _tmp)
string(TOLOWER ${_type} __tmp)
unset(___tmp)
set(_extra_args ${ARGN})
list(LENGTH _extra_args _num_extra_args)
if(${_num_extra_args} LESS 1)
string(REPLACE " " "/" ____tmp ${_name_var})
string(TOLOWER ${____tmp} ___tmp)
unset(____tmp)
set("AURORAFW_${_type}_${_tmp}_DIR" ${AURORAFW_ROOT_DIR}/${__tmp}s/${___tmp})
unset(___tmp)
else()
list(GET _extra_args 0 _path)
if(${_type} STREQUAL CMAKE)
set("${_type}_MODULE_${_tmp}_DIR" ${_path})
else()
set("AURORAFW_${_type}_${_tmp}_DIR" ${_path})
endif()
endif()
if(${_type} STREQUAL CMAKE)
include(${${_type}_MODULE_${_tmp}_DIR}/module.cmake)
else()
include(${AURORAFW_${_type}_${_tmp}_DIR}/${__tmp}.cmake)
endif()
unset(_tmp)
unset(__tmp)
ENDMACRO(AURORAFW_ADD_CMAKE_MODULE)
###############################################################################
# Precompiled Headers
###############################################################################
IF(CMAKE_COMPILER_IS_GNUCXX)
EXEC_PROGRAM(
${CMAKE_CXX_COMPILER}
ARGS --version
OUTPUT_VARIABLE _compiler_output)
STRING(REGEX REPLACE ".* ([0-9]\\.[0-9]\\.[0-9]) .*" "\\1"
gcc_compiler_version ${_compiler_output})
#MESSAGE("GCC Version: ${gcc_compiler_version}")
IF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
SET(PCHSupport_FOUND TRUE)
ELSE(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
IF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
SET(PCHSupport_FOUND TRUE)
ENDIF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
ENDIF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
MACRO(ADD_PRECOMPILED_HEADER _targetName _input )
IF(NOT CMAKE_BUILD_TYPE)
MESSAGE(FATAL_ERROR
"This is the ADD_PRECOMPILED_HEADER macro. "
"You must set CMAKE_BUILD_TYPE!"
)
ENDIF(NOT CMAKE_BUILD_TYPE)
foreach(_input_file ${_input})
GET_FILENAME_COMPONENT(_name ${_input_file} NAME)
GET_FILENAME_COMPONENT(_path ${_input_file} PATH)
get_filename_component(_result ${_path} ABSOLUTE)
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" _relative_path "${_path}")
SET(_outdir "${CMAKE_SOURCE_DIR}/CMakeFiles/${_targetName}.dir/pch/${_relative_path}")
SET(_output "${_outdir}/${_name}.gch")
list(APPEND _output_list ${_output})
string(CONCAT _output_list_include "-include ${_output} ")
MAKE_DIRECTORY(${_outdir})
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
SET(_compile_FLAGS ${${_flags_var_name}})
GET_DIRECTORY_PROPERTY(_directory_flags INCLUDE_DIRECTORIES)
SET(_CMAKE_CURRENT_BINARY_DIR_included_before_path FALSE)
FOREACH(item ${_directory_flags})
IF(${item} STREQUAL ${_path} AND NOT _CMAKE_CURRENT_BINARY_DIR_included_before_path )
MESSAGE(FATAL_ERROR
"This is the ADD_PRECOMPILED_HEADER macro. "
"CMAKE_CURREN_BINARY_DIR has to mentioned at INCLUDE_DIRECTORIES's argument list before ${_path}, where ${_name} is located"
)
ENDIF(${item} STREQUAL ${_path} AND NOT _CMAKE_CURRENT_BINARY_DIR_included_before_path )
IF(${item} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
SET(_CMAKE_CURRENT_BINARY_DIR_included_before_path TRUE)
ENDIF(${item} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
LIST(APPEND _compile_FLAGS "-I${item}")
ENDFOREACH(item)
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
LIST(APPEND _compile_FLAGS ${_directory_flags})
SEPARATE_ARGUMENTS(_compile_FLAGS)
#MESSAGE("_compiler_FLAGS: ${_compiler_FLAGS}")
#MESSAGE("COMMAND ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input_file}")
ADD_CUSTOM_COMMAND(
OUTPUT ${_output}
COMMAND ${CMAKE_CXX_COMPILER}
${_compile_FLAGS} -DAFW__PHC
-x c++-header
-o ${_output}
${_input_file}
DEPENDS ${_input_file} ${_outdir}
)
endforeach(_input_file)
ADD_CUSTOM_TARGET(${_targetName}_gch
DEPENDS ${_output_list}
)
ADD_DEPENDENCIES(${_targetName} ${_targetName}_gch )
SET_TARGET_PROPERTIES(${_targetName}
PROPERTIES
COMPILE_FLAGS "-I${CMAKE_SOURCE_DIR}/CMakeFiles/${_targetName}.dir/pch -Winvalid-pch"
)
ENDMACRO(ADD_PRECOMPILED_HEADER)
################################################################################
# Package finder
################################################################################
# Begin processing of package
MACRO(FINDPKG_BEGIN _PREFIX)
IF(NOT ${_PREFIX}_FIND_QUIETLY)
MESSAGE(STATUS "Looking for ${_PREFIX}...")
ENDIF()
ENDMACRO(FINDPKG_BEGIN)
# Display a status message unless FIND_QUIETLY is set
macro(pkg_message PREFIX)
if (NOT ${PREFIX}_FIND_QUIETLY)
message(STATUS ${ARGN})
endif ()
endmacro(pkg_message)
# Get environment variable, define it as ENV_$var and make sure backslashes are converted to forward slashes
macro(getenv_path VAR)
set(ENV_${VAR} $ENV{${VAR}})
# replace won't work if var is blank
if (ENV_${VAR})
string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
endif ()
endmacro(getenv_path)
# Construct search paths for includes and libraries from a PREFIX_PATH
macro(create_search_paths PREFIX)
foreach(dir ${${PREFIX}_PREFIX_PATH})
set(${PREFIX}_INC_SEARCH_PATH ${${PREFIX}_INC_SEARCH_PATH}
${dir}/include ${dir}/Include ${dir}/include/${PREFIX} ${dir}/Headers)
set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH}
${dir}/lib ${dir}/Lib ${dir}/lib/${PREFIX} ${dir}/Libs)
set(${PREFIX}_BIN_SEARCH_PATH ${${PREFIX}_BIN_SEARCH_PATH}
${dir}/bin)
endforeach(dir)
if(ANDROID)
set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH} lib/${ANDROID_ABI})
endif()
set(${PREFIX}_FRAMEWORK_SEARCH_PATH ${${PREFIX}_PREFIX_PATH})
endmacro(create_search_paths)
macro(aurorafw_add_target _target)
#target_compile_options(${_target} PUBLIC -nodefaultlibs -nostdlib -lgcc)
endmacro(aurorafw_add_target)
macro(aurorafw_add_library_target _target _type)
if(_type MATCHES SHARED)
aurorafw_add_target(${_target})
target_compile_definitions(${_target} PUBLIC -DAFW__COMPILING)
target_compile_options(${_target} PUBLIC -fPIC)
IF(CMAKE_BUILD_TYPE MATCHES Debug)
set_target_properties(${_target} PROPERTIES OUTPUT_NAME "${_target}_dev")
endif()
install(TARGETS ${_target} DESTINATION lib)
elseif(_type MATCHES STATIC)
endif()
endmacro(aurorafw_add_library_target)
macro(aurorafw_add_executable_target _target)
aurorafw_add_target(${_target})
#target_compile_definitions(${_target} PUBLIC -DAFW__COMPILING)
#target_compile_options(${_target} PUBLIC -Wl,-rpath,"\$ORIGIN")
endmacro(aurorafw_add_executable_target)
macro(aurorafw_print_debug_vars)
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
endmacro(aurorafw_print_debug_vars)
# clear cache variables if a certain variable changed
macro(clear_if_changed TESTVAR)
# test against internal check variable
# HACK: Apparently, adding a variable to the cache cleans up the list
# a bit. We need to also remove any empty strings from the list, but
# at the same time ensure that we are actually dealing with a list.
list(APPEND ${TESTVAR} "")
list(REMOVE_ITEM ${TESTVAR} "")
if (NOT "${${TESTVAR}}" STREQUAL "${${TESTVAR}_INT_CHECK}")
message(STATUS "${TESTVAR} changed.")
foreach(var ${ARGN})
set(${var} "NOTFOUND" CACHE STRING "x" FORCE)
endforeach(var)
endif ()
set(${TESTVAR}_INT_CHECK ${${TESTVAR}} CACHE INTERNAL "x" FORCE)
endmacro(clear_if_changed)
# Try to get some hints from pkg-config, if available
macro(use_pkgconfig PREFIX PKGNAME)
if(NOT ANDROID)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(${PREFIX} ${PKGNAME})
endif ()
endif()
endmacro (use_pkgconfig)
# Couple a set of release AND debug libraries (or frameworks)
macro(make_library_set PREFIX)
if (${PREFIX}_FWK)
set(${PREFIX} ${${PREFIX}_FWK})
elseif (${PREFIX}_REL AND ${PREFIX}_DBG)
set(${PREFIX} optimized ${${PREFIX}_REL} debug ${${PREFIX}_DBG})
elseif (${PREFIX}_REL)
set(${PREFIX} ${${PREFIX}_REL})
elseif (${PREFIX}_DBG)
set(${PREFIX} ${${PREFIX}_DBG})
endif ()
endmacro(make_library_set)
# Generate debug names from given release names
macro(get_debug_names PREFIX)
foreach(i ${${PREFIX}})
set(${PREFIX}_DBG ${${PREFIX}_DBG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug)
endforeach(i)
endmacro(get_debug_names)
# Add the parent dir from DIR to VAR
macro(add_parent_dir VAR DIR)
get_filename_component(${DIR}_TEMP "${${DIR}}/.." ABSOLUTE)
set(${VAR} ${${VAR}} ${${DIR}_TEMP})
endmacro(add_parent_dir)
# Do the final processing for the package find.
macro(FINDPKG_FINISH PREFIX)
# skip if already processed during this run
if (NOT ${PREFIX}_FOUND)
if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
set(${PREFIX}_FOUND TRUE)
set(${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
set(${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
if (NOT ${PREFIX}_FIND_QUIETLY)
message(STATUS "Found ${PREFIX}: ${${PREFIX}_LIBRARIES}")
endif ()
else ()
if (NOT ${PREFIX}_FIND_QUIETLY)
message(STATUS "Could not locate ${PREFIX}")
endif ()
if (${PREFIX}_FIND_REQUIRED)
message(FATAL_ERROR "Required library ${PREFIX} not found! Install the library (including dev packages) and try again. If the library is already installed, set the missing variables manually in cmake.")
endif ()
endif ()
mark_as_advanced(${PREFIX}_INCLUDE_DIR ${PREFIX}_LIBRARY ${PREFIX}_LIBRARY_REL ${PREFIX}_LIBRARY_DBG ${PREFIX}_LIBRARY_FWK)
endif ()
endmacro(FINDPKG_FINISH)
# Slightly customised framework finder
macro(findpkg_framework fwk)
if(APPLE)
set(${fwk}_FRAMEWORK_PATH
${${fwk}_FRAMEWORK_SEARCH_PATH}
${CMAKE_FRAMEWORK_PATH}
~/Library/Frameworks
/Library/Frameworks
/System/Library/Frameworks
/Network/Library/Frameworks
${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/Release
${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/Debug
)
# These could be arrays of paths, add each individually to the search paths
foreach(i ${PREFIX_PATH})
set(${fwk}_FRAMEWORK_PATH ${${fwk}_FRAMEWORK_PATH} ${i}/lib/macosx/Release ${i}/lib/macosx/Debug)
endforeach(i)
foreach(i ${PREFIX_BUILD})
set(${fwk}_FRAMEWORK_PATH ${${fwk}_FRAMEWORK_PATH} ${i}/lib/macosx/Release ${i}/lib/macosx/Debug)
endforeach(i)
foreach(dir ${${fwk}_FRAMEWORK_PATH})
set(fwkpath ${dir}/${fwk}.framework)
if(EXISTS ${fwkpath})
set(${fwk}_FRAMEWORK_INCLUDES ${${fwk}_FRAMEWORK_INCLUDES}
${fwkpath}/Headers ${fwkpath}/PrivateHeaders)
set(${fwk}_FRAMEWORK_PATH ${dir})
if (NOT ${fwk}_LIBRARY_FWK)
set(${fwk}_LIBRARY_FWK "-framework ${fwk}")
endif ()
endif(EXISTS ${fwkpath})
endforeach(dir)
endif(APPLE)
endmacro(findpkg_framework)
##################################################################
# Available platform targets (AURORAFW_PLATFORM_TARGET):
# - linux
# - win
# - android
# - default (auto detection)
# Available compilers (AURORAFW_COMPILER_TARGET):
# - gcc
# - clang
# - mingw
# - default (auto detection)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(AURORAFW_LIBRARY_EXT "so")
endif()
IF(AURORAFW_PLATFORM_TARGET MATCHES "linux")
IF(AURORAFW_COMPILER_TARGET MATCHES "gcc")
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
SET(CMAKE_C_COMPILER "/usr/bin/gcc")
SET(CMAKE_CXX_COMPILER "/usr/bin/g++")
ENDIF()
ELSEIF(AURORAFW_COMPILER_TARGET MATCHES "clang")
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
SET(CMAKE_C_COMPILER "/usr/bin/clang")
SET(CMAKE_CXX_COMPILER "/usr/bin/clang++")
SET(CMAKE_AR "/usr/bin/llvm-ar")
SET(CMAKE_LINKER "/usr/bin/llvm-ld")
SET(CMAKE_NM "/usr/bin/llvm-nm")
SET(CMAKE_OBJDUMP "/usr/bin/llvm-objdump")
SET(CMAKE_RANLIB "/usr/bin/llvm-ranlib")
SET(CMAKE_C_FLAGS_INIT "-Wall -std=c99")
SET(CMAKE_C_FLAGS_DEBUG_INIT "-g")
SET(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
SET(CMAKE_C_FLAGS_RELEASE_INIT "-O4 -DNDEBUG")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g")
SET(CMAKE_CXX_FLAGS_INIT "-Wall")
SET(CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
SET(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
SET(CMAKE_CXX_FLAGS_RELEASE_INIT "-O4 -DNDEBUG")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g")
ENDIF()
ENDIF()
SET(AURORAFW_PLATFORM_PREFIX "linux")
ELSEIF(AURORAFW_PLATFORM_TARGET MATCHES "win" OR AURORAFW_PLATFORM_TARGET MATCHES "windows")
IF(AURORAFW_COMPILER_TARGET MATCHES "mingw")
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
IF(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
SET(CMAKE_C_COMPILER "/usr/bin/x86_64-w64-mingw32-gcc")
SET(CMAKE_CXX_COMPILER "/usr/bin/x86_64-w64-mingw32-g++")
ELSEIF(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i686")
SET(CMAKE_C_COMPILER "/usr/bin/i686-w64-mingw32-gcc")
SET(CMAKE_CXX_COMPILER "/usr/bin/i686-w64-mingw32-g++")
ENDIF()
ENDIF()
ENDIF()
SET(AURORAFW_PLATFORM_PREFIX "win")
ELSE()
SET(AURORAFW_PLATFORM_TARGET "default")
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
SET(AURORAFW_PLATFORM_PREFIX "linux")
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Windows")
SET(AURORAFW_PLATFORM_PREFIX "win")
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
SET(AURORAFW_PLATFORM_PREFIX "darwin")
ELSE()
SET(AURORAFW_PLATFORM_PREFIX "unknown")
ENDIF()
ENDIF()
# Available CPU Architecture targets (AURORAFW_CPUARCH_TARGET):
# - x86_64
# - x86
# - arm
# - aarch64
# - default (auto detection)
IF(AURORAFW_CPUARCH_TARGET MATCHES "x86_64")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
IF(CMAKE_C_COMPILER MATCHES "/usr/bin/i686-w64-mingw32-gcc" OR CMAKE_CXX_COMPILER STREQUAL "/usr/bin/i686-w64-mingw32-g++")
SET(CMAKE_C_COMPILER "/usr/bin/x86_64-w64-mingw32-gcc")
SET(CMAKE_CXX_COMPILER "/usr/bin/x86_64-w64-mingw32-g++")
ENDIF()
SET(AURORAFW_CPUARCH_PREFIX "x86_64")
ELSEIF(AURORAFW_CPUARCH_TARGET MATCHES "x86")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
IF(CMAKE_C_COMPILER MATCHES "/usr/bin/x86_64-w64-mingw32-gcc" OR CMAKE_CXX_COMPILER STREQUAL "/usr/bin/x86_64-w64-mingw32-g++")
SET(CMAKE_C_COMPILER "/usr/bin/i686-w64-mingw32-gcc")
SET(CMAKE_CXX_COMPILER "/usr/bin/i686-w64-mingw32-g++")
ENDIF()
SET(AURORAFW_CPUARCH_PREFIX "x86")
ELSEIF(AURORAFW_CPUARCH_TARGET MATCHES "arm")
IF(AURORAFW_COMPILER_TARGET MATCHES "gcc" OR AURORAFW_COMPILER_TARGET MATCHES "default")
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
SET(CMAKE_C_COMPILER "/usr/bin/arm-none-eabi-gcc")
SET(CMAKE_C_COMPILER "/usr/bin/arm-none-eabi-g++")
ENDIF()
ENDIF()
SET(AURORAFW_CPUARCH_PREFIX "arm")
ELSEIF(AURORAFW_CPUARCH_TARGET MATCHES "aarch64")
IF(AURORAFW_COMPILER_TARGET MATCHES "gcc" OR AURORAFW_COMPILER_TARGET MATCHES "default")
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
SET(CMAKE_C_COMPILER "/usr/bin/aarch64-linux-gnu-gcc")
SET(CMAKE_C_COMPILER "/usr/bin/aarch64-linux-gnu-g++")
ENDIF()
ENDIF()
SET(AURORAFW_CPUARCH_PREFIX "aarch64")
ELSE()
SET(AURORAFW_CPUARCH_TARGET "default")
SET(AURORAFW_CPUARCH_PREFIX ${CMAKE_HOST_SYSTEM_PROCESSOR})
ENDIF()
endif(NOT DEFINED AURORAFWBUILD_LOADED)