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

81 lines
2.4 KiB
CMake

cmake_minimum_required (VERSION 3.7)
project (mastodon-cpp
VERSION 0.5.0
LANGUAGES CXX
)
include(GNUInstallDirs)
include(FindCURL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_BINARY_DIR})
# Write version in header
configure_file (
"${PROJECT_SOURCE_DIR}/src/version.hpp.in"
"${PROJECT_BINARY_DIR}/version.hpp"
)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DDEBUG=1)
endif()
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIR})
# Library
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}
)
target_link_libraries(mastodon-cpp ssl crypto ${CURL_LIBRARIES} curlpp)
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()
# Examples
if(WITH_EXAMPLES)
include(FindBoost)
find_package(Boost REQUIRED COMPONENTS system filesystem)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
add_definitions(${Boost_DEFINITIONS})
file(GLOB sources_examples src/examples/*.cpp)
foreach(src ${sources_examples})
get_filename_component(bin ${src} NAME_WE)
add_executable(${bin} ${src})
target_link_libraries(${bin} -lpthread ${Boost_LIBRARIES} mastodon-cpp)
endforeach()
endif()
# Tests
if(WITH_TESTS)
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()