This repository has been archived on 2020-05-10. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon-cpp/CMakeLists.txt

87 lines
2.3 KiB
CMake
Raw Permalink Normal View History

2019-08-14 00:15:04 +02:00
# 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()
include(GNUInstallDirs)
2018-01-06 21:33:52 +01:00
project (mastodon-cpp
2019-12-26 03:16:12 +01:00
VERSION 0.111.5
2019-08-14 00:15:04 +02:00
LANGUAGES CXX)
2019-08-14 00:15:04 +02:00
# DESCRIPTION was introduced in version 3.9.
if(NOT (${CMAKE_VERSION} VERSION_LESS 3.9))
set(PROJECT_DESCRIPTION
"C++ wrapper for the Mastodon API.")
endif()
2018-04-09 21:47:07 +02:00
2019-08-14 00:15:04 +02:00
option(WITH_EASY "Compile Easy interface." YES)
option(WITH_EXAMPLES "Compile examples." NO)
option(WITH_TESTS "Compile tests." NO)
option(WITH_DOC "Generate HTML documentation." YES)
option(WITH_DEB "Prepare for the building of .deb packages." NO)
option(WITH_RPM "Prepare for the building of .rpm packages." NO)
option(BUILD_SHARED_LIBS "Build shared libraries." YES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type, Release or Debug.")
2018-02-05 14:56:16 +01:00
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
2018-02-05 14:56:16 +01:00
2019-08-14 00:15:04 +02:00
set(DEBUG_CXXFLAGS
"-Wall"
"-Wextra"
"-Wpedantic"
"-ftrapv"
"-fsanitize=undefined"
"-g"
"-Og"
"-fno-omit-frame-pointer"
"-Wno-deprecated-declarations")
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-08-14 00:15:04 +02:00
# Turn on debug output.
2018-01-06 21:33:52 +01:00
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
2019-08-14 00:15:04 +02:00
add_definitions("-DDEBUG=1")
2018-01-06 21:33:52 +01:00
endif()
if(NOT WITH_EASY)
2019-08-14 00:15:04 +02:00
add_definitions("-DWITHOUT_EASY=1")
endif()
2019-08-14 00:15:04 +02:00
add_subdirectory("src")
if(WITH_EXAMPLES)
2019-08-14 00:15:04 +02:00
add_subdirectory("examples")
2018-01-06 21:33:52 +01:00
endif()
if(WITH_TESTS)
2019-08-14 00:15:04 +02:00
add_subdirectory("tests")
endif()
if(WITH_DOC)
2019-04-14 04:11:17 +02:00
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/doc/html
2019-08-14 00:15:04 +02:00
COMMAND "./build_doc.sh" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
2019-04-14 04:11:17 +02:00
add_custom_target(doc DEPENDS doc/html)
add_dependencies(${PROJECT_NAME} doc)
2019-08-14 00:15:04 +02:00
2019-04-14 04:11:17 +02:00
install(DIRECTORY ${PROJECT_SOURCE_DIR}/doc/html
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}")
endif()
2019-08-14 00:15:04 +02:00
add_subdirectory("cmake")
2019-08-14 00:19:12 +02:00
add_subdirectory("pkg-config")
2019-08-14 00:15:04 +02:00
include("cmake/packages.cmake")