From a7e1bc69f8a6bcf34b6573b49c0c56050d600992 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 27 Aug 2023 10:01:21 +0200 Subject: [PATCH 1/5] Try to use UNITY_BUILD With CMAKE_UNITY_BUILD there are build error with ftxui! Quickfix: don't build ftxui_sample if CMAKE_UNITY_BUILD is set. --- CMakeLists.txt | 2 +- CMakePresets.json | 9 ++++++++- ProjectOptions.cmake | 6 +++--- src/CMakeLists.txt | 4 +++- test/CMakeLists.txt | 20 +++++++++++--------- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5ac5435..212bb281 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.21) +cmake_minimum_required(VERSION 3.21...3.27) # This template attempts to be "fetch_content"-able # so that it works well with tools like CPM or other diff --git a/CMakePresets.json b/CMakePresets.json index 5871489e..9f16e253 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -50,6 +50,9 @@ "Darwin" ] }, + "cacheVariables": { + "CMAKE_UNITY_BUILD": true + }, "vendor": { "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" @@ -142,6 +145,8 @@ "description": "Target Unix-like OS with the gcc compiler, debug build type", "inherits": "conf-unixlike-common", "cacheVariables": { + "myproject_ENABLE_COVERAGE": false, + "CMAKE_SKIP_INSTALL_RULES": true, "CMAKE_C_COMPILER": "gcc", "CMAKE_CXX_COMPILER": "g++", "CMAKE_BUILD_TYPE": "Debug" @@ -164,6 +169,8 @@ "description": "Target Unix-like OS with the clang compiler, debug build type", "inherits": "conf-unixlike-common", "cacheVariables": { + "myproject_ENABLE_COVERAGE": false, + "CMAKE_SKIP_INSTALL_RULES": true, "CMAKE_C_COMPILER": "clang", "CMAKE_CXX_COMPILER": "clang++", "CMAKE_BUILD_TYPE": "Debug" @@ -251,4 +258,4 @@ "configurePreset": "unixlike-clang-release" } ] -} \ No newline at end of file +} diff --git a/ProjectOptions.cmake b/ProjectOptions.cmake index 3d260944..136a04af 100644 --- a/ProjectOptions.cmake +++ b/ProjectOptions.cmake @@ -89,9 +89,9 @@ macro(myproject_setup_options) option(myproject_ENABLE_SANITIZER_UNDEFINED "Enable undefined sanitizer" ${SUPPORTS_UBSAN}) option(myproject_ENABLE_SANITIZER_THREAD "Enable thread sanitizer" OFF) option(myproject_ENABLE_SANITIZER_MEMORY "Enable memory sanitizer" OFF) - option(myproject_ENABLE_UNITY_BUILD "Enable unity builds" OFF) - option(myproject_ENABLE_CLANG_TIDY "Enable clang-tidy" ON) - option(myproject_ENABLE_CPPCHECK "Enable cpp-check analysis" ON) + option(myproject_ENABLE_UNITY_BUILD "Enable unity builds" ON) + option(myproject_ENABLE_CLANG_TIDY "Enable clang-tidy" OFF) + option(myproject_ENABLE_CPPCHECK "Enable cpp-check analysis" OFF) option(myproject_ENABLE_PCH "Enable precompiled headers" OFF) option(myproject_ENABLE_CACHE "Enable ccache" ON) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f92a9d6..e35378d4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,2 +1,4 @@ add_subdirectory(sample_library) -add_subdirectory(ftxui_sample) +if(NOT CMAKE_UNITY_BUILD) + add_subdirectory(ftxui_sample) +endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 50f8e633..68cf88fb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15...3.23) +cmake_minimum_required(VERSION 3.21...3.27) project(CmakeConfigPackageTests LANGUAGES CXX) @@ -19,15 +19,17 @@ endif() include(${Catch2_SOURCE_DIR}/extras/Catch.cmake) -# Provide a simple smoke test to make sure that the CLI works and can display a --help message -add_test(NAME cli.has_help COMMAND intro --help) +if(TARGET intro) + # Provide a simple smoke test to make sure that the CLI works and can display a --help message + add_test(NAME cli.has_help COMMAND intro --help) -# Provide a test to verify that the version being reported from the application -# matches the version given to CMake. This will be important once you package -# your program. Real world shows that this is the kind of simple mistake that is easy -# to make, but also easy to test for. -add_test(NAME cli.version_matches COMMAND intro --version) -set_tests_properties(cli.version_matches PROPERTIES PASS_REGULAR_EXPRESSION "${PROJECT_VERSION}") + # Provide a test to verify that the version being reported from the application + # matches the version given to CMake. This will be important once you package + # your program. Real world shows that this is the kind of simple mistake that is easy + # to make, but also easy to test for. + add_test(NAME cli.version_matches COMMAND intro --version) + set_tests_properties(cli.version_matches PROPERTIES PASS_REGULAR_EXPRESSION "${PROJECT_VERSION}") +endif() add_executable(tests tests.cpp) target_link_libraries( From e784ea2f9b8ef37dbbeff2183213cf775f5f332c Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Wed, 20 Mar 2024 22:00:03 +0100 Subject: [PATCH 2/5] Restore quickfix after merge --- Dependencies.cmake | 2 +- src/CMakeLists.txt | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Dependencies.cmake b/Dependencies.cmake index e5008c4a..20b8de14 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -33,7 +33,7 @@ function(myproject_setup_dependencies) endif() if(NOT TARGET ftxui::screen) - cpmaddpackage("gh:ArthurSonzogni/FTXUI@6.0.2") + cpmaddpackage("gh:ArthurSonzogni/FTXUI@6.1.9") endif() if(NOT TARGET tools::tools) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e35378d4..0f92a9d6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,2 @@ add_subdirectory(sample_library) -if(NOT CMAKE_UNITY_BUILD) - add_subdirectory(ftxui_sample) -endif() +add_subdirectory(ftxui_sample) From c48af0aaae1aa1107cd632c0afcc39893a9828c0 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sat, 12 Jul 2025 21:22:21 +0200 Subject: [PATCH 3/5] Rebase and update packages used --- .clang-format | 8 +++++- CMakeLists.txt | 2 +- CMakePresets.json | 62 ++++++++++++++++++++++++++++++++++++++++++++- Dependencies.cmake | 4 +-- cmake/CPM.cmake | 4 +-- test/CMakeLists.txt | 8 ++++-- 6 files changed, 79 insertions(+), 9 deletions(-) diff --git a/.clang-format b/.clang-format index ffd5aa94..1a086d8e 100644 --- a/.clang-format +++ b/.clang-format @@ -1,3 +1,10 @@ +--- +BasedOnStyle: LLVM +Language: Json +IndentWidth: 4 +UseTab: Never +--- +Language: Cpp AccessModifierOffset: -2 AlignAfterOpenBracket: DontAlign AlignConsecutiveAssignments: false @@ -69,7 +76,6 @@ IndentWrappedFunctionNames: true JavaScriptQuotes: Leave JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: true -Language: Cpp MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 212bb281..6c749982 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.21...3.27) +cmake_minimum_required(VERSION 3.21...4.1) # This template attempts to be "fetch_content"-able # so that it works well with tools like CPM or other diff --git a/CMakePresets.json b/CMakePresets.json index 9f16e253..1bb46324 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -12,7 +12,19 @@ "hidden": true, "generator": "Ninja", "binaryDir": "${sourceDir}/out/build/${presetName}", - "installDir": "${sourceDir}/out/install/${presetName}" + "installDir": "${sourceDir}/out/install/${presetName}", + "cacheVariables": { + "CMAKE_PREFIX_PATH": { + "type": "path", + "value": "${sourceDir}/out/install/${presetName}" + }, + "CMAKE_CXX_EXTENSIONS": false, + "CMAKE_CXX_STANDARD": "23", + "CMAKE_CXX_STANDARD_REQUIRED": true, + "CMAKE_EXPORT_COMPILE_COMMANDS": true, + "CMAKE_MESSAGE_LOG_LEVEL": "TRACE", + "CMAKE_SKIP_TEST_ALL_DEPENDENCY": false + } }, { "name": "conf-windows-common", @@ -188,6 +200,54 @@ } } ], + "buildPresets":[ + { + "name": "build-common", + "description": "Build CMake settings that apply to all configurations", + "hidden": true, + "jobs": 4 + }, + { + "name": "build-windows-msvc-debug-developer-mode", + "inherits": "build-common", + "configurePreset": "windows-msvc-debug-developer-mode" + }, + { + "name": "build-windows-msvc-release-developer-mode", + "inherits": "build-common", + "configurePreset": "windows-msvc-release-developer-mode" + }, + { + "name": "build-windows-clang-debug", + "inherits": "build-common", + "configurePreset": "windows-clang-debug" + }, + { + "name": "build-windows-clang-release", + "inherits": "build-common", + "configurePreset": "windows-clang-release" + }, + { + "name": "build-unixlike-gcc-debug", + "inherits": "build-common", + "configurePreset": "unixlike-gcc-debug" + }, + { + "name": "build-unixlike-gcc-release", + "inherits": "build-common", + "configurePreset": "unixlike-gcc-release" + }, + { + "name": "build-unixlike-clang-debug", + "inherits": "build-common", + "configurePreset": "unixlike-clang-debug" + }, + { + "name": "build-unixlike-clang-release", + "inherits": "build-common", + "configurePreset": "unixlike-clang-release" + } + ], "testPresets": [ { "name": "test-common", diff --git a/Dependencies.cmake b/Dependencies.cmake index 20b8de14..dec189d2 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -9,7 +9,7 @@ function(myproject_setup_dependencies) # already been provided to us by a parent project if(NOT TARGET fmtlib::fmtlib) - cpmaddpackage("gh:fmtlib/fmt#11.1.4") + cpmaddpackage("gh:fmtlib/fmt#11.2.0") endif() if(NOT TARGET spdlog::spdlog) @@ -17,7 +17,7 @@ function(myproject_setup_dependencies) NAME spdlog VERSION - 1.15.2 + 1.15.3 GITHUB_REPOSITORY "gabime/spdlog" OPTIONS diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 9c27c51c..84748734 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -2,8 +2,8 @@ # # SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors -set(CPM_DOWNLOAD_VERSION 0.40.8) -set(CPM_HASH_SUM "78ba32abdf798bc616bab7c73aac32a17bbd7b06ad9e26a6add69de8f3ae4791") +set(CPM_DOWNLOAD_VERSION 0.42.0) +set(CPM_HASH_SUM "2020b4fc42dba44817983e06342e682ecfc3d2f484a581f11cc5731fbe4dce8a") if(CPM_SOURCE_CACHE) set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 68cf88fb..b197caf9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.21...3.27) +cmake_minimum_required(VERSION 3.21...4.1) project(CmakeConfigPackageTests LANGUAGES CXX) @@ -17,7 +17,11 @@ endif() # ---- Dependencies ---- -include(${Catch2_SOURCE_DIR}/extras/Catch.cmake) +if(Catch2_DIR) + include(${Catch2_DIR}/Catch.cmake) +else() + include(${Catch2_SOURCE_DIR}/extras/Catch.cmake) +endif() if(TARGET intro) # Provide a simple smoke test to make sure that the CLI works and can display a --help message From 0508115a658f51970386edeb15e89f78dfa89231 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Tue, 5 Sep 2023 18:09:35 +0200 Subject: [PATCH 4/5] Add CMake workflow presets clang-format -i *.json use CMAKE_UNITY_BUILD as default prevent clang-tidy as precompile step add ENABLE_DOXYGEN option --- CMakeLists.txt | 5 ++ CMakePresets.json | 150 +++++++++++++++++++++++++++++------- CMakeUserPresets.json | 171 ++++++++++++++++++++++++++++++++++++++++++ cmake/Doxygen.cmake | 2 +- test/CMakeLists.txt | 20 +++-- 5 files changed, 310 insertions(+), 38 deletions(-) create mode 100644 CMakeUserPresets.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c749982..bb48aeb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,11 @@ endif() # set the startup project for the "play" button in MSVC set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT intro) +if(ENABLE_DOXYGEN) + include(cmake/Doxygen.cmake) + myproject_enable_doxygen("") +endif() + if(CMAKE_SKIP_INSTALL_RULES) return() endif() diff --git a/CMakePresets.json b/CMakePresets.json index 1bb46324..6e5315f6 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,8 +1,8 @@ { - "version": 3, + "version": 6, "cmakeMinimumRequired": { "major": 3, - "minor": 21, + "minor": 25, "patch": 0 }, "configurePresets": [ @@ -28,7 +28,8 @@ }, { "name": "conf-windows-common", - "description": "Windows settings for MSBuild toolchain that apply to msvc and clang", + "description": + "Windows settings for MSBuild toolchain that apply to msvc and clang", "hidden": true, "inherits": "conf-common", "condition": { @@ -74,7 +75,8 @@ { "name": "windows-msvc-debug-developer-mode", "displayName": "msvc Debug (Developer Mode)", - "description": "Target Windows with the msvc compiler, debug build type", + "description": + "Target Windows with the msvc compiler, debug build type", "inherits": "conf-windows-common", "cacheVariables": { "CMAKE_C_COMPILER": "cl", @@ -86,7 +88,8 @@ { "name": "windows-msvc-release-developer-mode", "displayName": "msvc Release (Developer Mode)", - "description": "Target Windows with the msvc compiler, release build type", + "description": + "Target Windows with the msvc compiler, release build type", "inherits": "conf-windows-common", "cacheVariables": { "CMAKE_C_COMPILER": "cl", @@ -98,7 +101,8 @@ { "name": "windows-msvc-debug-user-mode", "displayName": "msvc Debug (User Mode)", - "description": "Target Windows with the msvc compiler, debug build type", + "description": + "Target Windows with the msvc compiler, debug build type", "inherits": "conf-windows-common", "cacheVariables": { "CMAKE_C_COMPILER": "cl", @@ -110,7 +114,8 @@ { "name": "windows-msvc-release-user-mode", "displayName": "msvc Release (User Mode)", - "description": "Target Windows with the msvc compiler, release build type", + "description": + "Target Windows with the msvc compiler, release build type", "inherits": "conf-windows-common", "cacheVariables": { "CMAKE_C_COMPILER": "cl", @@ -122,7 +127,8 @@ { "name": "windows-clang-debug", "displayName": "clang Debug", - "description": "Target Windows with the clang compiler, debug build type", + "description": + "Target Windows with the clang compiler, debug build type", "inherits": "conf-windows-common", "cacheVariables": { "CMAKE_C_COMPILER": "clang-cl", @@ -138,7 +144,8 @@ { "name": "windows-clang-release", "displayName": "clang Release", - "description": "Target Windows with the clang compiler, release build type", + "description": + "Target Windows with the clang compiler, release build type", "inherits": "conf-windows-common", "cacheVariables": { "CMAKE_C_COMPILER": "clang-cl", @@ -152,9 +159,10 @@ } }, { - "name": "unixlike-gcc-debug", + "name": "gcc-debug", "displayName": "gcc Debug", - "description": "Target Unix-like OS with the gcc compiler, debug build type", + "description": + "Target Unix-like OS with the gcc compiler, debug build type", "inherits": "conf-unixlike-common", "cacheVariables": { "myproject_ENABLE_COVERAGE": false, @@ -165,9 +173,10 @@ } }, { - "name": "unixlike-gcc-release", + "name": "gcc-release", "displayName": "gcc Release", - "description": "Target Unix-like OS with the gcc compiler, release build type", + "description": + "Target Unix-like OS with the gcc compiler, release build type", "inherits": "conf-unixlike-common", "cacheVariables": { "CMAKE_C_COMPILER": "gcc", @@ -176,9 +185,10 @@ } }, { - "name": "unixlike-clang-debug", + "name": "clang-debug", "displayName": "clang Debug", - "description": "Target Unix-like OS with the clang compiler, debug build type", + "description": + "Target Unix-like OS with the clang compiler, debug build type", "inherits": "conf-unixlike-common", "cacheVariables": { "myproject_ENABLE_COVERAGE": false, @@ -189,9 +199,10 @@ } }, { - "name": "unixlike-clang-release", + "name": "clang-release", "displayName": "clang Release", - "description": "Target Unix-like OS with the clang compiler, release build type", + "description": + "Target Unix-like OS with the clang compiler, release build type", "inherits": "conf-unixlike-common", "cacheVariables": { "CMAKE_C_COMPILER": "clang", @@ -251,7 +262,8 @@ "testPresets": [ { "name": "test-common", - "description": "Test CMake settings that apply to all configurations", + "description": + "Test CMake settings that apply to all configurations", "hidden": true, "output": { "outputOnFailure": true @@ -290,32 +302,118 @@ "configurePreset": "windows-clang-release" }, { - "name": "test-unixlike-gcc-debug", + "name": "gcc-debug", "displayName": "Strict", "description": "Enable output and stop on failure", "inherits": "test-common", - "configurePreset": "unixlike-gcc-debug" + "configurePreset": "gcc-debug" }, { - "name": "test-unixlike-gcc-release", + "name": "gcc-release", "displayName": "Strict", "description": "Enable output and stop on failure", "inherits": "test-common", - "configurePreset": "unixlike-gcc-release" + "configurePreset": "gcc-release" }, { - "name": "test-unixlike-clang-debug", + "name": "clang-debug", "displayName": "Strict", "description": "Enable output and stop on failure", "inherits": "test-common", - "configurePreset": "unixlike-clang-debug" + "configurePreset": "clang-debug" }, { - "name": "test-unixlike-clang-release", + "name": "clang-release", "displayName": "Strict", "description": "Enable output and stop on failure", "inherits": "test-common", - "configurePreset": "unixlike-clang-release" + "configurePreset": "clang-release" + } + ], + "buildPresets": [ + { + "name": "clang-release", + "configurePreset": "clang-release" + }, + { + "name": "clang-install", + "configurePreset": "clang-release", + "targets": [ + "install" + ] + }, + { + "name": "clang-debug", + "configurePreset": "clang-debug" + }, + { + "name": "gcc-release", + "configurePreset": "gcc-release" + }, + { + "name": "gcc-install", + "configurePreset": "gcc-release", + "targets": [ + "install" + ] + }, + { + "name": "gcc-debug", + "configurePreset": "gcc-debug" + } + ], + "packagePresets": [ + { + "name": "clang-release", + "configurePreset": "clang-release", + "generators": [ + "TGZ" + ] + }, + { + "name": "gcc-release", + "configurePreset": "gcc-release", + "generators": [ + "TGZ" + ] + } + ], + "workflowPresets": [ + { + "description": "Developer workflow without installation", + "name": "clang-debug", + "steps": [ + { + "type": "configure", + "name": "clang-debug" + }, + { + "type": "build", + "name": "clang-debug" + }, + { + "type": "test", + "name": "clang-debug" + } + ] + }, + { + "description": "Release workflow without test", + "name": "clang-release", + "steps": [ + { + "name": "clang-release", + "type": "configure" + }, + { + "name": "clang-release", + "type": "build" + }, + { + "name": "clang-release", + "type": "package" + } + ] } ] } diff --git a/CMakeUserPresets.json b/CMakeUserPresets.json new file mode 100644 index 00000000..78052ded --- /dev/null +++ b/CMakeUserPresets.json @@ -0,0 +1,171 @@ +{ + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 26, + "patch": 0 + }, + "configurePresets": [ + { + "name": "default-config", + "hidden": true, + "generator": "Ninja", + "cacheVariables": { + "CMAKE_HOST_SYSTEM_PROCESSOR": "$penv{PROCESSOR_ARCHITECTURE}" + } + }, + { + "name": "common-config", + "description": "Settings for all toolchains", + "hidden": true, + "inherits": "default-config", + "binaryDir": "${sourceDir}/out/build/${presetName}", + "installDir": "${sourceDir}/out/install/${presetName}", + "cacheVariables": { + "ENABLE_DOXYGEN": false, + "ENABLE_CPPCHECK": false, + "ENABLE_CLANG_TIDY": false + }, + "vendor": { + "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { + "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" + } + } + }, + { + "name": "debug", + "displayName": "Debug", + "description": "Debug build type", + "inherits": "conf-unixlike-common", + "cacheVariables": { + "CMAKE_SKIP_INSTALL_RULES": true, + "CMAKE_BUILD_TYPE": "Debug", + "myproject_ENABLE_COVERAGE": true + } + }, + { + "name": "release", + "displayName": "Release", + "description": "Release build type", + "inherits": "conf-unixlike-common", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "ENABLE_DOXYGEN": true + } + } + ], + "testPresets": [ + { + "name": "common-test", + "description": + "Test CMake settings that apply to all configurations", + "hidden": true, + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error", + "stopOnFailure": true + } + }, + { + "name": "debug", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "common-test", + "configuration": "Debug", + "configurePreset": "debug" + }, + { + "name": "release", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "common-test", + "configuration": "Release", + "configurePreset": "release" + } + ], + "buildPresets": [ + { + "name": "release", + "configurePreset": "release" + }, + { + "name": "install", + "configurePreset": "release", + "targets": [ + "install" + ] + }, + { + "name": "doxygen-docs", + "configurePreset": "release", + "targets": [ + "doxygen-docs" + ] + }, + { + "name": "debug", + "configurePreset": "debug" + } + ], + "packagePresets": [ + { + "name": "release", + "configurePreset": "release", + "generators": [ + "TGZ" + ] + } + ], + "workflowPresets": [ + { + "description": "Developer workflow without installation", + "name": "debug", + "steps": [ + { + "type": "configure", + "name": "debug" + }, + { + "type": "build", + "name": "debug" + }, + { + "type": "test", + "name": "debug" + } + ] + }, + { + "description": "Release workflow without test", + "name": "release", + "steps": [ + { + "name": "release", + "type": "configure" + }, + { + "name": "release", + "type": "build" + }, + { + "name": "release", + "type": "test" + }, + { + "name": "install", + "type": "build" + }, + { + "name": "doxygen-docs", + "type": "build" + }, + { + "name": "release", + "type": "package" + } + ] + } + ] +} diff --git a/cmake/Doxygen.cmake b/cmake/Doxygen.cmake index ed90c566..259f1891 100644 --- a/cmake/Doxygen.cmake +++ b/cmake/Doxygen.cmake @@ -49,6 +49,6 @@ function(myproject_enable_doxygen DOXYGEN_THEME) # add doxygen-docs target message(STATUS "Adding `doxygen-docs` target that builds the documentation.") - doxygen_add_docs(doxygen-docs ALL ${PROJECT_SOURCE_DIR} + doxygen_add_docs(doxygen-docs EXCLUDE_FROM_ALL ${PROJECT_SOURCE_DIR} COMMENT "Generating documentation - entry file: ${CMAKE_CURRENT_BINARY_DIR}/html/index.html") endfunction() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b197caf9..1a7d443c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -23,17 +23,15 @@ else() include(${Catch2_SOURCE_DIR}/extras/Catch.cmake) endif() -if(TARGET intro) - # Provide a simple smoke test to make sure that the CLI works and can display a --help message - add_test(NAME cli.has_help COMMAND intro --help) - - # Provide a test to verify that the version being reported from the application - # matches the version given to CMake. This will be important once you package - # your program. Real world shows that this is the kind of simple mistake that is easy - # to make, but also easy to test for. - add_test(NAME cli.version_matches COMMAND intro --version) - set_tests_properties(cli.version_matches PROPERTIES PASS_REGULAR_EXPRESSION "${PROJECT_VERSION}") -endif() +# Provide a simple smoke test to make sure that the CLI works and can display a --help message +add_test(NAME cli.has_help COMMAND intro --help) + +# Provide a test to verify that the version being reported from the application +# matches the version given to CMake. This will be important once you package +# your program. Real world shows that this is the kind of simple mistake that is easy +# to make, but also easy to test for. +add_test(NAME cli.version_matches COMMAND intro --version) +set_tests_properties(cli.version_matches PROPERTIES PASS_REGULAR_EXPRESSION "${PROJECT_VERSION}") add_executable(tests tests.cpp) target_link_libraries( From e11f7f87871d5b56d7e432ea16d0b2e293b95b1d Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 13 Jul 2025 10:33:17 +0200 Subject: [PATCH 5/5] Rebase with my develop --- CMakeLists.txt | 9 ++++-- CMakePresets.json | 68 +++++++++++++++---------------------------- CMakeUserPresets.json | 13 +++++++-- Dependencies.cmake | 14 +++++---- ProjectOptions.cmake | 5 ++-- src/CMakeLists.txt | 5 +++- test/CMakeLists.txt | 18 +++++++----- 7 files changed, 64 insertions(+), 68 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb48aeb4..34c2945c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ myproject_local_options() set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(GIT_SHA - "Unknown" + "0508115-dirty" CACHE STRING "SHA this build was generated from") string( SUBSTRING "${GIT_SHA}" @@ -92,7 +92,10 @@ if(MSVC) endif() # set the startup project for the "play" button in MSVC -set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT intro) +if(TARGET intro) + set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT intro) + set(VS_STARTUP_PROJECT intro) +endif() if(ENABLE_DOXYGEN) include(cmake/Doxygen.cmake) @@ -109,7 +112,7 @@ include(cmake/PackageProject.cmake) # we know we want to ship myproject_package_project( TARGETS - intro + ${VS_STARTUP_PROJECT} myproject_options myproject_warnings # FIXME: this does not work! CK diff --git a/CMakePresets.json b/CMakePresets.json index 6e5315f6..7a8f18fc 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -211,7 +211,7 @@ } } ], - "buildPresets":[ + "buildPresets": [ { "name": "build-common", "description": "Build CMake settings that apply to all configurations", @@ -239,24 +239,34 @@ "configurePreset": "windows-clang-release" }, { - "name": "build-unixlike-gcc-debug", - "inherits": "build-common", - "configurePreset": "unixlike-gcc-debug" + "name": "clang-release", + "configurePreset": "clang-release" }, { - "name": "build-unixlike-gcc-release", - "inherits": "build-common", - "configurePreset": "unixlike-gcc-release" + "name": "clang-install", + "configurePreset": "clang-release", + "targets": [ + "install" + ] }, { - "name": "build-unixlike-clang-debug", - "inherits": "build-common", - "configurePreset": "unixlike-clang-debug" + "name": "clang-debug", + "configurePreset": "clang-debug" }, { - "name": "build-unixlike-clang-release", - "inherits": "build-common", - "configurePreset": "unixlike-clang-release" + "name": "gcc-release", + "configurePreset": "gcc-release" + }, + { + "name": "gcc-install", + "configurePreset": "gcc-release", + "targets": [ + "install" + ] + }, + { + "name": "gcc-debug", + "configurePreset": "gcc-debug" } ], "testPresets": [ @@ -330,38 +340,6 @@ "configurePreset": "clang-release" } ], - "buildPresets": [ - { - "name": "clang-release", - "configurePreset": "clang-release" - }, - { - "name": "clang-install", - "configurePreset": "clang-release", - "targets": [ - "install" - ] - }, - { - "name": "clang-debug", - "configurePreset": "clang-debug" - }, - { - "name": "gcc-release", - "configurePreset": "gcc-release" - }, - { - "name": "gcc-install", - "configurePreset": "gcc-release", - "targets": [ - "install" - ] - }, - { - "name": "gcc-debug", - "configurePreset": "gcc-debug" - } - ], "packagePresets": [ { "name": "clang-release", diff --git a/CMakeUserPresets.json b/CMakeUserPresets.json index 78052ded..3d04a857 100644 --- a/CMakeUserPresets.json +++ b/CMakeUserPresets.json @@ -12,20 +12,27 @@ "generator": "Ninja", "cacheVariables": { "CMAKE_HOST_SYSTEM_PROCESSOR": "$penv{PROCESSOR_ARCHITECTURE}" + }, + "environment": { + "CPM_USE_LOCAL_PACKAGES": "1" } }, { "name": "common-config", "description": "Settings for all toolchains", "hidden": true, - "inherits": "default-config", + "inherits": ["conf-unixlike-common", "default-config"], "binaryDir": "${sourceDir}/out/build/${presetName}", "installDir": "${sourceDir}/out/install/${presetName}", "cacheVariables": { + "myproject_BUILD_FTXUI": false, "ENABLE_DOXYGEN": false, "ENABLE_CPPCHECK": false, "ENABLE_CLANG_TIDY": false }, + "environment": { + "CPM_USE_LOCAL_PACKAGES": "0" + }, "vendor": { "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" @@ -36,7 +43,7 @@ "name": "debug", "displayName": "Debug", "description": "Debug build type", - "inherits": "conf-unixlike-common", + "inherits": "common-config", "cacheVariables": { "CMAKE_SKIP_INSTALL_RULES": true, "CMAKE_BUILD_TYPE": "Debug", @@ -47,7 +54,7 @@ "name": "release", "displayName": "Release", "description": "Release build type", - "inherits": "conf-unixlike-common", + "inherits": "common-config", "cacheVariables": { "CMAKE_BUILD_TYPE": "Release", "ENABLE_DOXYGEN": true diff --git a/Dependencies.cmake b/Dependencies.cmake index dec189d2..d2a36221 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -28,12 +28,14 @@ function(myproject_setup_dependencies) cpmaddpackage("gh:catchorg/Catch2@3.8.1") endif() - if(NOT TARGET CLI11::CLI11) - cpmaddpackage("gh:CLIUtils/CLI11@2.5.0") - endif() - - if(NOT TARGET ftxui::screen) - cpmaddpackage("gh:ArthurSonzogni/FTXUI@6.1.9") + if(myproject_BUILD_FTXUI) + if(NOT TARGET CLI11::CLI11) + cpmaddpackage("gh:CLIUtils/CLI11@2.5.0") + endif() + + if(NOT TARGET ftxui::screen) + cpmaddpackage("gh:ArthurSonzogni/FTXUI@6.1.9") + endif() endif() if(NOT TARGET tools::tools) diff --git a/ProjectOptions.cmake b/ProjectOptions.cmake index 136a04af..fa57c522 100644 --- a/ProjectOptions.cmake +++ b/ProjectOptions.cmake @@ -122,6 +122,7 @@ macro(myproject_setup_options) endif() option(myproject_BUILD_FUZZ_TESTS "Enable fuzz testing executable" ${DEFAULT_FUZZER}) + option(myproject_BUILD_FTXUI "Build FTXUI sample too" ON) endmacro() @@ -135,7 +136,7 @@ macro(myproject_global_options) if(myproject_ENABLE_HARDENING AND myproject_ENABLE_GLOBAL_HARDENING) include(cmake/Hardening.cmake) - if(NOT SUPPORTS_UBSAN + if(NOT SUPPORTS_UBSAN OR myproject_ENABLE_SANITIZER_UNDEFINED OR myproject_ENABLE_SANITIZER_ADDRESS OR myproject_ENABLE_SANITIZER_THREAD @@ -221,7 +222,7 @@ macro(myproject_local_options) if(myproject_ENABLE_HARDENING AND NOT myproject_ENABLE_GLOBAL_HARDENING) include(cmake/Hardening.cmake) - if(NOT SUPPORTS_UBSAN + if(NOT SUPPORTS_UBSAN OR myproject_ENABLE_SANITIZER_UNDEFINED OR myproject_ENABLE_SANITIZER_ADDRESS OR myproject_ENABLE_SANITIZER_THREAD diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f92a9d6..b1a4cadc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,2 +1,5 @@ add_subdirectory(sample_library) -add_subdirectory(ftxui_sample) + +if(myproject_BUILD_FTXUI) + add_subdirectory(ftxui_sample) +endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1a7d443c..34c9ffa4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -24,14 +24,16 @@ else() endif() # Provide a simple smoke test to make sure that the CLI works and can display a --help message -add_test(NAME cli.has_help COMMAND intro --help) - -# Provide a test to verify that the version being reported from the application -# matches the version given to CMake. This will be important once you package -# your program. Real world shows that this is the kind of simple mistake that is easy -# to make, but also easy to test for. -add_test(NAME cli.version_matches COMMAND intro --version) -set_tests_properties(cli.version_matches PROPERTIES PASS_REGULAR_EXPRESSION "${PROJECT_VERSION}") +if(TARGET intro) + add_test(NAME cli.has_help COMMAND intro --help) + + # Provide a test to verify that the version being reported from the application + # matches the version given to CMake. This will be important once you package + # your program. Real world shows that this is the kind of simple mistake that is easy + # to make, but also easy to test for. + add_test(NAME cli.version_matches COMMAND intro --version) + set_tests_properties(cli.version_matches PROPERTIES PASS_REGULAR_EXPRESSION "${PROJECT_VERSION}") +endif() add_executable(tests tests.cpp) target_link_libraries(