2019-05-11 02:52:33 +02:00
|
|
|
cmake_minimum_required (VERSION 3.2)
|
|
|
|
project(remwharead
|
2019-05-16 08:37:50 +02:00
|
|
|
VERSION 0.0.2
|
2019-05-11 02:52:33 +02:00
|
|
|
LANGUAGES CXX
|
|
|
|
)
|
|
|
|
|
|
|
|
set(WITH_MAN "YES" CACHE STRING "WITH_MAN defaults to \"YES\"")
|
|
|
|
set(WITH_TESTS "NO" CACHE STRING "WITH_TESTS defaults to \"NO\"")
|
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
find_package(PkgConfig REQUIRED)
|
2019-05-12 21:39:01 +02:00
|
|
|
pkg_check_modules(LIBXDG_BASEDIR REQUIRED libxdg-basedir)
|
|
|
|
# sqlite3 is not a direct dependency, but vsqlite++ has no cmake- or pkg-config
|
|
|
|
# module. Since it installs in the same directories as sqlite3, I am adding the
|
|
|
|
# module here to add the include- and link directories below. It is not REQUIRED
|
|
|
|
# because the sqlite3 in Debian jessie doesn't come with a pkg-config module.
|
|
|
|
pkg_check_modules(SQLITE3 sqlite3)
|
2019-05-15 07:04:12 +02:00
|
|
|
pkg_check_modules(CURLPP REQUIRED curlpp)
|
2019-05-11 02:52:33 +02:00
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG
|
|
|
|
"${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wpedantic -ftrapv \
|
|
|
|
-fsanitize=undefined -g -Og -fno-omit-frame-pointer")
|
|
|
|
|
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/src)
|
|
|
|
Include_directories(${PROJECT_BINARY_DIR})
|
|
|
|
|
2019-05-12 21:39:01 +02:00
|
|
|
include_directories(${LIBXDG_BASEDIR_INCLUDE_DIRS})
|
|
|
|
include_directories(${SQLITE3_INCLUDE_DIRS})
|
2019-05-15 07:04:12 +02:00
|
|
|
include_directories(${CURLPP_INCLUDE_DIRS})
|
2019-05-11 02:52:33 +02:00
|
|
|
|
2019-05-12 21:39:01 +02:00
|
|
|
link_directories(${LIBXDG_BASEDIR_LIBRARY_DIRS})
|
|
|
|
link_directories(${SQLITE3_LIBRARY_DIRS})
|
2019-05-15 07:04:12 +02:00
|
|
|
link_directories(${CURLPP_LIBRARY_DIRS})
|
2019-05-12 21:39:01 +02:00
|
|
|
|
|
|
|
set(COMMON_LIBRARIES
|
2019-05-15 07:04:12 +02:00
|
|
|
${LIBXDG_BASEDIR_LIBRARIES} vsqlitepp stdc++fs ${CURLPP_LIBRARIES})
|
2019-05-11 02:52:33 +02:00
|
|
|
|
|
|
|
# Write version in header
|
|
|
|
configure_file(
|
|
|
|
"${PROJECT_SOURCE_DIR}/src/version.hpp.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/version.hpp"
|
|
|
|
)
|
|
|
|
|
|
|
|
file(GLOB sources src/*.cpp)
|
|
|
|
add_executable(${PROJECT_NAME} "${sources}")
|
2019-05-12 21:39:01 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} ${COMMON_LIBRARIES})
|
2019-05-11 02:52:33 +02:00
|
|
|
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
|
|
|
|
|
|
if (WITH_MAN)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.1"
|
|
|
|
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
|
|
|
|
DEPENDS "${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.1.adoc"
|
|
|
|
COMMAND ${CMAKE_SOURCE_DIR}/build_manpage.sh
|
|
|
|
ARGS ${PROJECT_VERSION})
|
|
|
|
add_custom_target(run ALL DEPENDS "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.1")
|
|
|
|
install(
|
|
|
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.1
|
|
|
|
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_TESTS)
|
|
|
|
add_library(${PROJECT_NAME}_testlib SHARED ${sources})
|
2019-05-12 21:39:01 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME}_testlib ${COMMON_LIBRARIES})
|
2019-05-11 02:52:33 +02:00
|
|
|
include(tests.CMakeLists.txt)
|
|
|
|
endif()
|