ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
ALib.cmake
1# #################################################################################################
2# ALib.cmake - CMake file for projects using ALib
3#
4# Copyright 2015-2024 A-Worx GmbH, Germany
5# Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6#
7# \file
8# CMake file for projects using ALib
9# #################################################################################################
10
11# --------------------------------------------------------------------------------------------------
12# checks
13# --------------------------------------------------------------------------------------------------
14 cmake_minimum_required( VERSION 3.20.0 )
15
16 # check
17 if (tmp_alib_included_marker)
18 message( FATAL_ERROR "ALib.cmake: Already included (included twice!)" )
19 return()
20 endif()
21 set(tmp_alib_included_marker "1")
22
23
24 # Infer base directory from this script's location
25 if( NOT DEFINED ALIB_BASE_DIR )
26 set( temp "${CMAKE_CURRENT_LIST_DIR}/../.." )
27 get_filename_component(temp ${temp} ABSOLUTE)
28 set( ALIB_BASE_DIR ${temp} CACHE PATH
29 "The base path to ALib containing source code, project files, tools, docs, etc.")
30 endif()
31
32
33 # check
34 if (NOT EXISTS "${ALIB_BASE_DIR}/src/alib" )
35 message( FATAL_ERROR "ALib.cmake: Can't read sources in ALIB_BASE_DIR= ${ALIB_BASE_DIR}" )
36 return()
37 endif()
38
39
40 # build type defaults to "Debug"
41 if ( "${CMAKE_BUILD_TYPE}" STREQUAL "" )
42 set( CMAKE_BUILD_TYPE "Debug" )
43 endif()
44
45 MESSAGE( STATUS "Build type: ${CMAKE_BUILD_TYPE}" )
46
47
48 # include tool functions
49 include( ${CMAKE_CURRENT_LIST_DIR}/ALibTools.cmake )
50
51# --------------------------------------------------------------------------------------------------
52# ALib Module Dependency Resolution
53# --------------------------------------------------------------------------------------------------
54
55 include( ${CMAKE_CURRENT_LIST_DIR}/ALibModules.cmake )
56
57# --------------------------------------------------------------------------------------------------
58# ALib Cache Variables
59# The variables are only set, if not already predefined prior to invoking this script.
60# --------------------------------------------------------------------------------------------------
61
62set( ALIB_VERSION "2412R0" CACHE STRING
63 "The ALib version. Not modifiable (will be overwritten on generation!)" FORCE )
64
65set( ALIB_VERSION_NO "2412" )
66set( ALIB_VERSION_REV "0" )
67
68if( NOT DEFINED ALIB_DEBUG )
69 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
70 set( defaultALIB_DEBUG "On" )
71 else()
72 set( defaultALIB_DEBUG "Off" )
73 endif()
74else()
75 set( defaultALIB_DEBUG ALIB_DEBUG )
76endif()
77
78set( ALIB_DEBUG ${defaultALIB_DEBUG} CACHE BOOL
79 "Enable/disable ALib debug code. Defaults to true with debug builds, otherwise to false." )
80
81
82if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
83 if( NOT DEFINED ALIB_DEBUG_GLIB )
84 set( ALIB_DEBUG_GLIB "Off" CACHE BOOL
85 "Defaults to false. If true, compiler symbols '_GLIBCXX_DEBUG', '_GLIBCXX_DEBUG_PEDANTIC' and '_GLIBCPP_CONCEPT_CHECKS' are set." )
86 endif()
87
88
89 if( NOT DEFINED ALIB_COVERAGE_COMPILE )
90 set( ALIB_COVERAGE_COMPILE "Off" CACHE BOOL
91 "Defaults to false. If true, option --coverage is added to GNU compiler command line.")
92 endif()
93
94 if ( $ENV{CLION_IDE} )
95 set( tmpDefault "On" )
96 else()
97 set( tmpDefault "Off" )
98 endif()
99
100 set( ALIB_GDB_PP_SUPPRESS_CHILDREN ${tmpDefault} CACHE BOOL
101 "Defaults to false except if CMake is run from within JetBrains CLion. If true, a corresponding symbol gets set with debug builds which is detected by GDB pretty printer scripts provided with ALib.")
102
103 set( ALIB_GDB_PP_FIND_POINTER_TYPES ${tmpDefault} CACHE BOOL
104 "Defaults to false. If true, a corresponding symbol gets set with debug builds which is detected by GDB pretty printer scripts provided with ALib.")
105endif()
106
107if( NOT DEFINED ALIB_PRECOMPILED_HEADER )
108 set( ALIB_PRECOMPILED_HEADER "Off" CACHE BOOL
109 "If on, header file ’alib/alib_precompile.hpp' will included some default headers, depending on the selected modules. Defaults to off." )
110endif()
111
112
113if( NOT DEFINED ALIB_CMAKE_SKIP_THREAD_LIB_SEARCH )
114 set( ALIB_CMAKE_SKIP_THREAD_LIB_SEARCH "Off" CACHE BOOL
115 "If true, no thread library is searched and bound to the target. If false, a thread library is searched and bound even if module Threads is not included. This is to allow debug assertions with multi-threaded use of a single-threaded ALib distribution." )
116endif()
117
118
119if( NOT DEFINED ALIB_CMAKE_VERBOSE )
120 set( ALIB_CMAKE_VERBOSE "Off" CACHE BOOL
121 "If true, CMake generation runs will provide a detailed report." )
122endif()
123
124
125if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
126 if( NOT DEFINED ALIB_DEBUG_ALLOCATIONS )
127 set( ALIB_DEBUG_ALLOCATIONS "Off" CACHE BOOL
128 "Adds allocation debug mechanics with lang::HeapAllocator and ALib Monomem allocators. Defaults to false." )
129 endif()
130endif()
131
132
133if( "SINGLETONS" IN_LIST ALIB_DISTRIBUTION )
134 if ( ${WIN32} )
135 set( platformDefaultFor_SINGLETON_MAPPED "On" )
136 else()
137 set( platformDefaultFor_SINGLETON_MAPPED "Off" )
138 endif()
139 if( NOT DEFINED ALIB_FEAT_SINGLETON_MAPPED )
140 set( ALIB_FEAT_SINGLETON_MAPPED ${platformDefaultFor_SINGLETON_MAPPED} CACHE BOOL
141 "Defaults to true on Windows OS, which then selects code to implement class Singleton to work with multiple data segments, as imposed by the use of Windows DLLs.")
142 endif()
143endif()
144
145if( "BITBUFFER" IN_LIST ALIB_DISTRIBUTION )
146 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
147 if( NOT DEFINED ALIB_DEBUG_ARRAY_COMPRESSION )
148 set( ALIB_DEBUG_ARRAY_COMPRESSION "On" CACHE BOOL
149 "If true, in debug compilations, compressed arrays are read back to check if result is same. Defaults to true." )
150 endif()
151 endif()
152endif()
153
154if( "CONTAINERS" IN_LIST ALIB_DISTRIBUTION )
155 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
156 if( NOT DEFINED ALIB_DEBUG_CONTAINERS )
157 set( ALIB_DEBUG_CONTAINERS "Off" CACHE BOOL
158 "Adds debug features to module ALib Containers. Defaults to false." )
159 endif()
160 endif()
161endif()
162
163if( "MONOMEM" IN_LIST ALIB_DISTRIBUTION )
164 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
165 if( NOT DEFINED ALIB_DEBUG_MONOMEM )
166 set( ALIB_DEBUG_MONOMEM "Off" CACHE BOOL
167 "Adds consistency checks and collection of statistics with module ALib Monomem. Defaults to false." )
168 endif()
169 endif()
170endif()
171
172
173if( "BOXING" IN_LIST ALIB_DISTRIBUTION )
174 if( NOT DEFINED ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS )
175 set( ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS "Off" CACHE BOOL
176 "If true, any C++ integral type will be boxed to its original type. If false (the default) all types are boxed to type 'integer', respectively / 'uinteger' and only this can be unboxed.")
177 endif()
178
179 if( NOT DEFINED ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS )
180 set( ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS "Off" CACHE BOOL
181 "If true, any C++ character type will be boxed to its original type. If false (the default) all types are boxed to type 'character' and only this can be unboxed.")
182 endif()
183
184 if( NOT DEFINED ALIB_FEAT_BOXING_BIJECTIVE_FLOATS )
185 set( ALIB_FEAT_BOXING_BIJECTIVE_FLOATS "Off" CACHE BOOL
186 "If true, type float will be boxed as float. If false (the default) float will be boxed as double and cannot be unboxed.")
187 endif()
188
189 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
190 if( NOT DEFINED ALIB_DEBUG_BOXING )
191 set( ALIB_DEBUG_BOXING "Off" CACHE BOOL
192 "Adds collection of statistics and debug methods to module ALib Boxing. Defaults to false." )
193 endif()
194 endif()
195endif()
196
197if( "CHARACTERS" IN_LIST ALIB_DISTRIBUTION )
198 if ( ${WIN32} )
199 set( defaultALIB_CHARACTERS_WIDE "On" )
200 set( defaultALIB_CHARACTERS_SIZEOF_WCHAR "2" )
201 else()
202 set( defaultALIB_CHARACTERS_WIDE "Off" )
203 set( defaultALIB_CHARACTERS_SIZEOF_WCHAR "4" )
204 endif()
205
206 if( NOT DEFINED ALIB_CHARACTERS_WIDE )
207 set( ALIB_CHARACTERS_WIDE ${defaultALIB_CHARACTERS_WIDE} CACHE BOOL
208 "If false, the type 'alib::character' is 1-byte wide, otherwise it has the width given with ALIB_CHARACTERS_SIZEOF_WCHAR. Default value depends on platform preference.")
209 endif()
210
211 if( NOT DEFINED ALIB_CHARACTERS_SIZEOF_WCHAR )
212 set( ALIB_CHARACTERS_SIZEOF_WCHAR ${defaultALIB_CHARACTERS_SIZEOF_WCHAR} CACHE STRING
213 "The width of wide characters, maybe 2 or 4. Default value depends on platform/compiler preference.")
214 endif()
215endif()
216
217if( "STRINGS" IN_LIST ALIB_DISTRIBUTION )
218 if( NOT DEFINED ALIB_FEAT_BOOST_REGEX )
219 set( ALIB_FEAT_BOOST_REGEX "Off" CACHE BOOL
220 "Defaults to false. If true, activates ALib classes that use boost regular expressions, for example strings::util::RegexMatcher. The corresponding boost library is searched and added to CMake variable ALIB_EXTERNAL_LIBS.")
221 endif()
222
223 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
224 if( NOT DEFINED ALIB_DEBUG_STRINGS )
225 set( ALIB_DEBUG_STRINGS "Off" CACHE BOOL
226 "Defaults to false. Adds consistency checks to ALib string classes. Useful when developing code to manipulate strings externally, i.e T_Append to specializations.")
227 endif()
228 endif()
229endif()
230
231if( "THREADS" IN_LIST ALIB_DISTRIBUTION )
232 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
233 if( NOT DEFINED ALIB_DEBUG_CRITICAL_SECTIONS )
234 set( ALIB_DEBUG_CRITICAL_SECTIONS "Off" CACHE BOOL
235 "Defaults to true. Activates lang::DbgCriticalSections with debug compilations.")
236 endif()
237 endif()
238endif()
239
240
241if( "CAMP" IN_LIST ALIB_DISTRIBUTION )
242 if( NOT DEFINED ALIB_RESOURCES_OMIT_DEFAULTS )
243 set( ALIB_RESOURCES_OMIT_DEFAULTS "Off" CACHE BOOL
244 "If true, ALib modules do not add default versions of resource strings. See section 'Bootstrapping' of ALib Programmer's Manual for more information. Defaults to false.")
245 endif()
246
247 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
248 if( NOT DEFINED ALIB_DEBUG_RESOURCES )
249 set( ALIB_DEBUG_RESOURCES "Off" CACHE BOOL
250 "Adds collection of statistics and resource export with module ALib Resources. Defaults to false." )
251 endif()
252 endif()
253
254endif()
255
256if( "FILES" IN_LIST ALIB_DISTRIBUTION )
257 if( NOT DEFINED ALIB_FILES_FORCE_STD_SCANNER )
258 set( ALIB_FILES_FORCE_STD_SCANNER "Off" CACHE BOOL
259 "If true, file scanning of ALib camp 'Files' falls back to a basic implementation using C++ library std::filesystem.")
260 endif()
261endif()
262
263if( "ALOX" IN_LIST ALIB_DISTRIBUTION )
264
265 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
266 set( defaultALOX_DBG_LOG "On" )
267 else()
268 set( defaultALOX_DBG_LOG "Off" )
269 endif()
270 if( NOT DEFINED ALOX_DBG_LOG )
271 set( ALOX_DBG_LOG ${defaultALOX_DBG_LOG} CACHE BOOL
272 "Enable/disable debug log statements. Defaults to true with debug builds, otherwise to false." )
273 endif()
274
275 if( NOT DEFINED ALOX_DBG_LOG_CI )
276 set( ALOX_DBG_LOG_CI "On" CACHE BOOL
277 "Defaults to true. If set, caller information is used with debug log statements." )
278 endif()
279
280 if( NOT DEFINED ALOX_REL_LOG )
281 set( ALOX_REL_LOG "On" CACHE BOOL
282 "Enable/disable release log statements. Defaults to true." )
283 endif()
284
285 if( NOT DEFINED ALOX_REL_LOG_CI )
286 set( ALOX_REL_LOG_CI "Off" CACHE BOOL
287 "Defaults to false. If set, caller information is used even with release log statements (and even in release builds!)" )
288 endif()
289endif()
290
291# --------------------------------------------------------------------------------------------------
292# Compiler symbols
293# --------------------------------------------------------------------------------------------------
294
295# module selection
296if( NOT allModules )
297 SET( moduleList "" )
298 LIST( APPEND moduleList "EXPRESSIONS;CLI;ALOX" )
299 LIST( APPEND moduleList "CONFIGURATION;CAMP;CONTAINERS" )
300 LIST( APPEND moduleList "THREADS;THREADMODEL;FILES" )
301 LIST( APPEND moduleList "ENUMS;BOXING;STRINGS" )
302 LIST( APPEND moduleList "SINGLETONS;MONOMEM;BITBUFFER;CHARACTERS;TIME" )
303 FOREACH( module IN LISTS moduleList )
304 IF( module IN_LIST ALIB_DISTRIBUTION )
305 list( APPEND ALIB_SYMBOLS "ALIB_${module}" )
306 ENDIF()
307 ENDFOREACH()
308endif()
309
310# debug
311if ( ${ALIB_DEBUG} )
312 list( APPEND ALIB_SYMBOLS "ALIB_DEBUG" )
313
314 if ( ${ALIB_DEBUG_GLIB} )
315 list( APPEND ALIB_SYMBOLS "_GLIBCXX_DEBUG"
316 "_GLIBCXX_DEBUG_PEDANTIC"
317 "_GLIBCPP_CONCEPT_CHECKS" )
318 else()
319 list( APPEND ALIB_SYMBOLS_UNUSED "_GLIBCXX_DEBUG"
320 "_GLIBCXX_DEBUG_PEDANTIC"
321 "_GLIBCPP_CONCEPT_CHECKS" )
322 endif()
323
324 if ( ${ALIB_GDB_PP_SUPPRESS_CHILDREN} )
325 list( APPEND ALIB_SYMBOLS "ALIB_GDB_PP_SUPPRESS_CHILDREN" )
326 else()
327 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_GDB_PP_SUPPRESS_CHILDREN" )
328 endif()
329 if ( ${ALIB_GDB_PP_FIND_POINTER_TYPES} )
330 list( APPEND ALIB_SYMBOLS "ALIB_GDB_PP_FIND_POINTER_TYPES" )
331 else()
332 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_GDB_PP_FIND_POINTER_TYPES" )
333 endif()
334
335endif()
336
337# precompiled header
338if ( ${ALIB_PRECOMPILED_HEADER} )
339 list( APPEND ALIB_SYMBOLS "ALIB_PRECOMPILED_HEADER" )
340else()
341 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_PRECOMPILED_HEADER" )
342endif()
343
344# ALib features
345if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
346 if ( ALIB_DEBUG_ALLOCATIONS )
347 list( APPEND ALIB_SYMBOLS "ALIB_DEBUG_ALLOCATIONS" )
348 else()
349 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_DEBUG_ALLOCATIONS" )
350 endif()
351endif()
352
353
354if( "SINGLETONS" IN_LIST ALIB_DISTRIBUTION )
355 if (NOT platformDefaultFor_SINGLETON_MAPPED STREQUAL ALIB_FEAT_SINGLETON_MAPPED)
356 if ( ALIB_FEAT_SINGLETON_MAPPED )
357 list( APPEND ALIB_SYMBOLS "ALIB_FEAT_SINGLETON_MAPPED" )
358 else()
359 list( APPEND ALIB_SYMBOLS "ALIB_FEAT_SINGLETON_MAPPED=0" )
360 endif()
361 else()
362 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_FEAT_SINGLETON_MAPPED=0" )
363 endif()
364endif()
365
366if( "BITBUFFER" IN_LIST ALIB_DISTRIBUTION )
367 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
368 if ( ALIB_DEBUG_ARRAY_COMPRESSION )
369 list( APPEND ALIB_SYMBOLS "ALIB_DEBUG_ARRAY_COMPRESSION=1" )
370 else()
371 list( APPEND ALIB_SYMBOLS "ALIB_DEBUG_ARRAY_COMPRESSION=0" )
372 endif()
373 endif()
374endif()
375
376if( "BOXING" IN_LIST ALIB_DISTRIBUTION )
377 if ( ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS )
378 list( APPEND ALIB_SYMBOLS "ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS" )
379 else()
380 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS" )
381 endif()
382 if ( ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS )
383 list( APPEND ALIB_SYMBOLS "ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS" )
384 else()
385 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS" )
386 endif()
387 if ( ALIB_FEAT_BOXING_BIJECTIVE_FLOATS )
388 list( APPEND ALIB_SYMBOLS "ALIB_FEAT_BOXING_BIJECTIVE_FLOATS" )
389 else()
390 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_FEAT_BOXING_BIJECTIVE_FLOATS" )
391 endif()
392 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
393 if( ALIB_DEBUG_BOXING )
394 list( APPEND ALIB_SYMBOLS "ALIB_DEBUG_BOXING" )
395 else()
396 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_DEBUG_BOXING" )
397 endif()
398 endif()
399endif()
400
401if( "CHARACTERS" IN_LIST ALIB_DISTRIBUTION )
402 if (NOT (defaultALIB_CHARACTERS_WIDE STREQUAL ALIB_CHARACTERS_WIDE ))
403 if ( ALIB_CHARACTERS_WIDE )
404 list( APPEND ALIB_SYMBOLS "ALIB_CHARACTERS_WIDE" )
405 else()
406 list( APPEND ALIB_SYMBOLS "ALIB_CHARACTERS_WIDE=0" )
407 endif()
408 else()
409 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_CHARACTERS_WIDE" )
410 endif()
411
412 if (NOT defaultALIB_CHARACTERS_SIZEOF_WCHAR STREQUAL ALIB_CHARACTERS_SIZEOF_WCHAR)
413 if ( NOT (ALIB_CHARACTERS_SIZEOF_WCHAR STREQUAL "2" OR ALIB_CHARACTERS_SIZEOF_WCHAR STREQUAL "4") )
414 message( FATAL_ERROR "Value of ALIB_CHARACTERS_SIZEOF_WCHAR must be 2 or 4" )
415 return()
416 endif()
417 list( APPEND ALIB_SYMBOLS "ALIB_CHARACTERS_SIZEOF_WCHAR=${ALIB_CHARACTERS_SIZEOF_WCHAR}" )
418 else()
419 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_CHARACTERS_SIZEOF_WCHAR=${ALIB_CHARACTERS_SIZEOF_WCHAR}" )
420 endif()
421
422endif()
423
424if( "CONTAINERS" IN_LIST ALIB_DISTRIBUTION )
425 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
426 if ( ALIB_DEBUG_CONTAINERS )
427 list( APPEND ALIB_SYMBOLS "ALIB_DEBUG_CONTAINERS" )
428 else()
429 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_DEBUG_CONTAINERS" )
430 endif()
431 endif()
432endif()
433
434if( "THREADS" IN_LIST ALIB_DISTRIBUTION )
435 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
436 if ( ALIB_DEBUG_CRITICAL_SECTIONS )
437 list( APPEND ALIB_SYMBOLS "ALIB_DEBUG_CRITICAL_SECTIONS" )
438 else()
439 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_DEBUG_CRITICAL_SECTIONS" )
440 endif()
441 endif()
442endif()
443
444if( "MONOMEM" IN_LIST ALIB_DISTRIBUTION )
445 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
446 if ( ALIB_DEBUG_MONOMEM )
447 list( APPEND ALIB_SYMBOLS "ALIB_DEBUG_MONOMEM" )
448 else()
449 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_DEBUG_MONOMEM" )
450 endif()
451 endif()
452endif()
453
454if( "STRINGS" IN_LIST ALIB_DISTRIBUTION )
455 if ( ALIB_FEAT_BOOST_REGEX )
456 list( APPEND ALIB_SYMBOLS "ALIB_FEAT_BOOST_REGEX" )
457 else()
458 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_FEAT_BOOST_REGEX" )
459 endif()
460
461 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
462 if ( ALIB_DEBUG_STRINGS )
463 list( APPEND ALIB_SYMBOLS "ALIB_DEBUG_STRINGS" )
464 else()
465 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_DEBUG_STRINGS" )
466 endif()
467 endif()
468endif()
469
470if( "CAMP" IN_LIST ALIB_DISTRIBUTION )
471
472 if( ALIB_RESOURCES_OMIT_DEFAULTS )
473 list( APPEND ALIB_SYMBOLS "ALIB_RESOURCES_OMIT_DEFAULTS" )
474 else()
475 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_RESOURCES_OMIT_DEFAULTS" )
476 endif()
477
478 if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
479 if( ALIB_DEBUG_RESOURCES )
480 list( APPEND ALIB_SYMBOLS "ALIB_DEBUG_RESOURCES" )
481 else()
482 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_DEBUG_RESOURCES" )
483 endif()
484 endif()
485endif()
486
487if( "FILES" IN_LIST ALIB_DISTRIBUTION )
488 if ( ALIB_FILES_FORCE_STD_SCANNER )
489 list( APPEND ALIB_SYMBOLS "ALIB_FILES_FORCE_STD_SCANNER" )
490 else()
491 list( APPEND ALIB_SYMBOLS_UNUSED "ALIB_FILES_FORCE_STD_SCANNER" )
492 endif()
493endif()
494
495if( "ALOX" IN_LIST ALIB_DISTRIBUTION )
496
497 if (NOT defaultALOX_DBG_LOG STREQUAL ALOX_DBG_LOG)
498 if( NOT ALOX_DBG_LOG )
499 list( APPEND ALIB_SYMBOLS "ALOX_DBG_LOG" )
500 else()
501 list( APPEND ALIB_SYMBOLS_UNUSED "ALOX_DBG_LOG" )
502 endif()
503
504 if ( NOT ${ALOX_DBG_LOG_CI} )
505 list( APPEND ALIB_SYMBOLS "ALOX_DBG_LOG_CI=0" )
506 else()
507 list( APPEND ALIB_SYMBOLS_UNUSED "ALOX_DBG_LOG_CI=0" )
508 endif()
509 else()
510 list( APPEND ALIB_SYMBOLS_UNUSED "ALOX_DBG_LOG" )
511 list( APPEND ALIB_SYMBOLS_UNUSED "ALOX_DBG_LOG_CI" )
512 endif()
513
514 if ( NOT ALOX_REL_LOG )
515 list( APPEND ALIB_SYMBOLS "ALOX_REL_LOG=0" )
516 else()
517 list( APPEND ALIB_SYMBOLS_UNUSED "ALOX_REL_LOG=0" )
518 endif()
519 if ( ALOX_REL_LOG_CI )
520 list( APPEND ALIB_SYMBOLS "ALOX_REL_LOG_CI" )
521 else()
522 list( APPEND ALIB_SYMBOLS_UNUSED "ALOX_REL_LOG_CI" )
523 endif()
524endif()
525
526
527
528# --------------------------------------------------------------------------------------------------
529# ALib Source File Definition
530# --------------------------------------------------------------------------------------------------
531include( ${CMAKE_CURRENT_LIST_DIR}/ALibSources.cmake )
532
533
534# --------------------------------------------------------------------------------------------------
535# External libraries
536# --------------------------------------------------------------------------------------------------
537if ( NOT ${ALIB_CMAKE_SKIP_THREAD_LIB_SEARCH} )
538 find_package(Threads)
539 if(Threads_FOUND)
540 list( APPEND ALIB_SYMBOLS "ALIB_EXT_LIB_THREADS_AVAILABLE" )
541 if(CMAKE_USE_PTHREADS_INIT)
542 list( APPEND ALIB_COMPILER_OPTIONS "-pthread" )
543 endif()
544 endif()
545
546 list( APPEND ALIB_EXTERNAL_LIBS ${CMAKE_THREAD_LIBS_INIT} )
547endif()
548
549if ( ${ALIB_FEAT_BOOST_REGEX} )
550 set(Boost_USE_STATIC_LIBS "On" CACHE BOOL "Link boost statically" )
551 if( "THREADS" IN_LIST ALIB_DISTRIBUTION )
552 set(Boost_USE_MULTITHREADED "On" CACHE BOOL "Use multi-threaded version of boost")
553 else()
554 set(Boost_USE_MULTITHREADED "Off" CACHE BOOL "Use single-threaded version of boost")
555 endif()
556
557 find_package( Boost CONFIG REQUIRED COMPONENTS regex )
558
559 if(Boost_FOUND)
560 list( APPEND ALIB_EXTERNAL_LIBS Boost::regex )
561 if(${Boost_USE_STATIC_LIBS})
562 message(STATUS "Found Boost version ${Boost_LIB_VERSION}, linking against boost static libraries")
563 else()
564 message(STATUS "Found Boost version ${Boost_LIB_VERSION}, linking against boost shared libraries")
565 endif()
566 else()
567 MESSAGE("Attention: Boost::regex requested, but library not found!")
568 endif()
569endif()
570
571if(APPLE)
572 list( APPEND ALIB_EXTERNAL_LIBS "-framework Foundation")
573endif()
574
575# lib math, needed with GCC (suddenly, we don't really know why, added 221205)
576if(NOT MSVC)
577 if(NOT APPLE)
578 list( APPEND ALIB_EXTERNAL_LIBS "m")
579 endif(NOT APPLE)
580endif(NOT MSVC)
581
582# --------------------------------------------------------------------------------------------------
583# A-Worx compiler features and flags
584# --------------------------------------------------------------------------------------------------
585
586# Set minimum required standard C++ 17
587list( APPEND ALIB_COMPILER_FEATURES "cxx_std_17" )
588
589
590# if "ALIB_SUPPRESS_COMPILER_WARNINGS" is set prior to invoking this script, this entry is removed
591# and nothing is added.
592if ("ALIB_SUPPRESS_COMPILER_WARNINGS" IN_LIST ALIB_COMPILER_WARNINGS)
593 LIST( REMOVE_ITEM ALIB_COMPILER_WARNINGS "ALIB_SUPPRESS_COMPILER_WARNINGS" )
594else()
595 if ( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" )
596 # add -H to generate output "!/x" for use of precompiled header
597 list( APPEND ALIB_COMPILER_WARNINGS "-Wall" )
598 list( APPEND ALIB_COMPILER_WARNINGS "-Wextra" )
599 list( APPEND ALIB_COMPILER_WARNINGS "-Werror" )
600 #list( APPEND ALIB_COMPILER_WARNINGS "-Weffc++" )
601 list( APPEND ALIB_COMPILER_WARNINGS "-Wno-psabi" )
602 list( APPEND ALIB_COMPILER_WARNINGS "-Wno-misleading-indentation" )
603
604 # this was "suddenly" needed with GCC 13.2.1 with release compilation
605 list( APPEND ALIB_COMPILER_WARNINGS "-Wno-stringop-overread" )
606
607 # add coverage flags to GCC
608 if( ${ALIB_COVERAGE_COMPILE} )
609 list( APPEND ALIB_COMPILER_OPTIONS "--coverage" )
610 list( APPEND ALIB_LINKER_OPTIONS "--coverage" )
611 endif()
612
613 # force unicode (needed for mingw)
614 if(MINGW)
615 list( APPEND ALIB_COMPILER_OPTIONS "-municode" )
616 list( APPEND ALIB_COMPILER_OPTIONS "-DUNICODE" )
617 list( APPEND ALIB_COMPILER_OPTIONS "-D_UNICODE" )
618 endif()
619
620
621 # Clang: We are using -Weverything, although this is not recommended. We think it should be
622 # recommended. ALib for example does not use old-style casts and explicitly cast each
623 # and every type change! The benefit for ALib users is that ALib code can be used in very
624 # strict build environments without using special warning flags.
625 # Of course, some very obvious things like C++98 compatibility warnings have to be
626 # removed explicitly:
627 elseif ( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" )
628 list( APPEND ALIB_COMPILER_WARNINGS "-pedantic" )
629 list( APPEND ALIB_COMPILER_WARNINGS "-Weffc++" )
630 list( APPEND ALIB_COMPILER_WARNINGS "-Weverything" )
631 list( APPEND ALIB_COMPILER_WARNINGS "-Wno-c++98-compat" )
632 list( APPEND ALIB_COMPILER_WARNINGS "-Wno-c++98-compat-pedantic" )
633 list( APPEND ALIB_COMPILER_WARNINGS "-Wno-global-constructors" )
634 list( APPEND ALIB_COMPILER_WARNINGS "-Wno-exit-time-destructors" )
635 list( APPEND ALIB_COMPILER_WARNINGS "-Wno-padded" )
636 list( APPEND ALIB_COMPILER_WARNINGS "-Wno-weak-vtables" )
637 list( APPEND ALIB_COMPILER_WARNINGS "-Wno-documentation-unknown-command" )
638 list( APPEND ALIB_COMPILER_WARNINGS "-Wno-misleading-indentation" )
639 list( APPEND ALIB_COMPILER_WARNINGS "-Wno-covered-switch-default" )
640
641 if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
642 list( APPEND ALIB_COMPILER_OPTIONS "-fno-limit-debug-info" )
643 endif()
644
645 # MSVC
646 elseif ( ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC" )
647 list( APPEND ALIB_COMPILER_WARNINGS "/W4" )
648 list( APPEND ALIB_COMPILER_WARNINGS "/WX" )
649 list( APPEND ALIB_COMPILER_WARNINGS "/EHsc" )
650
651 #! NEVER TESTED YET !
652 elseif ( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel" )
653 list( APPEND ALIB_COMPILER_WARNINGS "" )
654
655 endif()
656endif()
657
658# --------------------------------------------------------------------------------------------------
659# A-Worx linker features and flags
660# --------------------------------------------------------------------------------------------------
661if(APPLE)
662 list( APPEND ALIB_LINKER_OPTIONS "-lObjc" )
663else()
664 list( APPEND ALIB_LINKER_OPTIONS "" )
665endif()
666
667
668# -------------------------------------------------------------------------------------------------
669# Set filename of ALib library (if not given in ALIB_LIBRARY_FILENAME)
670# -------------------------------------------------------------------------------------------------
671if ( NOT ALIB_LIBRARY_FILENAME )
672
673 set( ALIB_LIBRARY_FILENAME "alib_${ALIB_VERSION_NO}R${ALIB_VERSION_REV}" )
674
675 if ( ${ALIB_DEBUG} )
676 if ( (CMAKE_BUILD_TYPE STREQUAL "Debug") )
677 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}DBG )
678 else()
679 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}RELDBG )
680 endif()
681 if ( NOT ${ALIB_DEBUG_CRITICAL_SECTIONS} )
682 list( FIND ALIB_DISTRIBUTION "THREADS" idx )
683 if( NOT idx LESS 0 )
684 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_NOCSDBG )
685 endif()
686 endif()
687 if ( ${ALIB_DEBUG_ALLOCATIONS} )
688 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_DALLOC )
689 endif()
690 else()
691 if ( (CMAKE_BUILD_TYPE STREQUAL "Debug") )
692 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}DBGREL )
693 endif()
694 endif()
695
696 # Add features
697 if ( ${ALIB_FEAT_SINGLETON_MAPPED} )
698 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_MS )
699 endif()
700 if ( ${ALIB_CHARACTERS_WIDE} )
701 if ( ALIB_CHARACTERS_SIZEOF_WCHAR STREQUAL "2" )
702 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_WC2 )
703 else()
704 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_WC4 )
705 endif()
706 endif()
707 if ( ${ALIB_FEAT_BOOST_REGEX} )
708 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_BREGEX )
709 endif()
710 if ( ${ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS} )
711 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_BIJCHARS )
712 endif()
713 if ( ${ALIB_FEAT_BOXING_BIJECTIVE_FLOATS} )
714 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_BIJFLOATS )
715 endif()
716 if ( ${ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS} )
717 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_BIJINTS )
718 endif()
719
720
721
722 # Add all module's names, prefixed by "DBG" if special debug flag is set
723 if( NOT allModules )
724 FOREACH(modName IN LISTS ALIB_DISTRIBUTION)
725
726 # MONOMEM debug mode?
727 IF( modName STREQUAL "MONOMEM" )
728 if ( ALIB_DEBUG_MONOMEM AND ${ALIB_DEBUG} )
729 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_DBGMONOMEM )
730 else()
731 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_MONOMEM )
732 endif()
733
734 # CONTAINERS debug mode?
735 ELSEIF( modName STREQUAL "CONTAINERS" )
736 if ( ALIB_DEBUG_CONTAINERS AND ${ALIB_DEBUG} )
737 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_DBGCONTAINERS )
738 else()
739 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_CONTAINERS )
740 endif()
741
742 # STRINGS debug mode?
743 ELSEIF( modName STREQUAL "STRINGS" )
744 if ( ALIB_DEBUG_STRINGS AND ${ALIB_DEBUG} )
745 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_DBGSTRINGS )
746 else()
747 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_STRINGS )
748 endif()
749
750 # RESOURCES debug mode?
751 ELSEIF( modName STREQUAL "CAMP" )
752 if ( ALIB_DEBUG_RESOURCES AND ${ALIB_DEBUG} )
753 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_DBGCAMP )
754 else()
755 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_CAMP )
756 endif()
757
758 # ALOX: add non-default feature s
759 ELSEIF( modName STREQUAL "ALOX" )
760 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_ALOX )
761 if ( (CMAKE_BUILD_TYPE STREQUAL "Debug") AND (NOT ALOX_DBG_LOG) )
762 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}NDL )
763 endif()
764
765 if ( NOT ALOX_REL_LOG )
766 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}NRL )
767 endif()
768 ELSE()
769 set ( ALIB_LIBRARY_FILENAME ${ALIB_LIBRARY_FILENAME}_${modName} )
770 ENDIF()
771
772 ENDFOREACH()
773
774 # Remove all dependent modules from the name, which are not added in a dbg version:
775 list( FIND ALIB_DISTRIBUTION "BOXING" idx )
776 if( NOT idx LESS 0 )
777 STRING(REPLACE "_SINGLETONS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
778 STRING(REPLACE "_CHARACTERS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
779 endif()
780
781 list( FIND ALIB_DISTRIBUTION "STRINGS" idx )
782 if( NOT idx LESS 0 )
783 STRING(REPLACE "_CHARACTERS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
784 endif()
785
786 list( FIND ALIB_DISTRIBUTION "THREADS" idx )
787 if( NOT idx LESS 0 )
788 STRING(REPLACE "_STRINGS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
789 STRING(REPLACE "_TIME" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
790 endif()
791
792 list( FIND ALIB_DISTRIBUTION "ENUMS" idx )
793 if( NOT idx LESS 0 )
794 STRING(REPLACE "_SINGLETONS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
795 STRING(REPLACE "_STRINGS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
796 endif()
797
798 list( FIND ALIB_DISTRIBUTION "BITBUFFER" idx )
799 if( NOT idx LESS 0 )
800 STRING(REPLACE "_MONOMEM" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
801 STRING(REPLACE "_ENUMS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
802 endif()
803
804 list( FIND ALIB_DISTRIBUTION "THREADMODEL" idx )
805 if( NOT idx LESS 0 )
806 STRING(REPLACE "_BOXING" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
807 STRING(REPLACE "_CONTAINERS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
808 STRING(REPLACE "_ENUMS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
809 STRING(REPLACE "_MONOMEM" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
810 STRING(REPLACE "_THREADS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
811 endif()
812
813 list( FIND ALIB_DISTRIBUTION "CAMP" idx )
814 if( NOT idx LESS 0 )
815 STRING(REPLACE "_BOXING" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
816 STRING(REPLACE "_ENUMS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
817 STRING(REPLACE "_CONTAINERS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
818 STRING(REPLACE "_MONOMEM" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
819 STRING(REPLACE "_SINGLETONS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
820 STRING(REPLACE "_STRINGS" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
821 STRING(REPLACE "_TIME" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
822 endif()
823
824 list( FIND ALIB_DISTRIBUTION "CONFIGURATION" idx )
825 if( NOT idx LESS 0 )
826 STRING(REPLACE "_CAMP" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
827 endif()
828
829 list( FIND ALIB_DISTRIBUTION "ALOX" idx )
830 if( NOT idx LESS 0 )
831 STRING(REPLACE "_CONFIGURATION" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
832 endif()
833
834 list( FIND ALIB_DISTRIBUTION "EXPRESSIONS" idx )
835 if( NOT idx LESS 0 )
836 STRING(REPLACE "_CAMP" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
837 endif()
838
839 list( FIND ALIB_DISTRIBUTION "FILES" idx )
840 if( NOT idx LESS 0 )
841 STRING(REPLACE "_CAMP" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
842 endif()
843
844 list( FIND ALIB_DISTRIBUTION "CLI" idx )
845 if( NOT idx LESS 0 )
846 STRING(REPLACE "_CAMP" "" ALIB_LIBRARY_FILENAME "${ALIB_LIBRARY_FILENAME}")
847 endif()
848
849 endif() # not all modules
850
851endif()
852
853# -------------------------------------------------------------------------------------------------
854# Display result summary
855# -------------------------------------------------------------------------------------------------
856message( "ALib CMake Configuration:" )
857IF( NOT allModules )
858 message( " Module Selection : ${ALIB_DISTRIBUTION}" )
859ELSE()
860 message( " Module Selection : All (${ALIB_DISTRIBUTION})" )
861ENDIF()
862
863 message( " Library filename : ${ALIB_LIBRARY_FILENAME}" )
864 message( " Compiler ID : ${CMAKE_CXX_COMPILER_ID}")
865
866IF( NOT ALIB_CMAKE_VERBOSE )
867 message( " (For further details enable CMake variable 'ALIB_CMAKE_VERBOSE')" )
868ELSE()
869
870 message( " Source folder: ${ALIB_SOURCE_DIR}" )
871 SET( result "" )
872 LIST( APPEND result ${ALIB_INCLUDE_FILES} )
873 LIST( APPEND result ${ALIB_SOURCE_FILES} )
874 LIST( SORT result )
875 LIST( LENGTH result length)
876 message( "\n List of header and source files (${length} items):" )
877 FOREACH( entry IN LISTS result )
878 STRING(REPLACE "${ALIB_SOURCE_DIR}/" "" entry ${entry} )
879 message( " ${entry}" )
880 ENDFOREACH()
881
882 SET( result "" )
883 LIST( APPEND result ${ALIB_SYMBOLS} )
884 LIST( SORT result )
885 LIST( LENGTH result length)
886 message( "\n Compiler definitions (${length} items):" )
887 FOREACH( entry IN LISTS result )
888 message( " ${entry}" )
889 ENDFOREACH()
890 SET( result "" )
891
892 SET( result "" )
893 LIST( APPEND result ${ALIB_SYMBOLS_UNUSED} )
894 LIST( SORT result )
895 LIST( LENGTH result length)
896 message( "\n Compiler definitions NOT given/omitted (${length} items):" )
897 FOREACH( entry IN LISTS result )
898 message( " ${entry}" )
899 ENDFOREACH()
900 SET( result "" )
901
902 LIST( APPEND result ${ALIB_COMPILER_WARNINGS} )
903 LIST( SORT result )
904 LIST( LENGTH result length)
905 message( "\n Compiler warnings (${length} items):" )
906 FOREACH( entry IN LISTS result )
907 message( " ${entry}" )
908 ENDFOREACH()
909 SET( result "" )
910
911 LIST( APPEND result ${ALIB_COMPILER_OPTIONS} )
912 LIST( SORT result )
913 LIST( LENGTH result length)
914 message( "\n Compiler flags (${length} items):" )
915 FOREACH( entry IN LISTS result )
916 message( " ${entry}" )
917 ENDFOREACH()
918 SET( result "" )
919
920 LIST( APPEND result ${ALIB_COMPILER_FEATURES} )
921 LIST( SORT result )
922 LIST( LENGTH result length)
923 message( "\n Compiler features (${length} items):" )
924 FOREACH( entry IN LISTS result )
925 message( " ${entry}" )
926 ENDFOREACH()
927 SET( result "" )
928
929 LIST( APPEND result ${ALIB_EXTERNAL_LIBS} )
930 LIST( SORT result )
931 LIST( LENGTH result length)
932 message( "\n External libraries (${length} items):" )
933 FOREACH( entry IN LISTS result )
934 message( " ${entry}" )
935 ENDFOREACH()
936 SET( result "" )
937
938 LIST( APPEND result ${ALIB_LINKER_OPTIONS} )
939 LIST( SORT result )
940 LIST( LENGTH result length)
941 message( "\n Linker flags (${length} items):" )
942 FOREACH( entry IN LISTS result )
943 message( " ${entry}" )
944 ENDFOREACH()
945 SET( result "" )
946
947 message( "\n" )
948ENDIF()
949
950# -------------------------------------------------------------------------------------------------
951# ALibSetCompilerAndLinker(target)
952#
953# Simple CMake function that sets
954# - ALIB_SYMBOLS
955# - ALIB_COMPILER_FEATURES
956# - ALIB_COMPILER_OPTIONS
957# - ALIB_COMPILER_WARNINGS
958# - ALIB_LINKER_OPTIONS
959#
960# In addition, postion independent compile (-fPic) is enabled (for static libraries its default
961# is off with CMake).
962# -------------------------------------------------------------------------------------------------
963function( ALibSetCompilerAndLinker target )
964
965 # compiler flags
966 target_compile_features ( ${target} PRIVATE ${ALIB_COMPILER_FEATURES} )
967 target_compile_options ( ${target} PRIVATE ${ALIB_COMPILER_OPTIONS} )
968 target_compile_options ( ${target} PRIVATE ${ALIB_COMPILER_WARNINGS} )
969 set_property ( TARGET ${target} PROPERTY POSITION_INDEPENDENT_CODE ON )
970 target_include_directories( ${target} PUBLIC ${ALIB_SOURCE_DIR} )
971
972 #definitions
973 target_compile_definitions( ${target} PUBLIC ${ALIB_SYMBOLS} )
974
975 # linker flags
976 IF( NOT "${ALIB_LINKER_OPTIONS}" STREQUAL "" )
977 set_target_properties ( ${target} PROPERTIES LINK_FLAGS ${ALIB_LINKER_OPTIONS} )
978 ENDIF()
979 IF( NOT "${ALIB_EXTERNAL_LIBS}" STREQUAL "" )
980 target_link_libraries ( ${target} PRIVATE ${ALIB_EXTERNAL_LIBS} )
981 ENDIF()
982
983endfunction()
984
985# -------------------------------------------------------------------------------------------------
986# Targets
987# -------------------------------------------------------------------------------------------------
988function( ALibAddStaticLibrary )
989 # sources
990 add_library ( ALib_StaticLib STATIC ${ALIB_INCLUDE_FILES} ${ALIB_SOURCE_FILES} )
991 ALibSetCompilerAndLinker ( ALib_StaticLib )
992 set_target_properties ( ALib_StaticLib PROPERTIES ARCHIVE_OUTPUT_NAME ${ALIB_LIBRARY_FILENAME} )
993endfunction()
994
995function( ALibAddSharedLibrary )
996 add_library ( ALib_SharedLib SHARED ${ALIB_INCLUDE_FILES} ${ALIB_SOURCE_FILES} )
997 ALibSetCompilerAndLinker ( ALib_SharedLib )
998 set_target_properties ( ALib_SharedLib PROPERTIES LIBRARY_OUTPUT_NAME ${ALIB_LIBRARY_FILENAME} )
999
1000 if(WIN32)
1001 target_compile_definitions ( ALib_SharedLib PRIVATE "ALIB_API_IS_DLL" )
1002 endif()
1003endfunction()
1004
1005# --------------------------------------------------------------------------------------------------
1006# CMake debugging Uncomment a line to have CMake summarize information
1007# --------------------------------------------------------------------------------------------------
1008#set(CMAKE_DEBUG_TARGET_PROPERTIES ${CMAKE_DEBUG_TARGET_PROPERTIES} INCLUDE_DIRECTORIES )
1009#set(CMAKE_DEBUG_TARGET_PROPERTIES ${CMAKE_DEBUG_TARGET_PROPERTIES} SOURCES )
1010#set(CMAKE_DEBUG_TARGET_PROPERTIES ${CMAKE_DEBUG_TARGET_PROPERTIES} COMPILE_DEFINITIONS )
1011#set(CMAKE_DEBUG_TARGET_PROPERTIES ${CMAKE_DEBUG_TARGET_PROPERTIES} COMPILE_OPTIONS )
1012#set(CMAKE_DEBUG_TARGET_PROPERTIES ${CMAKE_DEBUG_TARGET_PROPERTIES} COMPILE_FEATURES )
1013#set(CMAKE_DEBUG_TARGET_PROPERTIES ${CMAKE_DEBUG_TARGET_PROPERTIES} AUTOUIC_OPTIONS )
1014#set(CMAKE_DEBUG_TARGET_PROPERTIES ${CMAKE_DEBUG_TARGET_PROPERTIES} POSITION_INDEPENDENT_CODE )
1015#set(CMAKE_DEBUG_TARGET_PROPERTIES ${CMAKE_DEBUG_TARGET_PROPERTIES} CONTAINER_SIZE_REQUIRED )
1016#set(CMAKE_DEBUG_TARGET_PROPERTIES ${CMAKE_DEBUG_TARGET_PROPERTIES} LIB_VERSION )
1017
1018#set(CMAKE_VERBOSE_MAKEFILE ON)