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-10-06 17:20:44 +02:00
|
|
|
VERSION 0.111.1
|
2019-08-14 00:15:04 +02:00
|
|
|
LANGUAGES CXX)
|
2019-04-04 12:47:40 +02:00
|
|
|
|
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.")
|
2018-07-19 11:06:16 +02:00
|
|
|
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)
|
2018-04-04 06:11:12 +02:00
|
|
|
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}>")
|
2018-04-19 00:56:33 +02:00
|
|
|
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()
|
|
|
|
|
2019-04-04 12:47:40 +02:00
|
|
|
if(NOT WITH_EASY)
|
2019-08-14 00:15:04 +02:00
|
|
|
add_definitions("-DWITHOUT_EASY=1")
|
2018-03-21 17:08:33 +01:00
|
|
|
endif()
|
|
|
|
|
2019-08-14 00:15:04 +02:00
|
|
|
add_subdirectory("src")
|
2018-07-19 11:06:16 +02:00
|
|
|
|
2018-01-13 21:12:07 +01:00
|
|
|
if(WITH_EXAMPLES)
|
2019-08-14 00:15:04 +02:00
|
|
|
add_subdirectory("examples")
|
2018-01-06 21:33:52 +01:00
|
|
|
endif()
|
|
|
|
|
2018-01-13 21:12:07 +01:00
|
|
|
if(WITH_TESTS)
|
2019-08-14 00:15:04 +02:00
|
|
|
add_subdirectory("tests")
|
2018-04-04 06:11:12 +02:00
|
|
|
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)
|
2019-04-14 04:38:59 +02:00
|
|
|
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
|
2019-10-06 17:20:07 +02:00
|
|
|
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}")
|
2018-04-04 06:11:12 +02:00
|
|
|
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")
|