1
0
Fork 0
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:
Claus Klein 2023-07-31 07:13:34 +02:00
parent fcbedfe9d8
commit d81a42450c
22 changed files with 540 additions and 31 deletions

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14...3.27)
cmake_minimum_required(VERSION 3.21...3.27)
# ---- Project ----
@ -18,18 +18,25 @@ if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
)
endif()
if(NOT PROJECT_IS_TOP_LEVEL)
option(CMAKE_SKIP_INSTALL_RULES "Whether to disable generation of installation rules" YES)
endif()
option(OPTION_ENABLE_UNITY "Enable Unity builds of project" ON)
# ---- Add dependencies via CPM ----
# see https://github.com/TheLartians/CPM.cmake for more info
include(cmake/CPM.cmake)
# PackageProject.cmake will be used to make our target installable
CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.8.0")
CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.10.0")
CPMAddPackage(
NAME fmt
GIT_TAG 9.1.0
GITHUB_REPOSITORY fmtlib/fmt
SYSTEM ON # used in case of cmake v3.25
OPTIONS "FMT_INSTALL YES" # create an installable target
)
@ -46,12 +53,15 @@ file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/
# target: add_library(${PROJECT_NAME} INTERFACE)
add_library(${PROJECT_NAME} ${headers} ${sources})
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD ${OPTION_ENABLE_UNITY})
# enable compiler warnings
include(cmake/WarningsAsErrors.cmake)
if(PROJECT_IS_TOP_LEVEL)
# enable compiler warnings
include(cmake/WarningsAsErrors.cmake)
# being a cross-platform target, we enforce standards conformance on MSVC
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->")
# being a cross-platform target, we enforce standards conformance on MSVC
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->")
endif()
# Link dependencies
target_link_libraries(${PROJECT_NAME} PUBLIC fmt::fmt)
@ -79,3 +89,5 @@ packageProject(
COMPATIBILITY SameMajorVersion
DEPENDENCIES "fmt 9.1.0"
)
include(CPack)