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

61 lines
1.9 KiB
CMake
Raw Normal View History

2018-01-06 21:33:52 +01:00
cmake_minimum_required (VERSION 3.7)
include(GNUInstallDirs)
2018-01-06 21:33:52 +01:00
project (mastodon-cpp
2018-01-13 16:07:00 +01:00
VERSION 0.1.1
2018-01-06 21:33:52 +01:00
LANGUAGES CXX
)
2018-01-13 19:03:10 +01:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC")
2018-01-06 21:33:52 +01:00
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
2018-01-13 19:03:10 +01:00
# Write version in header
2018-01-06 21:33:52 +01:00
include_directories(${MY_SOURCE_DIR}/src)
configure_file (
"${PROJECT_SOURCE_DIR}/src/version.hpp.in"
"${PROJECT_BINARY_DIR}/version.hpp"
)
include_directories(${PROJECT_BINARY_DIR})
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DDEBUG=1)
endif()
file(GLOB sources src/*.cpp src/*.hpp)
add_library(mastodon-cpp SHARED ${sources})
set_target_properties(mastodon-cpp PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${mastodon-cpp_VERSION_MAJOR}
)
2018-01-13 16:32:43 +01:00
target_link_libraries(mastodon-cpp boost_system ssl crypto)
install(TARGETS mastodon-cpp LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${PROJECT_SOURCE_DIR}/src/mastodon-cpp.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Documentation
if(WITH_DOC)
execute_process(COMMAND ./build_doc.sh
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
install(DIRECTORY ${PROJECT_SOURCE_DIR}/doc/html
DESTINATION ${CMAKE_INSTALL_DOCDIR}/mastodon-cpp-${PROJECT_VERSION})
install(FILES ${PROJECT_SOURCE_DIR}/src/examples/example.cpp
DESTINATION ${CMAKE_INSTALL_DOCDIR}/mastodon-cpp-${PROJECT_VERSION}/examples)
endif()
2018-01-06 21:33:52 +01:00
# Example client
if(WITH_EXAMPLES)
file(GLOB_RECURSE sources_example src/examples/example.cpp)
2018-01-06 21:33:52 +01:00
add_executable(example ${sources_example})
target_link_libraries(example mastodon-cpp)
endif()
# Tests
if(WITH_TESTS)
2018-01-06 21:33:52 +01:00
include(CTest)
file(GLOB sources_tests "src/tests/test_*.cpp")
foreach(src ${sources_tests})
get_filename_component(bin ${src} NAME_WE)
add_executable(${bin} ${src})
target_link_libraries(${bin} mastodon-cpp)
add_test(${bin} ${bin})
endforeach()
endif()