ADD: added cmake config file for building
This commit is contained in:
parent
02d3d282a3
commit
d64ed1fcd0
143
CMakeLists.txt
Normal file
143
CMakeLists.txt
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2024 Dominik Meyer
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
cmake_minimum_required (VERSION 3.1 FATAL_ERROR)
|
||||||
|
project (remine-api-cpp VERSION 0.0.1 LANGUAGES CXX)
|
||||||
|
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules )
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
||||||
|
include(compdb)
|
||||||
|
include(doxygen)
|
||||||
|
|
||||||
|
build_docs(PROCESS_DOXYFILE DOXYFILE_PATH "docs/Doxyfile.in" )
|
||||||
|
|
||||||
|
|
||||||
|
# generate project specific configuration file
|
||||||
|
configure_file(${PROJECT_SOURCE_DIR}/src/config.hpp.in ${PROJECT_SOURCE_DIR}/src/config.hpp @ONLY)
|
||||||
|
|
||||||
|
#
|
||||||
|
# All dependencies
|
||||||
|
#
|
||||||
|
|
||||||
|
IF (NOT TARGET CLI11)
|
||||||
|
set(CLI11_TESTING OFF CACHE BOOL "disable testing")
|
||||||
|
add_subdirectory(libs/CLI11 EXCLUDE_FROM_ALL)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF(NOT TARGET loguru)
|
||||||
|
set(LOGURU_BUILD_TESTS OFF CACHE BOOL "disable testing")
|
||||||
|
set(LOGURU_BUILD_EXAMPLES OFF CACHE BOOL "disable testing")
|
||||||
|
set(LOGURU_INSTALL OFF CACHE BOOL "disable testing")
|
||||||
|
set(LOGURU_WITH_STREAMS ON CACHE BOOL "disable testing")
|
||||||
|
add_subdirectory(libs/loguru EXCLUDE_FROM_ALL)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF(NOT TARGET nlohmann_json::nlohmann_json)
|
||||||
|
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
||||||
|
add_subdirectory(libs/json EXCLUDE_FROM_ALL)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF(NOT TARGET httplib::httplib)
|
||||||
|
set(HTTPLIB_REQUIRE_OPENSSL OFF CACHE INTERNAL "")
|
||||||
|
set(HTTPLIB_TEST OFF CACHE INTERNAL "")
|
||||||
|
add_subdirectory(libs/cpp-httplib EXCLUDE_FROM_ALL)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
|
SET(REDMINE_LIBARIES loguru nlohmann_json::nlohmann_json httplib::httplib)
|
||||||
|
|
||||||
|
#
|
||||||
|
# all source files for the redmine api cpp library
|
||||||
|
#
|
||||||
|
SET(REDMINE_API_SOURCES
|
||||||
|
include/Redmine/Object.hpp
|
||||||
|
src/Redmine/Object.cpp
|
||||||
|
|
||||||
|
include/Redmine/User.hpp
|
||||||
|
src/Redmine/User.cpp
|
||||||
|
|
||||||
|
include/Redmine/API.hpp
|
||||||
|
src/Redmine/API.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(redmine-api-cpp-objlib OBJECT ${REDMINE_API_SOURCES})
|
||||||
|
|
||||||
|
set_property(TARGET redmine-api-cpp-objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
|
||||||
|
target_include_directories(redmine-api-cpp-objlib
|
||||||
|
PUBLIC
|
||||||
|
include
|
||||||
|
PRIVATE
|
||||||
|
src
|
||||||
|
)
|
||||||
|
target_link_libraries(redmine-api-cpp-objlib PUBLIC ${REDMINE_LIBARIES})
|
||||||
|
|
||||||
|
add_library(redmine-api-cpp SHARED $<TARGET_OBJECTS:redmine-api-cpp-objlib>)
|
||||||
|
target_include_directories(redmine-api-cpp
|
||||||
|
PUBLIC
|
||||||
|
include
|
||||||
|
PRIVATE
|
||||||
|
src
|
||||||
|
)
|
||||||
|
target_link_libraries(redmine-api-cpp-objlib PUBLIC ${REDMINE_LIBARIES})
|
||||||
|
|
||||||
|
add_library(redmine-api-cpp-static STATIC $<TARGET_OBJECTS:redmine-api-cpp-objlib>)
|
||||||
|
target_include_directories(redmine-api-cpp-static
|
||||||
|
PUBLIC
|
||||||
|
include
|
||||||
|
PRIVATE
|
||||||
|
src
|
||||||
|
)
|
||||||
|
target_link_libraries(redmine-api-cpp-static PUBLIC ${REDMINE_LIBARIES})
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(redmine-cli
|
||||||
|
src/Redmine-CLI/main.cpp
|
||||||
|
src/Redmine-CLI/Redmine.hpp
|
||||||
|
src/Redmine-CLI/Redmine.cpp
|
||||||
|
src/Redmine-CLI/Command/Version.hpp
|
||||||
|
src/Redmine-CLI/Command/Version.cpp
|
||||||
|
src/Redmine-CLI/Command/MyAccount.hpp
|
||||||
|
src/Redmine-CLI/Command/MyAccount.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries(redmine-cli redmine-api-cpp-static loguru CLI11)
|
||||||
|
target_include_directories(redmine-cli
|
||||||
|
PRIVATE
|
||||||
|
src
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(${REDMINE_API_TESTS})
|
||||||
|
|
||||||
|
IF(NOT TARGET Catch2)
|
||||||
|
add_subdirectory(libs/Catch2 EXCLUDE_FROM_ALL)
|
||||||
|
include(libs/Catch2/contrib/Catch.cmake)
|
||||||
|
ENDIF()
|
||||||
|
#
|
||||||
|
# add tests as executable
|
||||||
|
#
|
||||||
|
add_executable(test_event tests/test_event.cpp)
|
||||||
|
target_link_libraries(test_event Catch2::Catch2 eventmanager-static)
|
||||||
|
catch_discover_tests(test_event)
|
||||||
|
|
||||||
|
add_executable(test_basic tests/test_basic.cpp)
|
||||||
|
target_link_libraries(test_basic Catch2::Catch2 eventmanager-static)
|
||||||
|
catch_discover_tests(test_basic)
|
||||||
|
|
||||||
|
ENDIF()
|
Loading…
Reference in New Issue
Block a user