mirror of
https://github.com/TheLartians/ModernCppStarter.git
synced 2025-09-01 06:30:52 +02:00
cleanup build files
use strict -std=c++20 update cmake-format config file
This commit is contained in:
parent
1aad14a6fa
commit
7f36b7cb86
12 changed files with 70 additions and 164 deletions
|
@ -5,10 +5,6 @@ format:
|
||||||
|
|
||||||
parse:
|
parse:
|
||||||
additional_commands:
|
additional_commands:
|
||||||
cpmdeclarepackage:
|
|
||||||
spelling: CPMDeclarePackage
|
|
||||||
cpmusepackagelock:
|
|
||||||
spelling: CPMUsePackageLock
|
|
||||||
cpmaddpackage:
|
cpmaddpackage:
|
||||||
pargs:
|
pargs:
|
||||||
nargs: '*'
|
nargs: '*'
|
||||||
|
@ -44,10 +40,16 @@ parse:
|
||||||
flags: []
|
flags: []
|
||||||
spelling: CPMFindPackage
|
spelling: CPMFindPackage
|
||||||
kwargs: *cpmaddpackagekwargs
|
kwargs: *cpmaddpackagekwargs
|
||||||
packageproject:
|
cpmdeclarepackage:
|
||||||
pargs:
|
pargs:
|
||||||
nargs: '*'
|
nargs: '*'
|
||||||
flags: []
|
flags: []
|
||||||
|
spelling: CPMDeclarePackage
|
||||||
|
kwargs: *cpmaddpackagekwargs
|
||||||
|
packageproject:
|
||||||
|
pargs:
|
||||||
|
nargs: '*'
|
||||||
|
flags: [NO_VERSION_SUFFIX]
|
||||||
spelling: packageProject
|
spelling: packageProject
|
||||||
kwargs:
|
kwargs:
|
||||||
NAME: 1
|
NAME: 1
|
||||||
|
@ -59,3 +61,12 @@ parse:
|
||||||
COMPATIBILITY: 1
|
COMPATIBILITY: 1
|
||||||
VERSION_HEADER: 1
|
VERSION_HEADER: 1
|
||||||
DEPENDENCIES: +
|
DEPENDENCIES: +
|
||||||
|
cpmusepackagelock:
|
||||||
|
pargs: 1
|
||||||
|
spelling: CPMUsePackageLock
|
||||||
|
cpmregisterpackage:
|
||||||
|
pargs: 1
|
||||||
|
spelling: CPMRegisterPackage
|
||||||
|
cpmgetpackageversion:
|
||||||
|
pargs: 2
|
||||||
|
spelling: CPMGetPackageVersion
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
||||||
root/
|
stagedir/
|
||||||
build/
|
build/
|
||||||
/build*
|
/build*
|
||||||
/.vscode
|
/.vscode
|
||||||
|
|
|
@ -20,6 +20,8 @@ endif()
|
||||||
|
|
||||||
# ---- Project settings ----
|
# ---- Project settings ----
|
||||||
|
|
||||||
|
option(BUILD_SHARED_LIBS "Create shared libraries if ON" OFF)
|
||||||
|
|
||||||
if(NOT DEFINED CMAKE_CXX_STANDARD)
|
if(NOT DEFINED CMAKE_CXX_STANDARD)
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
@ -60,11 +62,11 @@ file(GLOB_RECURSE sources CONFIGURE_DEPENDS source/*.cpp)
|
||||||
|
|
||||||
# Note: for header-only libraries change all PUBLIC flags to INTERFACE and create an interface
|
# Note: for header-only libraries change all PUBLIC flags to INTERFACE and create an interface
|
||||||
# target! EITHER: add_library(Greeter INTERFACE) OR:
|
# target! EITHER: add_library(Greeter INTERFACE) OR:
|
||||||
add_library(Greeter SHARED ${headers} ${sources})
|
add_library(Greeter ${headers} ${sources})
|
||||||
|
|
||||||
# EITHER:
|
# EITHER:
|
||||||
set_target_properties(Greeter PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDARD})
|
set_target_properties(Greeter PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDARD})
|
||||||
# OR: target_compile_features(Greeter PUBLIC cxx_std_17)
|
# OR: target_compile_features(Greeter PUBLIC cxx_std_20)
|
||||||
|
|
||||||
# being a cross-platform target, we enforce standards conformance on MSVC EITHER:
|
# being a cross-platform target, we enforce standards conformance on MSVC EITHER:
|
||||||
# target_compile_options(Greeter PUBLIC "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive>") OR:
|
# target_compile_options(Greeter PUBLIC "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive>") OR:
|
||||||
|
|
22
GNUmakefile
22
GNUmakefile
|
@ -1,8 +1,11 @@
|
||||||
#
|
#
|
||||||
# CURDIR=$(/bin/pwd)
|
# CURDIR=$(/bin/pwd)
|
||||||
#
|
# On UNIX one can use the DESTDIR mechanism in order to relocate the whole installation.
|
||||||
# GENERATOR="Unix Makefiles"
|
DESTDIR?=${CURDIR}/stagedir
|
||||||
GENERATOR=Ninja
|
export DESTDIR
|
||||||
|
|
||||||
|
# GENERATOR?="Unix Makefiles"
|
||||||
|
GENERATOR?=Ninja
|
||||||
|
|
||||||
export CPM_SOURCE_CACHE=${HOME}/.cache/CPM
|
export CPM_SOURCE_CACHE=${HOME}/.cache/CPM
|
||||||
export CPM_USE_LOCAL_PACKAGES=1
|
export CPM_USE_LOCAL_PACKAGES=1
|
||||||
|
@ -12,8 +15,11 @@ export CPM_USE_LOCAL_PACKAGES=1
|
||||||
# the default target does just all
|
# the default target does just all
|
||||||
all:
|
all:
|
||||||
|
|
||||||
|
clean:
|
||||||
|
find . -type d -name build | xargs rm -rf
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -rf build root
|
rm -rf build ${DESTDIR}
|
||||||
|
|
||||||
# update CPM.cmake
|
# update CPM.cmake
|
||||||
update:
|
update:
|
||||||
|
@ -27,18 +33,18 @@ lock: standalone all
|
||||||
|
|
||||||
# install the library
|
# install the library
|
||||||
install:
|
install:
|
||||||
cmake -S . -B build/install -G "${GENERATOR}" -DCMAKE_PREFIX_PATH=${CURDIR}/root -DCMAKE_INSTALL_PREFIX=${CURDIR}/root -DCMAKE_CXX_STANDARD=20 # --trace-expand
|
cmake -S . -B build/install -G "${GENERATOR}" -DCMAKE_PREFIX_PATH=${DESTDIR} # --trace-expand
|
||||||
cmake --build build/install --target install
|
cmake --build build/install --target install
|
||||||
|
|
||||||
# test the library
|
# test the library
|
||||||
test: install
|
test: install
|
||||||
cmake -S test -B build/test -G "${GENERATOR}" -DCMAKE_PREFIX_PATH=${CURDIR}/root -DTEST_INSTALLED_VERSION=1
|
cmake -S test -B build/test -G "${GENERATOR}" -DCMAKE_PREFIX_PATH=${DESTDIR} -DTEST_INSTALLED_VERSION=1
|
||||||
cmake --build build/test
|
cmake --build build/test
|
||||||
cmake --build build/test --target test
|
cmake --build build/test --target test
|
||||||
|
|
||||||
# all together
|
# all together
|
||||||
all: test
|
all: test
|
||||||
cmake -S all -B build/all -G "${GENERATOR}" -DCMAKE_PREFIX_PATH=${CURDIR}/root -DTEST_INSTALLED_VERSION=1 -DENABLE_TEST_COVERAGE=1
|
cmake -S all -B build/all -G "${GENERATOR}" -DCMAKE_PREFIX_PATH=${DESTDIR} -DTEST_INSTALLED_VERSION=1 -DENABLE_TEST_COVERAGE=1
|
||||||
cmake --build build/all
|
cmake --build build/all
|
||||||
cmake --build build/all --target test
|
cmake --build build/all --target test
|
||||||
cmake --build build/all --target GenerateDocs
|
cmake --build build/all --target GenerateDocs
|
||||||
|
@ -51,7 +57,7 @@ format: distclean
|
||||||
find . -name '*.h' | xargs clang-format -i
|
find . -name '*.h' | xargs clang-format -i
|
||||||
|
|
||||||
standalone:
|
standalone:
|
||||||
cmake -S standalone -B build/standalone -G "${GENERATOR}" -DCMAKE_PREFIX_PATH=${CURDIR}/root -DCMAKE_EXPORT_COMPILE_COMMANDS=1
|
cmake -S standalone -B build/standalone -G "${GENERATOR}" -DCMAKE_PREFIX_PATH=${DESTDIR} -DCMAKE_EXPORT_COMPILE_COMMANDS=1
|
||||||
cmake --build build/standalone --target all
|
cmake --build build/standalone --target all
|
||||||
|
|
||||||
# check the library
|
# check the library
|
||||||
|
|
|
@ -3,69 +3,17 @@
|
||||||
# Ccache.cmake
|
# Ccache.cmake
|
||||||
CPMDeclarePackage(
|
CPMDeclarePackage(
|
||||||
Ccache.cmake
|
Ccache.cmake
|
||||||
NAME
|
NAME Ccache.cmake
|
||||||
Ccache.cmake
|
VERSION 1.2.1
|
||||||
VERSION
|
GITHUB_REPOSITORY TheLartians/Ccache.cmake
|
||||||
1.2.1
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
TheLartians/Ccache.cmake
|
|
||||||
)
|
|
||||||
# cxxopts
|
|
||||||
CPMDeclarePackage(
|
|
||||||
cxxopts
|
|
||||||
NAME
|
|
||||||
cxxopts
|
|
||||||
VERSION
|
|
||||||
2.2.0
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
jarro2783/cxxopts
|
|
||||||
OPTIONS
|
|
||||||
"CXXOPTS_BUILD_EXAMPLES Off"
|
|
||||||
"CXXOPTS_BUILD_TESTS Off"
|
|
||||||
)
|
|
||||||
# Greeter (unversioned) CPMDeclarePackage(Greeter local directory ) PackageProject.cmake
|
|
||||||
CPMDeclarePackage(
|
|
||||||
PackageProject.cmake
|
|
||||||
NAME
|
|
||||||
PackageProject.cmake
|
|
||||||
VERSION
|
|
||||||
1.4.1
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
TheLartians/PackageProject.cmake
|
|
||||||
)
|
|
||||||
# fmt
|
|
||||||
CPMDeclarePackage(
|
|
||||||
fmt
|
|
||||||
NAME
|
|
||||||
fmt
|
|
||||||
GIT_TAG
|
|
||||||
7.1.3
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
fmtlib/fmt
|
|
||||||
OPTIONS
|
|
||||||
"FMT_INSTALL YES"
|
|
||||||
)
|
|
||||||
# doctest
|
|
||||||
CPMDeclarePackage(
|
|
||||||
doctest
|
|
||||||
NAME
|
|
||||||
doctest
|
|
||||||
GIT_TAG
|
|
||||||
2.4.5
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
onqtam/doctest
|
|
||||||
)
|
)
|
||||||
# Format.cmake
|
# Format.cmake
|
||||||
CPMDeclarePackage(
|
CPMDeclarePackage(
|
||||||
Format.cmake
|
Format.cmake
|
||||||
NAME
|
NAME Format.cmake
|
||||||
Format.cmake
|
VERSION 1.6
|
||||||
VERSION
|
GITHUB_REPOSITORY TheLartians/Format.cmake
|
||||||
1.6
|
OPTIONS "FORMAT_CHECK_CMAKE ON"
|
||||||
GITHUB_REPOSITORY
|
|
||||||
TheLartians/Format.cmake
|
|
||||||
OPTIONS
|
|
||||||
"FORMAT_CHECK_CMAKE ON"
|
|
||||||
)
|
)
|
||||||
# MCSS (unversioned) CPMDeclarePackage(MCSS NAME MCSS GIT_TAG
|
# MCSS (unversioned) CPMDeclarePackage(MCSS NAME MCSS GIT_TAG
|
||||||
# 42d4a9a48f31f5df6e246c948403b54b50574a2a DOWNLOAD_ONLY YES GITHUB_REPOSITORY mosra/m.css )
|
# 42d4a9a48f31f5df6e246c948403b54b50574a2a DOWNLOAD_ONLY YES GITHUB_REPOSITORY mosra/m.css )
|
||||||
|
|
|
@ -9,6 +9,12 @@ endif()
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
||||||
CPMUsePackageLock(package-lock.cmake)
|
CPMUsePackageLock(package-lock.cmake)
|
||||||
|
|
||||||
|
if(NOT DEFINED CMAKE_CXX_STANDARD)
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS NO)
|
||||||
|
endif()
|
||||||
|
|
||||||
# option: default not set
|
# option: default not set
|
||||||
set(USE_STATIC_ANALYZER
|
set(USE_STATIC_ANALYZER
|
||||||
""
|
""
|
||||||
|
|
|
@ -3,22 +3,7 @@
|
||||||
# PackageProject.cmake
|
# PackageProject.cmake
|
||||||
CPMDeclarePackage(
|
CPMDeclarePackage(
|
||||||
PackageProject.cmake
|
PackageProject.cmake
|
||||||
NAME
|
NAME PackageProject.cmake
|
||||||
PackageProject.cmake
|
VERSION 1.4.1
|
||||||
VERSION
|
GITHUB_REPOSITORY TheLartians/PackageProject.cmake
|
||||||
1.4.1
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
TheLartians/PackageProject.cmake
|
|
||||||
)
|
|
||||||
# fmt
|
|
||||||
CPMDeclarePackage(
|
|
||||||
fmt
|
|
||||||
NAME
|
|
||||||
fmt
|
|
||||||
GIT_TAG
|
|
||||||
7.1.3
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
fmtlib/fmt
|
|
||||||
OPTIONS
|
|
||||||
"FMT_INSTALL YES"
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,10 +26,12 @@ file(GLOB sources CONFIGURE_DEPENDS source/*.cpp)
|
||||||
|
|
||||||
add_executable(GreeterStandalone ${sources})
|
add_executable(GreeterStandalone ${sources})
|
||||||
|
|
||||||
# TODO: why rename in this way?
|
# TODO: why rename in this way? Seems only for CI with GitHub actions! CK
|
||||||
set_target_properties(GreeterStandalone PROPERTIES CXX_STANDARD 17 OUTPUT_NAME "Greeter")
|
set_target_properties(
|
||||||
|
GreeterStandalone PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDARD} OUTPUT_NAME "Greeter"
|
||||||
|
)
|
||||||
|
|
||||||
# WORKAROUND for ALIAS target is missing error! CK
|
# WORKAROUND missing ALIAS target error! CK
|
||||||
if(NOT TARGET cxxopts::cxxopts)
|
if(NOT TARGET cxxopts::cxxopts)
|
||||||
add_library(cxxopts::cxxopts ALIAS cxxopts)
|
add_library(cxxopts::cxxopts ALIAS cxxopts)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -3,45 +3,7 @@
|
||||||
# Ccache.cmake
|
# Ccache.cmake
|
||||||
CPMDeclarePackage(
|
CPMDeclarePackage(
|
||||||
Ccache.cmake
|
Ccache.cmake
|
||||||
NAME
|
NAME Ccache.cmake
|
||||||
Ccache.cmake
|
VERSION 1.2.1
|
||||||
VERSION
|
GITHUB_REPOSITORY TheLartians/Ccache.cmake
|
||||||
1.2.1
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
TheLartians/Ccache.cmake
|
|
||||||
)
|
|
||||||
# cxxopts
|
|
||||||
CPMDeclarePackage(
|
|
||||||
cxxopts
|
|
||||||
NAME
|
|
||||||
cxxopts
|
|
||||||
VERSION
|
|
||||||
2.2.0
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
jarro2783/cxxopts
|
|
||||||
OPTIONS
|
|
||||||
"CXXOPTS_BUILD_EXAMPLES Off"
|
|
||||||
"CXXOPTS_BUILD_TESTS Off"
|
|
||||||
)
|
|
||||||
# Greeter (unversioned) CPMDeclarePackage(Greeter local directory ) PackageProject.cmake
|
|
||||||
CPMDeclarePackage(
|
|
||||||
PackageProject.cmake
|
|
||||||
NAME
|
|
||||||
PackageProject.cmake
|
|
||||||
VERSION
|
|
||||||
1.4.1
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
TheLartians/PackageProject.cmake
|
|
||||||
)
|
|
||||||
# fmt
|
|
||||||
CPMDeclarePackage(
|
|
||||||
fmt
|
|
||||||
NAME
|
|
||||||
fmt
|
|
||||||
GIT_TAG
|
|
||||||
7.1.3
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
fmtlib/fmt
|
|
||||||
OPTIONS
|
|
||||||
"FMT_INSTALL YES"
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -41,8 +41,9 @@ CPMAddPackage(
|
||||||
file(GLOB sources CONFIGURE_DEPENDS source/*.cpp)
|
file(GLOB sources CONFIGURE_DEPENDS source/*.cpp)
|
||||||
add_executable(GreeterTests ${sources})
|
add_executable(GreeterTests ${sources})
|
||||||
target_link_libraries(GreeterTests doctest::doctest Greeter::Greeter)
|
target_link_libraries(GreeterTests doctest::doctest Greeter::Greeter)
|
||||||
|
# EITHER:
|
||||||
set_target_properties(GreeterTests PROPERTIES CXX_STANDARD 20)
|
set_target_properties(GreeterTests PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDARD})
|
||||||
|
# OR: target_compile_features(GreeterTests PUBLIC cxx_std_20)
|
||||||
|
|
||||||
# enable compiler warnings
|
# enable compiler warnings
|
||||||
if(NOT TEST_INSTALLED_VERSION)
|
if(NOT TEST_INSTALLED_VERSION)
|
||||||
|
|
|
@ -3,32 +3,15 @@
|
||||||
# Ccache.cmake
|
# Ccache.cmake
|
||||||
CPMDeclarePackage(
|
CPMDeclarePackage(
|
||||||
Ccache.cmake
|
Ccache.cmake
|
||||||
NAME
|
NAME Ccache.cmake
|
||||||
Ccache.cmake
|
VERSION 1.2.1
|
||||||
VERSION
|
GITHUB_REPOSITORY TheLartians/Ccache.cmake
|
||||||
1.2.1
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
TheLartians/Ccache.cmake
|
|
||||||
)
|
|
||||||
# doctest
|
|
||||||
CPMDeclarePackage(
|
|
||||||
doctest
|
|
||||||
NAME
|
|
||||||
doctest
|
|
||||||
GIT_TAG
|
|
||||||
2.4.5
|
|
||||||
GITHUB_REPOSITORY
|
|
||||||
onqtam/doctest
|
|
||||||
)
|
)
|
||||||
# Format.cmake
|
# Format.cmake
|
||||||
CPMDeclarePackage(
|
CPMDeclarePackage(
|
||||||
Format.cmake
|
Format.cmake
|
||||||
NAME
|
NAME Format.cmake
|
||||||
Format.cmake
|
VERSION 1.6
|
||||||
VERSION
|
GITHUB_REPOSITORY TheLartians/Format.cmake
|
||||||
1.6
|
OPTIONS "FORMAT_CHECK_CMAKE ON"
|
||||||
GITHUB_REPOSITORY
|
|
||||||
TheLartians/Format.cmake
|
|
||||||
OPTIONS
|
|
||||||
"FORMAT_CHECK_CMAKE ON"
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,7 +16,7 @@ TEST_CASE("Greeter") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Greeter version") {
|
TEST_CASE("Greeter version") {
|
||||||
#if (__cpp_lib_starts_ends_with)
|
#if ((__cplusplus >= 201907L) || __cpp_lib_starts_ends_with)
|
||||||
static_assert(std::string_view(GREETER_VERSION).starts_with("1.0")); // TBD C++20 only
|
static_assert(std::string_view(GREETER_VERSION).starts_with("1.0")); // TBD C++20 only
|
||||||
CHECK(std::string(GREETER_VERSION).starts_with("1.0")); // SameMajorVersion
|
CHECK(std::string(GREETER_VERSION).starts_with("1.0")); // SameMajorVersion
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue