mirror of
https://github.com/TheLartians/ModernCppStarter.git
synced 2025-09-03 07:30:53 +02:00
add boost, make boost work in docker, solve merge conflict
This commit is contained in:
parent
617257b7dc
commit
11319c5e0b
6 changed files with 101 additions and 83 deletions
|
@ -1,6 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.14...3.22)
|
||||
|
||||
project(GreeterStandalone LANGUAGES CXX)
|
||||
project(
|
||||
GreeterStandalone
|
||||
DESCRIPTION "A standalone minimal webserver application using the Crow framework"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
# --- Import tools ----
|
||||
|
||||
|
@ -10,12 +14,44 @@ include(../cmake/tools.cmake)
|
|||
|
||||
include(../cmake/CPM.cmake)
|
||||
|
||||
# Crow needs Boost 1.64 and does not provide CPM.cmake integration itself, so we have to get Boost first
|
||||
find_package(Boost 1.64 QUIET)
|
||||
if(NOT Boost_FOUND)
|
||||
# Use CPM.cmake to get Boost from the official repo if not provided as system lib
|
||||
message(STATUS "GreeterStandalone: Boost system lib NOT found")
|
||||
CPMAddPackage(
|
||||
NAME Boost
|
||||
GITHUB_REPOSITORY boostorg/boost
|
||||
GIT_TAG boost-1.78.0
|
||||
VERSION 1.78.0
|
||||
)
|
||||
# Ugly workaround:
|
||||
# Boost cmake support is still experimental, the Boost::boost target is not provided if downloaded via
|
||||
# FetchContent_declare / CPM.cmake
|
||||
# Crow uses it for asio, so we fake the Boost:boost target as asio
|
||||
if(NOT TARGET Boost::boost)
|
||||
add_library(Boost::boost INTERFACE IMPORTED)
|
||||
target_link_libraries(Boost::boost INTERFACE Boost::asio)
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "GreeterStandalone: Boost system lib found")
|
||||
endif()
|
||||
# add Crow
|
||||
CPMAddPackage(
|
||||
<<<<<<< HEAD
|
||||
GITHUB_REPOSITORY jarro2783/cxxopts
|
||||
VERSION 3.0.0
|
||||
OPTIONS "CXXOPTS_BUILD_EXAMPLES NO" "CXXOPTS_BUILD_TESTS NO" "CXXOPTS_ENABLE_INSTALL YES"
|
||||
=======
|
||||
NAME Crow
|
||||
GITHUB_REPOSITORY CrowCpp/Crow
|
||||
GIT_TAG v1.0+1
|
||||
VERSION 1.0.1
|
||||
OPTIONS "CROW_INSTALL OFF"
|
||||
>>>>>>> a42d7c5 (add boost, make boost work in docker)
|
||||
)
|
||||
|
||||
# get the Greeter lib
|
||||
CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||
|
||||
# ---- Create standalone executable ----
|
||||
|
@ -23,7 +59,5 @@ CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
|||
file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${sources})
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 OUTPUT_NAME "Greeter")
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} Greeter::Greeter cxxopts)
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Greeter::Greeter Crow::Crow)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue