mirror of
https://github.com/TheLartians/ModernCppStarter.git
synced 2025-09-03 07:30:53 +02:00
- Add CMake Workflow Presets
- Upgrade to gitup workflow action v3 - Prepare use of git-flow - Use CMake v3.21 variable PROJECT_IS_TOP_LEVEL - Use CMAKE_DEBUG_POSTFIX to prevent name clashes - Add more config files
This commit is contained in:
parent
fcbedfe9d8
commit
d81a42450c
22 changed files with 540 additions and 31 deletions
|
@ -1,7 +1,16 @@
|
|||
cmake_minimum_required(VERSION 3.14...3.27)
|
||||
cmake_minimum_required(VERSION 3.21...3.27)
|
||||
|
||||
project(GreeterStandalone LANGUAGES CXX)
|
||||
|
||||
if(PROJECT_IS_TOP_LEVEL AND CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set(CMAKE_SKIP_INSTALL_RULES
|
||||
NO
|
||||
CACHE BOOL "Forced generation of installation rules" FORCE
|
||||
)
|
||||
endif()
|
||||
|
||||
option(OPTION_ENABLE_UNITY "Enable Unity builds of project" ON)
|
||||
|
||||
# --- Import tools ----
|
||||
|
||||
include(../cmake/tools.cmake)
|
||||
|
@ -13,6 +22,7 @@ include(../cmake/CPM.cmake)
|
|||
CPMAddPackage(
|
||||
GITHUB_REPOSITORY jarro2783/cxxopts
|
||||
VERSION 3.1.1
|
||||
SYSTEM ON # used in case of cmake v3.25
|
||||
OPTIONS "CXXOPTS_BUILD_EXAMPLES NO" "CXXOPTS_BUILD_TESTS NO" "CXXOPTS_ENABLE_INSTALL YES"
|
||||
)
|
||||
|
||||
|
@ -27,8 +37,22 @@ CPMAddPackage(
|
|||
file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${sources})
|
||||
if(CMAKE_DEBUG_POSTFIX)
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
|
||||
endif()
|
||||
target_link_libraries(${PROJECT_NAME} Greeter::Greeter cxxopts::cxxopts)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD ${OPTION_ENABLE_UNITY})
|
||||
|
||||
# TODO(CK): why is this needed?
|
||||
# TODO(CK): why is this used? This overrides the CMAKE_DEBUG_POSTFIX!
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME Greeter)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} Greeter::Greeter cxxopts::cxxopts)
|
||||
# --- Test it ---
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --help)
|
||||
|
||||
# --- Install it ---
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} RUNTIME)
|
||||
|
||||
include(CPack)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue