mirror of
https://github.com/TheLartians/ModernCppStarter.git
synced 2025-08-31 22:21:13 +02:00
cleanup the sample
add only a build dependency (header only lib)
This commit is contained in:
parent
a4075a5534
commit
5f9aa807b9
5 changed files with 25 additions and 32 deletions
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.14...3.19 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.14...3.19)
|
||||||
|
|
||||||
# ---- Project ----
|
# ---- Project ----
|
||||||
|
|
||||||
|
@ -38,15 +38,11 @@ CPMAddPackage(
|
||||||
VERSION 1.4
|
VERSION 1.4
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(fmt 6)
|
CPMAddPackage(
|
||||||
if(NOT TARGET fmt::fmt-header-only)
|
NAME fmt
|
||||||
# FIXME this add a target without namespace! CK
|
GIT_TAG 7.1.3
|
||||||
CPMAddPackage(
|
GITHUB_REPOSITORY fmtlib/fmt
|
||||||
NAME fmt
|
)
|
||||||
GIT_TAG 7.1.3
|
|
||||||
GITHUB_REPOSITORY fmtlib/fmt
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# ---- Add source files ----
|
# ---- Add source files ----
|
||||||
|
|
||||||
|
@ -70,7 +66,7 @@ target_sources(Greeter PRIVATE ${headers} ${sources})
|
||||||
# FIXME target_compile_options(Greeter PUBLIC "$<$<BOOL:${MSVC}>:/permissive->")
|
# FIXME target_compile_options(Greeter PUBLIC "$<$<BOOL:${MSVC}>:/permissive->")
|
||||||
|
|
||||||
# Link dependencies (if required)
|
# Link dependencies (if required)
|
||||||
target_link_libraries(Greeter PUBLIC fmt::fmt)
|
target_link_libraries(Greeter PRIVATE fmt::fmt-header-only)
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
Greeter PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
Greeter PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||||
|
@ -92,5 +88,5 @@ packageProject(
|
||||||
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
|
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
|
||||||
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
|
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
|
||||||
VERSION_HEADER "${VERSION_HEADER_LOCATION}"
|
VERSION_HEADER "${VERSION_HEADER_LOCATION}"
|
||||||
DEPENDENCIES fmt
|
# XXX DEPENDENCIES fmt
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# this script adds all subprojects to a single build to allow IDEs understand the full project
|
# this script adds all subprojects to a single build to allow IDEs understand the full project
|
||||||
# structure.
|
# structure.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.14...3.19 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.14...3.19)
|
||||||
|
|
||||||
project(BuildAll LANGUAGES CXX)
|
project(BuildAll LANGUAGES CXX)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.14...3.19 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.14...3.19)
|
||||||
|
|
||||||
project(GreeterDocs)
|
project(GreeterDocs)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.14...3.19)
|
||||||
|
|
||||||
project(GreeterStandalone LANGUAGES CXX)
|
project(GreeterStandalone LANGUAGES CXX)
|
||||||
|
|
||||||
|
@ -21,10 +21,11 @@ CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||||
|
|
||||||
# ---- Create standalone executable ----
|
# ---- Create standalone executable ----
|
||||||
|
|
||||||
file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp)
|
file(GLOB sources CONFIGURE_DEPENDS source/*.cpp)
|
||||||
|
|
||||||
add_executable(GreeterStandalone ${sources})
|
add_executable(GreeterStandalone ${sources})
|
||||||
|
|
||||||
set_target_properties(GreeterStandalone PROPERTIES CXX_STANDARD 17 OUTPUT_NAME "Greeter")
|
# FIXME: WHY? CK
|
||||||
|
# set_target_properties(GreeterStandalone PROPERTIES CXX_STANDARD 17 OUTPUT_NAME "Greeter")
|
||||||
|
|
||||||
target_link_libraries(GreeterStandalone Greeter::Greeter cxxopts)
|
target_link_libraries(GreeterStandalone Greeter::Greeter cxxopts)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.14...3.19 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.14...3.19)
|
||||||
|
|
||||||
project(GreeterTests LANGUAGES CXX)
|
project(GreeterTests LANGUAGES CXX)
|
||||||
|
|
||||||
|
@ -15,15 +15,11 @@ include(../cmake/tools.cmake)
|
||||||
|
|
||||||
include(../cmake/CPM.cmake)
|
include(../cmake/CPM.cmake)
|
||||||
|
|
||||||
find_package(doctest)
|
CPMAddPackage(
|
||||||
if(NOT TARGET doctest::doctest)
|
NAME doctest
|
||||||
# FIXME this add a target without namespace! CK
|
GITHUB_REPOSITORY onqtam/doctest
|
||||||
CPMAddPackage(
|
GIT_TAG 2.3.7
|
||||||
NAME doctest
|
)
|
||||||
GITHUB_REPOSITORY onqtam/doctest
|
|
||||||
GIT_TAG 2.3.7
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(TEST_INSTALLED_VERSION)
|
if(TEST_INSTALLED_VERSION)
|
||||||
find_package(Greeter REQUIRED)
|
find_package(Greeter REQUIRED)
|
||||||
|
@ -49,10 +45,10 @@ target_compile_features(GreeterTests PUBLIC cxx_std_17)
|
||||||
# enable compiler warnings
|
# enable compiler warnings
|
||||||
if(NOT TEST_INSTALLED_VERSION)
|
if(NOT TEST_INSTALLED_VERSION)
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
target_compile_options(Greeter PUBLIC -Wall -pedantic -Wextra -Werror)
|
target_compile_options(Greeter PRIVATE -Wall -pedantic -Wextra -Werror)
|
||||||
elseif(MSVC)
|
elseif(MSVC)
|
||||||
target_compile_options(Greeter PUBLIC /W4 /WX)
|
target_compile_options(Greeter PRIVATE /W4 /WX)
|
||||||
target_compile_definitions(GreeterTests PUBLIC DOCTEST_CONFIG_USE_STD_HEADERS)
|
target_compile_definitions(GreeterTests PRIVATE DOCTEST_CONFIG_USE_STD_HEADERS)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -70,6 +66,6 @@ add_test(NAME GreeterTests COMMAND GreeterTests --success=false)
|
||||||
# ---- code coverage ----
|
# ---- code coverage ----
|
||||||
|
|
||||||
if(ENABLE_TEST_COVERAGE AND NOT TEST_INSTALLED_VERSION)
|
if(ENABLE_TEST_COVERAGE AND NOT TEST_INSTALLED_VERSION)
|
||||||
target_compile_options(Greeter PUBLIC -O0 -g -fprofile-arcs -ftest-coverage)
|
target_compile_options(Greeter PRIVATE -O0 -g -fprofile-arcs -ftest-coverage)
|
||||||
target_link_options(Greeter PUBLIC -fprofile-arcs -ftest-coverage)
|
target_link_options(Greeter PRIVATE -fprofile-arcs -ftest-coverage)
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue