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
|
cmake_minimum_required(VERSION 3.12)
# Ensure built-in policies from CMake are used, (e.g. improved policies for macOS)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
project(libeconf VERSION 0.7.7
DESCRIPTION "Enhanced config file parser, which merges config files placed in several locations into one."
LANGUAGES C
)
# Set up GNU conventions and standard FHS paths
include(GNUInstallDirs)
# Activate CMake package configuration helpers
include(CMakePackageConfigHelpers)
# Ensure _GNU_SOURCE is available
include(CheckSymbolExists)
# check if _GNU_SOURCE is available
if (NOT _GNU_SOURCE)
check_symbol_exists(__GNU_LIBRARY__ "features.h" _GNU_SOURCE)
if (NOT _GNU_SOURCE)
unset(_GNU_SOURCE CACHE)
check_symbol_exists(_GNU_SOURCE "features.h" _GNU_SOURCE)
endif ()
endif ()
if (_GNU_SOURCE)
add_definitions(-D_GNU_SOURCE)
endif ()
# set the minimum C standard
set(CMAKE_C_STANDARD 11)
# Build Types
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}
CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Sanitize RelWithDebInfoStrict"
FORCE
)
# AddressSanitize
set(CMAKE_C_FLAGS_SANITIZE
"-O2 -g -Wall -fsanitize=address,undefined"
CACHE STRING "Flags used by the C compiler during Sanitizer builds."
FORCE
)
set(CMAKE_LINK_FLAGS_SANITIZE
"-fsanitize=address,undefined"
CACHE STRING "Flags used by the linker during Sanitizer builds."
FORCE
)
# RelWithDebInfoStrict
set(CMAKE_C_FLAGS_RELWITHDEBINFOSTRICT
"-O2 -g -Werror -W -Wall -DXTSTRINGDEFINES -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=8 -Wbad-function-cast -Wcast-align -Wcast-qual -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef"
CACHE STRING "Flags used by the C compiler during strict RelWithDebInfo builds."
FORCE
)
add_subdirectory(lib)
add_subdirectory(example)
add_subdirectory(util)
add_subdirectory(doc)
# Enable testing
include(CTest)
enable_testing()
add_subdirectory(tests)
|