identiconpp/CMakeLists.txt

58 lines
1.5 KiB
CMake
Raw Permalink Normal View History

# Support version 3.6 and above, but use policy settings up to 3.14.
# 3.6 is needed because of IMPORTED_TARGET in pkg_check_modules().
cmake_minimum_required(VERSION 3.6...3.14)
# Ranges are supported from 3.12, set policy to current for < 3.12.
if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()
2018-12-25 18:33:19 +01:00
project(identiconpp
2020-10-24 11:30:43 +02:00
VERSION 0.7.3
2019-07-30 11:32:57 +02:00
LANGUAGES CXX)
# DESCRIPTION was introduced in version 3.9.
if(NOT (${CMAKE_VERSION} VERSION_LESS 3.9))
set(PROJECT_DESCRIPTION
"Library to generate identicons for C++.")
endif()
2018-12-25 18:33:19 +01:00
2019-07-30 11:32:57 +02:00
option(WITH_TESTS "Enable Tests" NO)
option(BUILD_SHARED_LIBS "Build shared libraries." YES)
2018-12-25 18:33:19 +01:00
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(DEBUG_CXXFLAGS
"-Wall"
"-Wextra"
"-Wpedantic"
"-ftrapv"
"-fsanitize=undefined"
"-g"
"-Og"
"-fno-omit-frame-pointer")
set(DEBUG_LDFLAGS
"-fsanitize=undefined")
add_compile_options("$<$<CONFIG:Debug>:${DEBUG_CXXFLAGS}>")
# add_link_options was introduced in version 3.13.
if(${CMAKE_VERSION} VERSION_LESS 3.13)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${DEBUG_LDFLAGS}")
else()
add_link_options("$<$<CONFIG:Debug>:${DEBUG_LDFLAGS}>")
endif()
2019-07-30 11:32:57 +02:00
2018-12-25 18:33:19 +01:00
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
2019-07-30 11:32:57 +02:00
add_definitions(-DDEBUG=1)
2018-12-25 18:33:19 +01:00
endif()
2019-07-30 11:32:57 +02:00
add_subdirectory(src)
2019-09-23 19:00:52 +02:00
add_subdirectory(include)
add_subdirectory(cmake)
add_subdirectory(pkg-config)
2019-07-30 11:32:57 +02:00
if(WITH_TESTS)
add_subdirectory(tests)
endif()
include(packages.CMakeLists.txt)