From 5e8801ba3c873943015ad8779007d8fc6b5a37f9 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jul 2022 02:01:38 -0700 Subject: [PATCH 01/43] fix: redirect the vcvarsall output into NUL --- src/VCEnvironment.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCEnvironment.cmake b/src/VCEnvironment.cmake index aea0b7d4..33dc3d25 100644 --- a/src/VCEnvironment.cmake +++ b/src/VCEnvironment.cmake @@ -115,7 +115,7 @@ macro(run_vcvarsall) message(STATUS "Running `${VCVARSALL_FILE} ${VCVARSALL_ARCH}` to set up the MSVC environment") execute_process( COMMAND - "cmd" "/c" ${VCVARSALL_FILE} ${VCVARSALL_ARCH} # + "cmd" "/c" "${VCVARSALL_FILE}" "${VCVARSALL_ARCH}" "1>NUL" # "&&" "call" "echo" "VCVARSALL_ENV_START" # "&" "set" # OUTPUT_VARIABLE VCVARSALL_OUTPUT From 2e9cdae2b40f6c0db3f477257a1b1c1f999b9f64 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jul 2022 02:01:58 -0700 Subject: [PATCH 02/43] fix: ignore the vcvarsall output if there is any error --- src/VCEnvironment.cmake | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/VCEnvironment.cmake b/src/VCEnvironment.cmake index 33dc3d25..0c8c6e84 100644 --- a/src/VCEnvironment.cmake +++ b/src/VCEnvironment.cmake @@ -119,13 +119,20 @@ macro(run_vcvarsall) "&&" "call" "echo" "VCVARSALL_ENV_START" # "&" "set" # OUTPUT_VARIABLE VCVARSALL_OUTPUT + ERROR_VARIABLE VCVARSALL_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE) - # parse the output and get the environment variables string - find_substring_by_prefix(VCVARSALL_ENV "VCVARSALL_ENV_START" "${VCVARSALL_OUTPUT}") + if("${VCVARSALL_ERROR}" STREQUAL "") + # parse the output and get the environment variables string + find_substring_by_prefix(VCVARSALL_ENV "VCVARSALL_ENV_START" "${VCVARSALL_OUTPUT}") + + # set the environment variables + set_env_from_string("${VCVARSALL_ENV}") + else() + message(WARNING "Failed to parse the vcvarsall output. ${VCVARSALL_ERROR}.\nIgnoring this error") + + endif() - # set the environment variables - set_env_from_string("${VCVARSALL_ENV}") else() message( WARNING From fbaa466dfab9cf06fffa3fdddbe7da4af8033817 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jul 2022 03:09:43 -0700 Subject: [PATCH 03/43] fix: make vcvarsall quiet --- src/VCEnvironment.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/VCEnvironment.cmake b/src/VCEnvironment.cmake index 0c8c6e84..e5559296 100644 --- a/src/VCEnvironment.cmake +++ b/src/VCEnvironment.cmake @@ -115,12 +115,13 @@ macro(run_vcvarsall) message(STATUS "Running `${VCVARSALL_FILE} ${VCVARSALL_ARCH}` to set up the MSVC environment") execute_process( COMMAND + "set" "VSCMD_DEBUG=0" "&&" # make vcvarsall quiet "cmd" "/c" "${VCVARSALL_FILE}" "${VCVARSALL_ARCH}" "1>NUL" # - "&&" "call" "echo" "VCVARSALL_ENV_START" # - "&" "set" # + "&&" "call" "echo" "VCVARSALL_ENV_START" # a starting point + "&" "set" # print the environment variables OUTPUT_VARIABLE VCVARSALL_OUTPUT ERROR_VARIABLE VCVARSALL_ERROR - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE) if("${VCVARSALL_ERROR}" STREQUAL "") # parse the output and get the environment variables string From 169e0dbf1fb9249678ad9a5b829d88031bb2e7cd Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jul 2022 03:10:02 -0700 Subject: [PATCH 04/43] fix: only run vcvarsall if VSCMD_VER is not defined --- src/VCEnvironment.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCEnvironment.cmake b/src/VCEnvironment.cmake index e5559296..d44328df 100644 --- a/src/VCEnvironment.cmake +++ b/src/VCEnvironment.cmake @@ -96,7 +96,7 @@ macro(run_vcvarsall) # if msvc_found is set by msvc_toolchain # or if MSVC but VSCMD_VER is not set, which means vcvarsall has not run - if(MSVC_FOUND OR (MSVC AND "$ENV{VSCMD_VER}" STREQUAL "")) + if((MSVC_FOUND OR MSVC) AND "$ENV{VSCMD_VER}" STREQUAL "") # find vcvarsall.bat get_filename_component(MSVC_DIR ${CMAKE_CXX_COMPILER} DIRECTORY) From 8b03a8c0203865fa0559e6b1f2844e93393b602e Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jul 2022 03:21:15 -0700 Subject: [PATCH 05/43] fix: set VSCMD_DEBUG using cmake --- src/VCEnvironment.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/VCEnvironment.cmake b/src/VCEnvironment.cmake index d44328df..9d0efa91 100644 --- a/src/VCEnvironment.cmake +++ b/src/VCEnvironment.cmake @@ -113,9 +113,13 @@ macro(run_vcvarsall) if(EXISTS ${VCVARSALL_FILE}) # run vcvarsall and print the environment variables message(STATUS "Running `${VCVARSALL_FILE} ${VCVARSALL_ARCH}` to set up the MSVC environment") + + # make vcvarsall quiet + set(VSCMD_DEBUG "$ENV{VSCMD_DEBUG}") + set($ENV{VSCMD_DEBUG} 0) + execute_process( COMMAND - "set" "VSCMD_DEBUG=0" "&&" # make vcvarsall quiet "cmd" "/c" "${VCVARSALL_FILE}" "${VCVARSALL_ARCH}" "1>NUL" # "&&" "call" "echo" "VCVARSALL_ENV_START" # a starting point "&" "set" # print the environment variables @@ -123,7 +127,9 @@ macro(run_vcvarsall) ERROR_VARIABLE VCVARSALL_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE) - if("${VCVARSALL_ERROR}" STREQUAL "") + # recover VSCMD_DEBUG variable + set($ENV{VSCMD_DEBUG} "${VSCMD_DEBUG}") + # parse the output and get the environment variables string find_substring_by_prefix(VCVARSALL_ENV "VCVARSALL_ENV_START" "${VCVARSALL_OUTPUT}") From 4c70e28c9d786fcdad32c5a377c55d12bae17575 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jul 2022 03:21:29 -0700 Subject: [PATCH 06/43] fix: check if VCVARSALL_OUTPUT is not empty before using it --- src/VCEnvironment.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/VCEnvironment.cmake b/src/VCEnvironment.cmake index 9d0efa91..52bf13b6 100644 --- a/src/VCEnvironment.cmake +++ b/src/VCEnvironment.cmake @@ -130,6 +130,11 @@ macro(run_vcvarsall) # recover VSCMD_DEBUG variable set($ENV{VSCMD_DEBUG} "${VSCMD_DEBUG}") + if("${VCVARSALL_ERROR}" STREQUAL "" + AND NOT + "${VCVARSALL_OUTPUT}" + STREQUAL + "") # parse the output and get the environment variables string find_substring_by_prefix(VCVARSALL_ENV "VCVARSALL_ENV_START" "${VCVARSALL_OUTPUT}") From 2b75259e54ec08e679787b457b81248faf7c79b4 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jul 2022 17:55:18 -0700 Subject: [PATCH 07/43] docs: add docs about target_disable_static_analysis [skip ci] --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 988aa012..14116b74 100644 --- a/README.md +++ b/README.md @@ -303,6 +303,21 @@ Other arguments that are automatically found and manually specifying them is not - `CONFIG_INSTALL_DESTINATION`: the destination for installation of the configuration files. Defaults to `${CMAKE_INSTALL_DATADIR}/${NAME}` +## Disabling static analysis for external targets: + +This function disables static analysis for the given target: + +```cmake +target_disable_static_analysis(some_external_target) +``` + +There is also individual functions to disable a specific analysis for the target: + +- `target_disable_cpp_check(target)` +- `target_disable_vs_analysis(target)` +- `target_disable_clang_tidy(target)` + + ## Changing the project_options dynamically During the test and development, it can be useful to change options on the fly. For example, to enable sanitizers when running tests. You can include `DynamicOptions.cmake`, which imports the `dynamic_project_options` function. From 5dc3e3965ccbb44870850eb1cf4c117d9b954c35 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jul 2022 17:57:02 -0700 Subject: [PATCH 08/43] chore: v0.23.0 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 14116b74..673844e2 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.22.4 +# Add project_options v0.23.0 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.22.4.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.23.0.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) @@ -350,11 +350,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.22.4 +# Add project_options v0.23.0 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.22.4.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.23.0.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) From ec6625c889700a6cda82cb4113e550878bf71620 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 15 Jul 2022 14:54:24 -0700 Subject: [PATCH 09/43] feat: add VCPKG_REV option for run_vcpkg This option allows checking out a specific branch name or a commit sha. If `VCPKG_REV` is set to a specific commit sha, the builds will become reproducible as that exact commit is always used for the builds. --- README.md | 4 ++++ src/Vcpkg.cmake | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 673844e2..5af43c7c 100644 --- a/README.md +++ b/README.md @@ -241,6 +241,7 @@ It gets the following named parameters that can have different values in front o Named Option: - `ENABLE_VCPKG_UPDATE`: (Disabled by default). If enabled, the vcpkg registry is updated before building (using `git pull`). As a result, if some of your vcpkg dependencies have been updated in the registry, they will be rebuilt. +Not that If `VCPKG_REV` is specified, updating the vcpkg registry will not trigger rebuilds. Named String: @@ -249,6 +250,9 @@ Named String: - `VCPKG_URL`: (Defaults to `https://github.com/microsoft/vcpkg.git`). This option allows setting the URL of the vcpkg repository. By default, the official vcpkg repository is used. +- `VCPKG_REV`: This option allows checking out a specific branch name or a commit sha. +If `VCPKG_REV` is set to a specific commit sha, the builds will become reproducible because that exact commit is always used for the builds. + ## `target_link_system_libraries` function A function that accepts the same arguments as `target_link_libraries`. It has the following features: diff --git a/src/Vcpkg.cmake b/src/Vcpkg.cmake index a83ab8b4..789f7fc2 100644 --- a/src/Vcpkg.cmake +++ b/src/Vcpkg.cmake @@ -4,10 +4,10 @@ include(FetchContent) # Install vcpkg and vcpkg dependencies: - should be called before defining project() macro(run_vcpkg) - # named boolean ENABLE_VCPKG_UPDATE argument + # named boolean ENABLE_VCPKG_UPDATE arguments set(options ENABLE_VCPKG_UPDATE) - # optional named VCPKG_DIR and VCPKG_URL argument - set(oneValueArgs VCPKG_DIR VCPKG_URL) + # optional named VCPKG_DIR, VCPKG_URL, and VCPKG_REV arguments + set(oneValueArgs VCPKG_DIR VCPKG_URL VCPKG_REV) cmake_parse_arguments( _vcpkg_args "${options}" @@ -63,6 +63,15 @@ macro(run_vcpkg) endif() endif() + if(NOT + "_vcpkg_args_VCPKG_REV" + STREQUAL + "") + find_program(GIT_EXECUTABLE "git" REQUIRED) + execute_process(COMMAND "${GIT_EXECUTABLE}" "checkout" "${_vcpkg_args_VCPKG_REV}" + WORKING_DIRECTORY ${VCPKG_PARENT_DIR} COMMAND_ERROR_IS_FATAL LAST) + endif() + configure_mingw_vcpkg() # Setting up vcpkg toolchain From 00ac0f5e13ee7d98287e4c2b11f6ff86cb0ba4f4 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 15 Jul 2022 15:13:07 -0700 Subject: [PATCH 10/43] fix: fix git chcekout for the specified rev + add docs --- README.md | 17 +++++++++++++++-- src/Vcpkg.cmake | 12 ++++++------ test/CMakeLists.txt | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5af43c7c..1be4415e 100644 --- a/README.md +++ b/README.md @@ -238,10 +238,23 @@ It gets the following named parameters that can have different values in front o ## `run_vcpkg` function +```cmake +run_vcpkg() +``` + +Or by specifying the options +```cmake +run_vcpkg( + VCPKG_URL "https://github.com/microsoft/vcpkg.git" + VCPKG_REV "33c8f025390f8682811629b6830d2d66ecedcaa5" + ENABLE_VCPKG_UPDATE +) +``` + Named Option: - `ENABLE_VCPKG_UPDATE`: (Disabled by default). If enabled, the vcpkg registry is updated before building (using `git pull`). As a result, if some of your vcpkg dependencies have been updated in the registry, they will be rebuilt. -Not that If `VCPKG_REV` is specified, updating the vcpkg registry will not trigger rebuilds. +Not that If `VCPKG_REV` is checked out after pulling the vcpkg repository. Named String: @@ -251,7 +264,7 @@ Named String: - `VCPKG_URL`: (Defaults to `https://github.com/microsoft/vcpkg.git`). This option allows setting the URL of the vcpkg repository. By default, the official vcpkg repository is used. - `VCPKG_REV`: This option allows checking out a specific branch name or a commit sha. -If `VCPKG_REV` is set to a specific commit sha, the builds will become reproducible because that exact commit is always used for the builds. +If `VCPKG_REV` is set to a specific commit sha, the builds will become reproducible because that exact commit is always used for the builds. To make sure that this commit sha is pulled, enable `ENABLE_VCPKG_UPDATE` ## `target_link_system_libraries` function diff --git a/src/Vcpkg.cmake b/src/Vcpkg.cmake index 789f7fc2..4c5f85d1 100644 --- a/src/Vcpkg.cmake +++ b/src/Vcpkg.cmake @@ -20,15 +20,15 @@ macro(run_vcpkg) STREQUAL "") # the installation directory is specified - get_filename_component(VCPKG_PARENT_DIR ${_vcpkg_args_VCPKG_DIR} DIRECTORY) + get_filename_component(VCPKG_PARENT_DIR "${_vcpkg_args_VCPKG_DIR}" DIRECTORY) else() # Default vcpkg installation directory if(WIN32) set(VCPKG_PARENT_DIR $ENV{userprofile}) - set(_vcpkg_args_VCPKG_DIR ${VCPKG_PARENT_DIR}/vcpkg) + set(_vcpkg_args_VCPKG_DIR "${VCPKG_PARENT_DIR}/vcpkg") else() set(VCPKG_PARENT_DIR $ENV{HOME}) - set(_vcpkg_args_VCPKG_DIR ${VCPKG_PARENT_DIR}/vcpkg) + set(_vcpkg_args_VCPKG_DIR "${VCPKG_PARENT_DIR}/vcpkg") endif() endif() @@ -40,7 +40,7 @@ macro(run_vcpkg) message(STATUS "vcpkg is already installed at ${_vcpkg_args_VCPKG_DIR}.") if(${_vcpkg_args_ENABLE_VCPKG_UPDATE}) message(STATUS "Updating the repository...") - execute_process(COMMAND "git" "pull" WORKING_DIRECTORY ${_vcpkg_args_VCPKG_DIR}) + execute_process(COMMAND "git" "pull" WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}") endif() else() message(STATUS "Installing vcpkg at ${_vcpkg_args_VCPKG_DIR}") @@ -51,7 +51,7 @@ macro(run_vcpkg) endif() find_program(GIT_EXECUTABLE "git" REQUIRED) execute_process(COMMAND "${GIT_EXECUTABLE}" "clone" "${_vcpkg_args_VCPKG_URL}" - WORKING_DIRECTORY ${VCPKG_PARENT_DIR} COMMAND_ERROR_IS_FATAL LAST) + WORKING_DIRECTORY "${VCPKG_PARENT_DIR}" COMMAND_ERROR_IS_FATAL LAST) endif() # Run vcpkg bootstrap if(WIN32) @@ -69,7 +69,7 @@ macro(run_vcpkg) "") find_program(GIT_EXECUTABLE "git" REQUIRED) execute_process(COMMAND "${GIT_EXECUTABLE}" "checkout" "${_vcpkg_args_VCPKG_REV}" - WORKING_DIRECTORY ${VCPKG_PARENT_DIR} COMMAND_ERROR_IS_FATAL LAST) + WORKING_DIRECTORY "${VCPKG_PARENT_DIR}/vcpkg" COMMAND_ERROR_IS_FATAL LAST) endif() configure_mingw_vcpkg() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c43767dc..7739dca5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -119,7 +119,7 @@ target_link_system_libraries( Eigen3::Eigen) target_link_system_libraries( lib2 - PRIVATE + PRIVATE mythirdpartylib) # package everything automatically From 5bc9eda2afcfe4c6d8bd407c9d5e6cfac0bec363 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 15 Jul 2022 15:20:35 -0700 Subject: [PATCH 11/43] fix: the variable reference + docs for relation with ENABLE_VCPKG_UPDATE --- README.md | 6 ++++-- src/Vcpkg.cmake | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1be4415e..df1441bd 100644 --- a/README.md +++ b/README.md @@ -253,8 +253,10 @@ run_vcpkg( Named Option: -- `ENABLE_VCPKG_UPDATE`: (Disabled by default). If enabled, the vcpkg registry is updated before building (using `git pull`). As a result, if some of your vcpkg dependencies have been updated in the registry, they will be rebuilt. -Not that If `VCPKG_REV` is checked out after pulling the vcpkg repository. +- `ENABLE_VCPKG_UPDATE`: (Disabled by default). If enabled, the vcpkg registry is updated before building (using `git pull`). + + If `VCPKG_REV` is set to a specific commit sha, no rebuilds are triggered. + If `VCPKG_REV` is not specified or is a branch, enabling `ENABLE_VCPKG_UPDATE` will rebuild your updated vcpkg dependencies. Named String: diff --git a/src/Vcpkg.cmake b/src/Vcpkg.cmake index 4c5f85d1..34b86218 100644 --- a/src/Vcpkg.cmake +++ b/src/Vcpkg.cmake @@ -64,7 +64,7 @@ macro(run_vcpkg) endif() if(NOT - "_vcpkg_args_VCPKG_REV" + "${_vcpkg_args_VCPKG_REV}" STREQUAL "") find_program(GIT_EXECUTABLE "git" REQUIRED) From 370900da1d9df08146c1690a2a2c978122979716 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 15 Jul 2022 15:35:44 -0700 Subject: [PATCH 12/43] chore: v0.24.0 [skip ci] --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index df1441bd..4d07e81f 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.23.0 +# Add project_options v0.24.0 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.23.0.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.24.0.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) @@ -369,11 +369,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.23.0 +# Add project_options v0.24.0 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.23.0.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.24.0.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) From 4cb508a5541c50b9bf70f94a21612c2e75b73817 Mon Sep 17 00:00:00 2001 From: Kushal-Chandar <83660514+Kushal-Chandar@users.noreply.github.com> Date: Thu, 21 Jul 2022 15:37:41 +0530 Subject: [PATCH 13/43] fix: typo in mingw.cmake changes copmiler to compiler --- src/MinGW.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MinGW.cmake b/src/MinGW.cmake index 09b0e6cf..11b06a62 100644 --- a/src/MinGW.cmake +++ b/src/MinGW.cmake @@ -18,7 +18,7 @@ function(is_mingw value) return() endif() - # if the copmiler is unknown by CMake + # if the compiler is unknown by CMake if(NOT CMAKE_CXX_COMPILER AND NOT CMAKE_C_COMPILER AND NOT CMAKE_CXX_COMPILER_ID From 453689595b5ae41a95ada98e3012c7c278a06f51 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Wed, 10 Aug 2022 22:03:56 +0200 Subject: [PATCH 14/43] install FILE_SET HEADERS too --- src/PackageProject.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PackageProject.cmake b/src/PackageProject.cmake index f272175c..f311f475 100644 --- a/src/PackageProject.cmake +++ b/src/PackageProject.cmake @@ -154,7 +154,9 @@ function(package_project) LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin - PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_PackageProject_NAME}" COMPONENT dev) + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_PackageProject_NAME}" COMPONENT dev + FILE_SET HEADERS # NOTE: requierd from CMake to install the FILE_SET HEADERS too! + ) # download ForwardArguments FetchContent_Declare( From fe12ff3c400b272c849bd813438dada983735804 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Wed, 10 Aug 2022 23:19:27 +0200 Subject: [PATCH 15/43] fix typo --- src/PackageProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PackageProject.cmake b/src/PackageProject.cmake index f311f475..a21b1104 100644 --- a/src/PackageProject.cmake +++ b/src/PackageProject.cmake @@ -155,7 +155,7 @@ function(package_project) ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_PackageProject_NAME}" COMPONENT dev - FILE_SET HEADERS # NOTE: requierd from CMake to install the FILE_SET HEADERS too! + FILE_SET HEADERS # NOTE: required from CMake to install the FILE_SET HEADERS too! ) # download ForwardArguments From 889e14e3ee554f37265baa107cf5c07c657dee26 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Wed, 10 Aug 2022 15:49:52 -0700 Subject: [PATCH 16/43] fix: pass FILE_SET only on cmake 3.23 and more --- src/PackageProject.cmake | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/PackageProject.cmake b/src/PackageProject.cmake index a21b1104..513424b9 100644 --- a/src/PackageProject.cmake +++ b/src/PackageProject.cmake @@ -148,15 +148,22 @@ function(package_project) # Installation of package (compatible with vcpkg, etc) set(_targets_list ${_PackageProject_TARGETS}) unset(_PackageProject_TARGETS) # to avoid ycm conflict + + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.23.0") + # required in CMake 3.23 and more + set(FILE_SET_ARGS "FILE_SET" "HEADERS") + endif() + install( TARGETS ${_targets_list} EXPORT ${_PackageProject_EXPORT} LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin - PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_PackageProject_NAME}" COMPONENT dev - FILE_SET HEADERS # NOTE: required from CMake to install the FILE_SET HEADERS too! - ) + PUBLIC_HEADER + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_PackageProject_NAME}" + COMPONENT dev + ${FILE_SET_ARGS}) # download ForwardArguments FetchContent_Declare( From 5e077f5f29a1be1dc09e5a937d56b1db39025cd4 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Wed, 10 Aug 2022 22:30:45 -0700 Subject: [PATCH 17/43] chore: v0.24.1 [skip ci] --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4d07e81f..d2a8ebfd 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.24.0 +# Add project_options v0.24.1 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.24.0.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.24.1.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) @@ -369,11 +369,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.24.0 +# Add project_options v0.24.1 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.24.0.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.24.1.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) From 0eb9b71ec6bc01d14a3b1f687039e3f34fcc93d9 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 4 Sep 2022 20:04:12 -0700 Subject: [PATCH 18/43] feat: support multi-project projects by adding PREFIX --- README.md | 1 + src/Index.cmake | 50 ++++++++++++++++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d2a8ebfd..1e7b1620 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,7 @@ It accepts the following named flags: It gets the following named parameters that can have different values in front of them: +- `PREFIX`: the optional prefix that is used to define `${PREFIX}_project_options` and `${PREFIX}_project_warnings` targets when the function is used in a multi-project fashion. - `DOXYGEN_THEME`: the name of the Doxygen theme to use. Supported themes: - `awesome-sidebar` (default) - `awesome` diff --git a/src/Index.cmake b/src/Index.cmake index 23fb5ba3..df032628 100644 --- a/src/Index.cmake +++ b/src/Index.cmake @@ -41,6 +41,7 @@ include("${ProjectOptions_SRC_DIR}/Vcpkg.cmake") # # Params: +# - PREFIX: the optional prefix to be prepended to the `project_options` and `project_warnings` targets when the function is used in a multi-project fashion. # - WARNINGS_AS_ERRORS: Treat compiler warnings as errors # - ENABLE_CPPCHECK: Enable static analysis with cppcheck # - ENABLE_CLANG_TIDY: Enable static analysis with clang-tidy @@ -94,7 +95,11 @@ macro(project_options) ENABLE_SANITIZER_UNDEFINED_BEHAVIOR ENABLE_SANITIZER_THREAD ENABLE_SANITIZER_MEMORY) - set(oneValueArgs LINKER VS_ANALYSIS_RULESET CONAN_PROFILE) + set(oneValueArgs + PREFIX + LINKER + VS_ANALYSIS_RULESET + CONAN_PROFILE) set(multiValueArgs DOXYGEN_THEME MSVC_WARNINGS @@ -121,8 +126,26 @@ macro(project_options) common_project_options() - # Link this 'library' to set the c++ standard / compile-time options requested - add_library(project_options INTERFACE) + # Add an interface library for the options + set(_options_target project_options) + set(_warnings_target project_warnings) + if(NOT + "${ProjectOptions_PREFIX}" + STREQUAL + "") + set(_options_target "${ProjectOptions_PREFIX}_project_options") + set(_warnings_target "${ProjectOptions_PREFIX}_project_warnings") + else() + if(TARGET project_options) + message( + FATAL + "Multiple calls to `project_options` in the same `project` detected, but the argument `PREFIX` that is prepended to `project_options` and `project_warnings` is not set." + ) + endif() + endif() + + add_library(${_options_target} INTERFACE) + add_library(${_warnings_target} INTERFACE) # fix mingw mingw_unicode() @@ -135,33 +158,30 @@ macro(project_options) set(ProjectOptions_ENABLE_INTERPROCEDURAL_OPTIMIZATION ${ProjectOptions_ENABLE_IPO}) endif() if(${ProjectOptions_ENABLE_INTERPROCEDURAL_OPTIMIZATION}) - enable_interprocedural_optimization(project_options) + enable_interprocedural_optimization(${_options_target}) endif() if(${ProjectOptions_ENABLE_NATIVE_OPTIMIZATION}) - enable_native_optimization(project_options) + enable_native_optimization(${_options_target}) endif() if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") if(ProjectOptions_ENABLE_BUILD_WITH_TIME_TRACE) - target_compile_options(project_options INTERFACE -ftime-trace) + target_compile_options(${_options_target} INTERFACE -ftime-trace) endif() endif() - # Link this 'library' to use the warnings specified in CompilerWarnings.cmake - add_library(project_warnings INTERFACE) - if(${ProjectOptions_ENABLE_CACHE}) # enable cache system enable_cache() endif() # use the linker - configure_linker(project_options "${ProjectOptions_LINKER}") + configure_linker(${_options_target} "${ProjectOptions_LINKER}") # standard compiler warnings set_project_warnings( - project_warnings + ${_warnings_target} "${WARNINGS_AS_ERRORS}" "${ProjectOptions_MSVC_WARNINGS}" "${ProjectOptions_CLANG_WARNINGS}" @@ -169,12 +189,12 @@ macro(project_options) "${ProjectOptions_CUDA_WARNINGS}") if(${ProjectOptions_ENABLE_COVERAGE}) - enable_coverage(project_options) + enable_coverage(${_options_target}) endif() # sanitizer options if supported by compiler enable_sanitizers( - project_options + ${_options_target} ${ProjectOptions_ENABLE_SANITIZER_ADDRESS} ${ProjectOptions_ENABLE_SANITIZER_LEAK} ${ProjectOptions_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR} @@ -211,7 +231,7 @@ macro(project_options) ) endif() - target_precompile_headers(project_options INTERFACE ${ProjectOptions_PCH_HEADERS}) + target_precompile_headers(${_options_target} INTERFACE ${ProjectOptions_PCH_HEADERS}) endif() if(${ProjectOptions_ENABLE_VCPKG}) @@ -224,7 +244,7 @@ macro(project_options) if(${ProjectOptions_ENABLE_UNITY}) # Add for any project you want to apply unity builds for - set_target_properties(project_options PROPERTIES UNITY_BUILD ON) + set_target_properties(${_options_target} PROPERTIES UNITY_BUILD ON) endif() endmacro() From c68025fd90b9276879c324271dc00cacba9a55a2 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 5 Sep 2022 15:48:59 -0700 Subject: [PATCH 19/43] chore: v0.25.0 [skip ci] --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1e7b1620..9cc80234 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.24.1 +# Add project_options v0.25.0 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.24.1.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.25.0.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) @@ -370,11 +370,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.24.1 +# Add project_options v0.25.0 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.24.1.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.25.0.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) From c675c4ce402fe2a2680b35969acc72ad80fa3304 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 11 Sep 2022 19:15:11 +0200 Subject: [PATCH 20/43] Warn about semicolon after in-class function definition --- src/CompilerWarnings.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CompilerWarnings.cmake b/src/CompilerWarnings.cmake index b4fb252a..db895867 100644 --- a/src/CompilerWarnings.cmake +++ b/src/CompilerWarnings.cmake @@ -44,6 +44,7 @@ function( set(CLANG_WARNINGS -Wall -Wextra # reasonable and standard + -Wextra-semi # Warn about semicolon after in-class function definition. -Wshadow # warn the user if a variable declaration shadows one from a parent context -Wnon-virtual-dtor # warn the user if a class with virtual functions has a non-virtual destructor. This helps # catch hard to track down memory errors From 70d5325813f7bcc6de1061777aa5be5d48b32ef5 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 13 Sep 2022 16:24:50 -0700 Subject: [PATCH 21/43] fix: switch back before pulling the vcpkg branch --- src/Vcpkg.cmake | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Vcpkg.cmake b/src/Vcpkg.cmake index 34b86218..d8660b38 100644 --- a/src/Vcpkg.cmake +++ b/src/Vcpkg.cmake @@ -39,6 +39,24 @@ macro(run_vcpkg) if(EXISTS "${_vcpkg_args_VCPKG_DIR}" AND EXISTS "${_vcpkg_args_VCPKG_DIR}/vcpkg${CMAKE_EXECUTABLE_SUFFIX}") message(STATUS "vcpkg is already installed at ${_vcpkg_args_VCPKG_DIR}.") if(${_vcpkg_args_ENABLE_VCPKG_UPDATE}) + + if(NOT + "${_vcpkg_args_VCPKG_REV}" + STREQUAL + "") + # detect if the head is detached, if so, switch back before calling git pull on a detached head + set(GIT_STATUS "") + execute_process( + COMMAND "git" "rev-parse" "--abbrev-ref" "--symbolic-full-name" "HEAD" + OUTPUT_VARIABLE GIT_STATUS + WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}" + OUTPUT_STRIP_TRAILING_WHITESPACE) + if("${GIT_STATUS}" STREQUAL "HEAD") + message(STATUS "Switching back before updating") + execute_process(COMMAND "git" "switch" "-" WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}") + endif() + endif() + message(STATUS "Updating the repository...") execute_process(COMMAND "git" "pull" WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}") endif() From ec9be4ae98789a6ccac1d9b4bb3b8177b558736a Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 13 Sep 2022 16:26:13 -0700 Subject: [PATCH 22/43] fix: find git before using vcpkg --- src/Vcpkg.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Vcpkg.cmake b/src/Vcpkg.cmake index d8660b38..f1b2c0d2 100644 --- a/src/Vcpkg.cmake +++ b/src/Vcpkg.cmake @@ -15,6 +15,8 @@ macro(run_vcpkg) "" ${ARGN}) + find_program(GIT_EXECUTABLE "git" REQUIRED) + if(NOT "${_vcpkg_args_VCPKG_DIR}" STREQUAL @@ -47,18 +49,18 @@ macro(run_vcpkg) # detect if the head is detached, if so, switch back before calling git pull on a detached head set(GIT_STATUS "") execute_process( - COMMAND "git" "rev-parse" "--abbrev-ref" "--symbolic-full-name" "HEAD" + COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--abbrev-ref" "--symbolic-full-name" "HEAD" OUTPUT_VARIABLE GIT_STATUS WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}" OUTPUT_STRIP_TRAILING_WHITESPACE) if("${GIT_STATUS}" STREQUAL "HEAD") message(STATUS "Switching back before updating") - execute_process(COMMAND "git" "switch" "-" WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}") + execute_process(COMMAND "${GIT_EXECUTABLE}" "switch" "-" WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}") endif() endif() message(STATUS "Updating the repository...") - execute_process(COMMAND "git" "pull" WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}") + execute_process(COMMAND "${GIT_EXECUTABLE}" "pull" WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}") endif() else() message(STATUS "Installing vcpkg at ${_vcpkg_args_VCPKG_DIR}") @@ -67,7 +69,6 @@ macro(run_vcpkg) if("${_vcpkg_args_VCPKG_URL}" STREQUAL "") set(_vcpkg_args_VCPKG_URL "https://github.com/microsoft/vcpkg.git") endif() - find_program(GIT_EXECUTABLE "git" REQUIRED) execute_process(COMMAND "${GIT_EXECUTABLE}" "clone" "${_vcpkg_args_VCPKG_URL}" WORKING_DIRECTORY "${VCPKG_PARENT_DIR}" COMMAND_ERROR_IS_FATAL LAST) endif() @@ -85,7 +86,6 @@ macro(run_vcpkg) "${_vcpkg_args_VCPKG_REV}" STREQUAL "") - find_program(GIT_EXECUTABLE "git" REQUIRED) execute_process(COMMAND "${GIT_EXECUTABLE}" "checkout" "${_vcpkg_args_VCPKG_REV}" WORKING_DIRECTORY "${VCPKG_PARENT_DIR}/vcpkg" COMMAND_ERROR_IS_FATAL LAST) endif() From 3fec6a607de24f64c28934c2349e2f5deccf409a Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 13 Sep 2022 17:24:48 -0700 Subject: [PATCH 23/43] chore: v0.25.1 [skip ci] --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9cc80234..a96fa4ce 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.25.0 +# Add project_options v0.25.1 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.25.0.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.25.1.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) @@ -370,11 +370,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.25.0 +# Add project_options v0.25.1 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.25.0.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.25.1.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) From 623b448aa767c57d819fcbec337eee3cfff65189 Mon Sep 17 00:00:00 2001 From: Francesco Cusolito Date: Wed, 14 Sep 2022 15:15:15 +0200 Subject: [PATCH 24/43] Forcing Conan build type to match CMake one Invoking Conan with `-s build_type=` parameter matching active CMake build type, or all the active ones if in multi-config scenario. This allows CMake to correctly build targets and link to correct Conan-insatlled dependencies. --- src/Conan.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Conan.cmake b/src/Conan.cmake index 9067a3eb..dcdf5e7c 100644 --- a/src/Conan.cmake +++ b/src/Conan.cmake @@ -69,7 +69,7 @@ macro(run_conan) set(CONAN_ENV ENV "CC=${CMAKE_C_COMPILER}" "CXX=${CMAKE_CXX_COMPILER}") else() # Derive all conan settings from a conan profile - set(CONAN_SETTINGS PROFILE ${ProjectOptions_CONAN_PROFILE}) + set(CONAN_SETTINGS PROFILE ${ProjectOptions_CONAN_PROFILE} SETTINGS "build_type=${TYPE}") # CONAN_ENV should be redundant, since the profile can set CC & CXX endif() From b8e29a98180dcd2df40ab7fa4fdf35bf9cdcdfc4 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Thu, 15 Sep 2022 14:24:29 +0200 Subject: [PATCH 25/43] prevent use of ProjectOptions_SRC_DIR as cache var --- src/Conan.cmake | 6 +++++- src/Index.cmake | 43 ++++++++++++++++++++------------------- src/StaticAnalyzers.cmake | 14 ++++++------- src/VCEnvironment.cmake | 2 +- 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/src/Conan.cmake b/src/Conan.cmake index dcdf5e7c..a8203476 100644 --- a/src/Conan.cmake +++ b/src/Conan.cmake @@ -69,7 +69,11 @@ macro(run_conan) set(CONAN_ENV ENV "CC=${CMAKE_C_COMPILER}" "CXX=${CMAKE_CXX_COMPILER}") else() # Derive all conan settings from a conan profile - set(CONAN_SETTINGS PROFILE ${ProjectOptions_CONAN_PROFILE} SETTINGS "build_type=${TYPE}") + set(CONAN_SETTINGS + PROFILE + ${ProjectOptions_CONAN_PROFILE} + SETTINGS + "build_type=${TYPE}") # CONAN_ENV should be redundant, since the profile can set CC & CXX endif() diff --git a/src/Index.cmake b/src/Index.cmake index df032628..a4d0516f 100644 --- a/src/Index.cmake +++ b/src/Index.cmake @@ -10,34 +10,35 @@ endif() include_guard() -set(ProjectOptions_SRC_DIR +set(ProjectOptions_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}) +set(ProjectOptions_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} - CACHE FILEPATH "") + PARENT_SCOPE) # include the files to allow calling individual functions (including the files does not run any code.) -include("${ProjectOptions_SRC_DIR}/Common.cmake") -include("${ProjectOptions_SRC_DIR}/Utilities.cmake") -include("${ProjectOptions_SRC_DIR}/Vcpkg.cmake") -include("${ProjectOptions_SRC_DIR}/SystemLink.cmake") -include("${ProjectOptions_SRC_DIR}/Cuda.cmake") -include("${ProjectOptions_SRC_DIR}/PackageProject.cmake") -include("${ProjectOptions_SRC_DIR}/Optimization.cmake") -include("${ProjectOptions_SRC_DIR}/Cache.cmake") -include("${ProjectOptions_SRC_DIR}/Linker.cmake") -include("${ProjectOptions_SRC_DIR}/CompilerWarnings.cmake") -include("${ProjectOptions_SRC_DIR}/Tests.cmake") -include("${ProjectOptions_SRC_DIR}/Sanitizers.cmake") -include("${ProjectOptions_SRC_DIR}/Doxygen.cmake") -include("${ProjectOptions_SRC_DIR}/StaticAnalyzers.cmake") -include("${ProjectOptions_SRC_DIR}/VCEnvironment.cmake") -include("${ProjectOptions_SRC_DIR}/MinGW.cmake") -include("${ProjectOptions_SRC_DIR}/DetectCompiler.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Common.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Utilities.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Vcpkg.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/SystemLink.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Cuda.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/PackageProject.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Optimization.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Cache.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Linker.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/CompilerWarnings.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Tests.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Sanitizers.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Doxygen.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/StaticAnalyzers.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/VCEnvironment.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/MinGW.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/DetectCompiler.cmake") # Include msvc toolchain on windows if the generator is not visual studio. Should be called before run_vcpkg and run_conan to be effective msvc_toolchain() -include("${ProjectOptions_SRC_DIR}/Conan.cmake") -include("${ProjectOptions_SRC_DIR}/Vcpkg.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Conan.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Vcpkg.cmake") # # Params: diff --git a/src/StaticAnalyzers.cmake b/src/StaticAnalyzers.cmake index 1f9f8103..b302f027 100644 --- a/src/StaticAnalyzers.cmake +++ b/src/StaticAnalyzers.cmake @@ -159,7 +159,6 @@ macro(enable_include_what_you_use) endif() endmacro() - # Disable clang-tidy for target macro(target_disable_clang_tidy TARGET) find_program(CLANGTIDY clang-tidy) @@ -183,17 +182,18 @@ macro(target_disable_vs_analysis TARGET) if(CMAKE_GENERATOR MATCHES "Visual Studio") set_target_properties( ${TARGET} - PROPERTIES - VS_GLOBAL_EnableMicrosoftCodeAnalysis false - VS_GLOBAL_CodeAnalysisRuleSet "" - VS_GLOBAL_EnableClangTidyCodeAnalysis "" - ) + PROPERTIES VS_GLOBAL_EnableMicrosoftCodeAnalysis false + VS_GLOBAL_CodeAnalysisRuleSet "" + VS_GLOBAL_EnableClangTidyCodeAnalysis "") endif() endmacro() # Disable static analysis for target macro(target_disable_static_analysis TARGET) - if(NOT CMAKE_GENERATOR MATCHES "Visual Studio") + if(NOT + CMAKE_GENERATOR + MATCHES + "Visual Studio") target_disable_clang_tidy(${TARGET}) target_disable_cpp_check(${TARGET}) endif() diff --git a/src/VCEnvironment.cmake b/src/VCEnvironment.cmake index 52bf13b6..86d39fa2 100644 --- a/src/VCEnvironment.cmake +++ b/src/VCEnvironment.cmake @@ -1,6 +1,6 @@ include_guard() -include("${ProjectOptions_SRC_DIR}/Utilities.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Utilities.cmake") # detect if the compiler is msvc function(is_msvc value) From eeafa0f04b117407fdf37ec5e7993334d223ca4a Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Thu, 15 Sep 2022 14:33:59 +0200 Subject: [PATCH 26/43] prevent double include of Vcpkg.cmake --- src/Index.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Index.cmake b/src/Index.cmake index a4d0516f..9ba75d26 100644 --- a/src/Index.cmake +++ b/src/Index.cmake @@ -18,7 +18,7 @@ set(ProjectOptions_SOURCE_DIR # include the files to allow calling individual functions (including the files does not run any code.) include("${CMAKE_CURRENT_LIST_DIR}/Common.cmake") include("${CMAKE_CURRENT_LIST_DIR}/Utilities.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/Vcpkg.cmake") +# see below! include("${CMAKE_CURRENT_LIST_DIR}/Vcpkg.cmake") include("${CMAKE_CURRENT_LIST_DIR}/SystemLink.cmake") include("${CMAKE_CURRENT_LIST_DIR}/Cuda.cmake") include("${CMAKE_CURRENT_LIST_DIR}/PackageProject.cmake") From 2e7682eab50f52d28c4c92249c09644fa7790898 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Fri, 16 Sep 2022 05:15:18 +0200 Subject: [PATCH 27/43] fix review items --- src/Index.cmake | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Index.cmake b/src/Index.cmake index 9ba75d26..71682f85 100644 --- a/src/Index.cmake +++ b/src/Index.cmake @@ -10,15 +10,13 @@ endif() include_guard() -set(ProjectOptions_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}) -set(ProjectOptions_SOURCE_DIR +set(ProjectOptions_SRC_DIR ${CMAKE_CURRENT_LIST_DIR} PARENT_SCOPE) # include the files to allow calling individual functions (including the files does not run any code.) include("${CMAKE_CURRENT_LIST_DIR}/Common.cmake") include("${CMAKE_CURRENT_LIST_DIR}/Utilities.cmake") -# see below! include("${CMAKE_CURRENT_LIST_DIR}/Vcpkg.cmake") include("${CMAKE_CURRENT_LIST_DIR}/SystemLink.cmake") include("${CMAKE_CURRENT_LIST_DIR}/Cuda.cmake") include("${CMAKE_CURRENT_LIST_DIR}/PackageProject.cmake") From fb45da6e1c432614928bec1ad7e1de11edb8736d Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Fri, 16 Sep 2022 05:26:31 +0200 Subject: [PATCH 28/43] fix scope of ProjectOptions_SRC_DIR --- src/Index.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Index.cmake b/src/Index.cmake index 71682f85..f350b436 100644 --- a/src/Index.cmake +++ b/src/Index.cmake @@ -10,9 +10,8 @@ endif() include_guard() -set(ProjectOptions_SRC_DIR - ${CMAKE_CURRENT_LIST_DIR} - PARENT_SCOPE) +# only useable here +set(ProjectOptions_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}) # include the files to allow calling individual functions (including the files does not run any code.) include("${CMAKE_CURRENT_LIST_DIR}/Common.cmake") From 1e967fe054672d82088dffce7e36483221af6091 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 18 Sep 2022 00:09:10 -0700 Subject: [PATCH 29/43] chore: v0.25.2 [skip ci] --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a96fa4ce..a25f6f84 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.25.1 +# Add project_options v0.25.2 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.25.1.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.25.2.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) @@ -370,11 +370,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.25.1 +# Add project_options v0.25.2 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.25.1.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.25.2.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) From 939d083e03f58396784f76efdc01cab2b936aa64 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 18 Sep 2022 20:26:16 -0700 Subject: [PATCH 30/43] docs: fix the option name Closes https://github.com/aminya/project_options/issues/155 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a25f6f84..ca7331fd 100644 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ It gets the following named parameters that can have different values in front o - `CLANG_WARNINGS`: Override the defaults for the CLANG warnings - `GCC_WARNINGS`: Override the defaults for the GCC warnings - `CUDA_WARNINGS`: Override the defaults for the CUDA warnings -- `CPPCHECK_WARNINGS`: Override the defaults for the options passed to cppcheck +- `CPPCHECK_OPTIONS`: Override the defaults for the options passed to cppcheck - `VS_ANALYSIS_RULESET`: Override the defaults for the code analysis rule set in Visual Studio. - `CONAN_OPTIONS`: Extra Conan options From 308b51d53f03f027e198f9b55125153d826456eb Mon Sep 17 00:00:00 2001 From: FeignClaims Date: Sat, 1 Oct 2022 21:55:07 +0800 Subject: [PATCH 31/43] fix: is_verbose function + Conan OUTPUT_QUIET --- src/Conan.cmake | 2 +- src/Utilities.cmake | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Conan.cmake b/src/Conan.cmake index a8203476..b27200b0 100644 --- a/src/Conan.cmake +++ b/src/Conan.cmake @@ -56,7 +56,7 @@ macro(run_conan) if(NOT ${_is_verbose}) set(OUTPUT_QUIET "OUTPUT_QUIET") else() - set(OUTPUT_QUIET OFF) + set(OUTPUT_QUIET) endif() foreach(TYPE ${LIST_OF_BUILD_TYPES}) diff --git a/src/Utilities.cmake b/src/Utilities.cmake index 7b3ef253..392d49ec 100644 --- a/src/Utilities.cmake +++ b/src/Utilities.cmake @@ -131,9 +131,9 @@ endmacro() # Is CMake verbose? function(is_verbose var) - if("CMAKE_MESSAGE_LOG_LEVEL" STREQUAL "VERBOSE" - OR "CMAKE_MESSAGE_LOG_LEVEL" STREQUAL "DEBUG" - OR "CMAKE_MESSAGE_LOG_LEVEL" STREQUAL "TRACE") + if("${CMAKE_MESSAGE_LOG_LEVEL}" STREQUAL "VERBOSE" + OR "${CMAKE_MESSAGE_LOG_LEVEL}" STREQUAL "DEBUG" + OR "${CMAKE_MESSAGE_LOG_LEVEL}" STREQUAL "TRACE") set(${var} ON PARENT_SCOPE) From ba7a32b59a8967eef1c7362a4cd00243e8c763be Mon Sep 17 00:00:00 2001 From: SK83RJOSH Date: Sat, 8 Oct 2022 12:37:56 +0200 Subject: [PATCH 32/43] Enable SYSTEM includes when supported on WIN32 --- src/SystemLink.cmake | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/SystemLink.cmake b/src/SystemLink.cmake index 73610f88..3fac675d 100644 --- a/src/SystemLink.cmake +++ b/src/SystemLink.cmake @@ -12,10 +12,8 @@ function(target_include_system_directories target) foreach(scope IN ITEMS INTERFACE PUBLIC PRIVATE) foreach(lib_include_dirs IN LISTS ARG_${scope}) - if(NOT MSVC) - # system includes do not work in MSVC - # awaiting https://gitlab.kitware.com/cmake/cmake/-/issues/18272# - # awaiting https://gitlab.kitware.com/cmake/cmake/-/issues/17904 + if(NOT MSVC OR (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "19.29.30036.3")) + # system includes do not work prior to CMake 3.24.0 and MSVC 19.29.30036.3 set(_SYSTEM SYSTEM) endif() if(${scope} STREQUAL "INTERFACE" OR ${scope} STREQUAL "PUBLIC") From 41a74035bd9183420a37123b8e4ecb694edce7b2 Mon Sep 17 00:00:00 2001 From: SK83RJOSH Date: Sat, 8 Oct 2022 12:34:12 +0200 Subject: [PATCH 33/43] ProjectOptions_SRC_DIR is now set correctly for submodules --- src/Common.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Common.cmake b/src/Common.cmake index 499992fb..3deb3c9d 100644 --- a/src/Common.cmake +++ b/src/Common.cmake @@ -1,7 +1,17 @@ include_guard() +# This function sets ProjectOptions_SRC_DIR using the current lists path +macro(set_project_options_src_dir) + get_directory_property(LISTFILE_STACK LISTFILE_STACK) + list(POP_BACK LISTFILE_STACK _LIST_FILE) + cmake_path(GET _LIST_FILE PARENT_PATH ProjectOptions_SRC_DIR) +endmacro() + # Common project settings run by default for all the projects that call `project_options()` macro(common_project_options) + set_project_options_src_dir() + message(DEBUG "${ProjectOptions_SRC_DIR}") + include("${ProjectOptions_SRC_DIR}/PreventInSourceBuilds.cmake") assure_out_of_source_builds() From 3290e5b55fed5e091368fed40dc2bef65c912d1c Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 14 Oct 2022 13:46:08 -0700 Subject: [PATCH 34/43] fix: require CMake 3.20 as the minimum version --- .github/workflows/ci.yml | 3 -- src/Index.cmake | 12 ++------ src/Optimization.cmake | 37 +++++++++-------------- src/PackageProject.cmake | 14 ++------- src/SystemLink.cmake | 3 +- test/CMakeLists.txt | 5 +-- test/include/mylib/lib.hpp | 12 ++++---- test/libs/mythirdpartylib/CMakeLists.txt | 11 ++----- test/libs/mythirdpartylib/include/Foo.hpp | 16 +++++----- test/libs/mythirdpartylib/src/Foo.cpp | 24 +++++++-------- test/src/main/main.cpp | 22 +++++++------- test/src/mylib2/lib.cpp | 14 ++++----- test_install/src/another_main.cpp | 4 +-- 13 files changed, 72 insertions(+), 105 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 070ee77c..4097e9ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,17 +31,14 @@ jobs: vcvarsall: true - os: "windows-2022" compiler: "msvc" - cmake: 3.18.0 cmake_generator: "Ninja" vcvarsall: true - os: "windows-2022" compiler: "msvc" - cmake: 3.18.0 cmake_generator: "Ninja" vcvarsall: false - os: "windows-2022" compiler: "msvc" - cmake: 3.18.0 vcvarsall: false steps: - uses: actions/checkout@v2 diff --git a/src/Index.cmake b/src/Index.cmake index f350b436..71c8f588 100644 --- a/src/Index.cmake +++ b/src/Index.cmake @@ -1,12 +1,6 @@ -if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0") - cmake_minimum_required(VERSION 3.18) -else() - cmake_minimum_required(VERSION 3.16) - message( - WARNING - "Consider upgrading CMake to the latest version. CMake ${CMAKE_VERSION} might fail in the linking stage because of missing references." - ) -endif() +cmake_minimum_required(VERSION 3.20) +# 3.20 is required by the windows toolchain and cmake_path. It also has a more reliable building functionality. +# 3.18 required by package_project and interprocedural optimization. It also has a more reliable building functionality (no errors during the linking stage). include_guard() diff --git a/src/Optimization.cmake b/src/Optimization.cmake index eac85a62..7b3991cf 100644 --- a/src/Optimization.cmake +++ b/src/Optimization.cmake @@ -1,29 +1,22 @@ include_guard() macro(enable_interprocedural_optimization project_name) - if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0") - if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - include(CheckIPOSupported) - check_ipo_supported(RESULT result OUTPUT output) - is_mingw(_is_mingw) - if(result AND NOT ${_is_mingw}) - # If a static library of this project is used in another project that does not have `CMAKE_INTERPROCEDURAL_OPTIMIZATION` enabled, a linker error might happen. - # TODO set this option in `package_project` function. - message( - STATUS - "Interprocedural optimization is enabled. In other projects, linking with the compiled libraries of this project might require `set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)`" - ) - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) - set_target_properties(${project_name} PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON) - else() - message(WARNING "Interprocedural Optimization is not supported. Not using it. Here is the error log: ${output}") - endif() + if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + include(CheckIPOSupported) + check_ipo_supported(RESULT result OUTPUT output) + is_mingw(_is_mingw) + if(result AND NOT ${_is_mingw}) + # If a static library of this project is used in another project that does not have `CMAKE_INTERPROCEDURAL_OPTIMIZATION` enabled, a linker error might happen. + # TODO set this option in `package_project` function. + message( + STATUS + "Interprocedural optimization is enabled. In other projects, linking with the compiled libraries of this project might require `set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)`" + ) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) + set_target_properties(${project_name} PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON) + else() + message(WARNING "Interprocedural Optimization is not supported. Not using it. Here is the error log: ${output}") endif() - else() - message( - WARNING - "Consider upgrading CMake to the latest version. CMake ${CMAKE_VERSION} does not support ENABLE_INTERPROCEDURAL_OPTIMIZATION." - ) endif() endmacro() diff --git a/src/PackageProject.cmake b/src/PackageProject.cmake index 513424b9..eb17bd4a 100644 --- a/src/PackageProject.cmake +++ b/src/PackageProject.cmake @@ -5,18 +5,8 @@ include_guard() # A function that packages the project for external usage (e.g. from vcpkg, Conan, etc). # See the [README.md] for more details function(package_project) - if(${CMAKE_VERSION} VERSION_LESS "3.18.0") - message( - WARNING - "Consider upgrading CMake to the latest version. CMake ${CMAKE_VERSION} does not support checking for policy CMP0103." - ) - else() - cmake_minimum_required(VERSION 3.18) - cmake_policy(SET CMP0103 NEW) # disallow multiple calls with the same NAME - endif() - - set(_options ARCH_INDEPENDENT # default to false - ) + # default to false + set(_options ARCH_INDEPENDENT) set(_oneValueArgs # default to the project_name: NAME diff --git a/src/SystemLink.cmake b/src/SystemLink.cmake index 3fac675d..62227f0d 100644 --- a/src/SystemLink.cmake +++ b/src/SystemLink.cmake @@ -12,7 +12,8 @@ function(target_include_system_directories target) foreach(scope IN ITEMS INTERFACE PUBLIC PRIVATE) foreach(lib_include_dirs IN LISTS ARG_${scope}) - if(NOT MSVC OR (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "19.29.30036.3")) + if(NOT MSVC OR (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL + "19.29.30036.3")) # system includes do not work prior to CMake 3.24.0 and MSVC 19.29.30036.3 set(_SYSTEM SYSTEM) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7739dca5..5c9f9820 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -117,10 +117,7 @@ target_link_system_libraries( PRIVATE fmt::fmt Eigen3::Eigen) -target_link_system_libraries( - lib2 - PRIVATE - mythirdpartylib) +target_link_system_libraries(lib2 PRIVATE mythirdpartylib) # package everything automatically package_project( diff --git a/test/include/mylib/lib.hpp b/test/include/mylib/lib.hpp index e808b290..6ecad59b 100644 --- a/test/include/mylib/lib.hpp +++ b/test/include/mylib/lib.hpp @@ -18,13 +18,13 @@ #include int some_fun() { - fmt::print("Hello from fmt{}", "!"); + fmt::print("Hello from fmt{}", "!"); - // populate an Eigen vector with the values - auto eigen_vec = Eigen::VectorXd::LinSpaced(10, 0, 1); + // populate an Eigen vector with the values + auto eigen_vec = Eigen::VectorXd::LinSpaced(10, 0, 1); - // print the vector - fmt::print("{}", eigen_vec); + // print the vector + fmt::print("{}", eigen_vec); - return 0; + return 0; } diff --git a/test/libs/mythirdpartylib/CMakeLists.txt b/test/libs/mythirdpartylib/CMakeLists.txt index ddc7e17b..d035dda3 100644 --- a/test/libs/mythirdpartylib/CMakeLists.txt +++ b/test/libs/mythirdpartylib/CMakeLists.txt @@ -1,11 +1,6 @@ - add_library(mythirdpartylib STATIC src/Foo.cpp) generate_export_header(mythirdpartylib) -target_include_directories(mythirdpartylib - PUBLIC $ - $ -) -target_include_directories(mythirdpartylib - PUBLIC $ -) \ No newline at end of file +target_include_directories(mythirdpartylib PUBLIC $ + $) +target_include_directories(mythirdpartylib PUBLIC $) diff --git a/test/libs/mythirdpartylib/include/Foo.hpp b/test/libs/mythirdpartylib/include/Foo.hpp index 24621a36..26aa7e0e 100644 --- a/test/libs/mythirdpartylib/include/Foo.hpp +++ b/test/libs/mythirdpartylib/include/Foo.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include "mythirdpartylib_export.h" @@ -9,17 +9,17 @@ namespace mythirdpartylib { class MYTHIRDPARTYLIB_EXPORT Foo { public: - Foo() = default; + Foo() = default; - /*implicit*/ Foo(int a) : m_a(a) {} + /*implicit*/ Foo(int a) : m_a(a) {} - int a() const { return m_a; } + int a() const { return m_a; } - void update(bool b, bool c, bool d); - void bad(std::vector& v); + void update(bool b, bool c, bool d); + void bad(std::vector &v); private: - int m_a; + int m_a; }; -} \ No newline at end of file +} // namespace mythirdpartylib \ No newline at end of file diff --git a/test/libs/mythirdpartylib/src/Foo.cpp b/test/libs/mythirdpartylib/src/Foo.cpp index f83ced37..9e777af4 100644 --- a/test/libs/mythirdpartylib/src/Foo.cpp +++ b/test/libs/mythirdpartylib/src/Foo.cpp @@ -3,22 +3,22 @@ namespace mythirdpartylib { void Foo::update(bool b, bool c, bool d) { - int e = b + d; - m_a = e; + int e = b + d; + m_a = e; } -void Foo::bad(std::vector& v) { - std::string val = "hello"; - int index = -1; // bad, plus should use gsl::index - for (int i = 0; i < v.size(); ++i) { - if (v[i] == val) { - index = i; - break; - } +void Foo::bad(std::vector &v) { + std::string val = "hello"; + int index = -1; // bad, plus should use gsl::index + for (int i = 0; i < v.size(); ++i) { + if (v[i] == val) { + index = i; + break; } + } } -static Foo foo (5); +static Foo foo(5); static Foo bar = 42; -} \ No newline at end of file +} // namespace mythirdpartylib \ No newline at end of file diff --git a/test/src/main/main.cpp b/test/src/main/main.cpp index 8493180a..3dc72141 100644 --- a/test/src/main/main.cpp +++ b/test/src/main/main.cpp @@ -16,20 +16,20 @@ #include int main() { - fmt::print("Hello from fmt{}", "!"); + fmt::print("Hello from fmt{}", "!"); - Eigen::VectorXd eigen_vec = Eigen::Vector3d(1, 2, 3); - fmt::print("{}", eigen_vec); + Eigen::VectorXd eigen_vec = Eigen::Vector3d(1, 2, 3); + fmt::print("{}", eigen_vec); -#if !defined(__MINGW32__) && !defined(__MSYS__)// TODO fails - Eigen::VectorXd eigen_vec2 = Eigen::VectorXd::LinSpaced(10, 0, 1); - fmt::print("{}", eigen_vec2); +#if !defined(__MINGW32__) && !defined(__MSYS__) // TODO fails + Eigen::VectorXd eigen_vec2 = Eigen::VectorXd::LinSpaced(10, 0, 1); + fmt::print("{}", eigen_vec2); #endif - // trigger address sanitizer - // int *p = nullptr; - // *p = 1; + // trigger address sanitizer + // int *p = nullptr; + // *p = 1; - // trigger compiler warnings, clang-tidy, and cppcheck - int a; + // trigger compiler warnings, clang-tidy, and cppcheck + int a; } diff --git a/test/src/mylib2/lib.cpp b/test/src/mylib2/lib.cpp index 41e4b510..38458dce 100644 --- a/test/src/mylib2/lib.cpp +++ b/test/src/mylib2/lib.cpp @@ -16,15 +16,15 @@ #include int some_fun2() { - fmt::print("Hello from fmt{}", "!"); + fmt::print("Hello from fmt{}", "!"); - Eigen::VectorXd eigen_vec = Eigen::Vector3d(1, 2, 3); - fmt::print("{}", eigen_vec); + Eigen::VectorXd eigen_vec = Eigen::Vector3d(1, 2, 3); + fmt::print("{}", eigen_vec); -#if !defined(__MINGW32__) && !defined(__MSYS__)// TODO fails - Eigen::VectorXd eigen_vec2 = Eigen::VectorXd::LinSpaced(10, 0, 1); - fmt::print("{}", eigen_vec2); +#if !defined(__MINGW32__) && !defined(__MSYS__) // TODO fails + Eigen::VectorXd eigen_vec2 = Eigen::VectorXd::LinSpaced(10, 0, 1); + fmt::print("{}", eigen_vec2); #endif - return 0; + return 0; } diff --git a/test_install/src/another_main.cpp b/test_install/src/another_main.cpp index 4b80c7b0..f14a6747 100644 --- a/test_install/src/another_main.cpp +++ b/test_install/src/another_main.cpp @@ -2,6 +2,6 @@ #include int main() { - some_fun2(); - return some_fun2(); + some_fun2(); + return some_fun2(); } \ No newline at end of file From ddb74b6f6c324fafe17750529ff68f320052e493 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 18 Oct 2022 18:07:09 -0700 Subject: [PATCH 35/43] fix: update the windows toolchain to v0.5.1 --- src/VCEnvironment.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VCEnvironment.cmake b/src/VCEnvironment.cmake index 86d39fa2..fb6928bf 100644 --- a/src/VCEnvironment.cmake +++ b/src/VCEnvironment.cmake @@ -64,10 +64,10 @@ macro(msvc_toolchain) is_msvc(_is_msvc) if(${_is_msvc}) # if msvc - message(STATUS "Using Windows MSVC toolchain") + message(STATUS "Using Windows Windows toolchain") include(FetchContent) FetchContent_Declare( - _msvc_toolchain URL "https://github.com/aminya/Toolchain/archive/95891a1e28a406ffb22e572f3ef24a7a8ad27ec0.zip") + _msvc_toolchain URL "https://github.com/MarkSchofield/WindowsToolchain/archive/refs/tags/v0.5.1.zip") FetchContent_MakeAvailable(_msvc_toolchain) include("${_msvc_toolchain_SOURCE_DIR}/Windows.MSVC.toolchain.cmake") message(STATUS "Setting CXX/C compiler to ${CMAKE_CXX_COMPILER}") From c0f69a12fd686bed1591e91e96a4ace85809feac Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 18 Oct 2022 22:22:56 -0700 Subject: [PATCH 36/43] chore: v0.26.0 --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ca7331fd..d6c73ac0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ A general-purpose CMake library that provides functions that improve the CMake experience. -It provides different functions such as `project_options`, `package_project`, `dynamic_project_options`, `run_vcpkg`, `target_link_system_libraries`, etc. +Provides different features such as `project_options`, `package_project`, `dynamic_project_options`, `run_vcpkg`, `target_link_system_libraries`, and it follows the best practices for C++/C/CMake. + +[![ci](https://github.com/aminya/project_options/actions/workflows/ci.yml/badge.svg)](https://github.com/aminya/project_options/actions/workflows/ci.yml) ## Usage @@ -17,11 +19,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.25.2 +# Add project_options v0.26.0 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.25.2.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.26.0.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) @@ -370,11 +372,11 @@ cmake_minimum_required(VERSION 3.16) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.25.2 +# Add project_options v0.26.0 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.25.2.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.26.0.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) From ffb1b59a59299a106d2cb07dd0bd9f6dbee8fc4b Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 18 Oct 2022 22:25:22 -0700 Subject: [PATCH 37/43] docs: update the readme minimum version [skip ci] --- README.md | 4 ++-- src/detect_compiler/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d6c73ac0..9675d68c 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ See `project_options()` in action in [this template repository](https://github.c Here is a full example: ```cmake -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.20) # set a default CXX standard for the tools and targets that do not specify them. # If commented, the latest supported standard for your compiler is automatically set. @@ -366,7 +366,7 @@ See `dynamic_project_options()` in action in [this template repository](https:// 👉 Click to show the example: ```cmake -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.20) # set a default CXX standard for the tools and targets that do not specify them. # If commented, the latest supported standard for your compiler is automatically set. diff --git a/src/detect_compiler/CMakeLists.txt b/src/detect_compiler/CMakeLists.txt index 693a767e..86853bdc 100644 --- a/src/detect_compiler/CMakeLists.txt +++ b/src/detect_compiler/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.20) enable_language(CXX) enable_language(C) From 5ddd23a747353e495a1750ec53a5c25469aa7456 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 22 Oct 2022 15:38:11 -0700 Subject: [PATCH 38/43] docs: improve the feature list [skip ci] --- README.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9675d68c..17ec41f6 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,27 @@ # project_options -A general-purpose CMake library that provides functions that improve the CMake experience. - -Provides different features such as `project_options`, `package_project`, `dynamic_project_options`, `run_vcpkg`, `target_link_system_libraries`, and it follows the best practices for C++/C/CMake. +A general-purpose CMake library that provides functions that improve the CMake experience following the best practices. + +## Features + +- `project_options`: + - compiler warnings, + - compiler optimizations (interprocedureal, native), + - caching (ccache), + - sanitizers, + - static code analyzers (clang-tidy, cppcheck, visual studio, iwwu), + - document generation (doxygen), + - test coverage analysis, + - precopmiled headers, + - build time measurement, + - unity builds + - using custom linkers (e.g. lld) +- `package_project`: automatic packaging/installation of the project for seamless usage via find_package/target_link through CMake's FetchContent, vcpkg, etc. +- `run_vcpkg`: automatic installation of vcpkg and the project dependencies +- `ENABLE_CONAN` in `project_options`: automatic installation of Conan and the project dependencies +- `dynamic_project_options`: a wrapper around `project_options` to change the options on the fly dynamically +- `target_link_system_libraries` and `target_include_system_directories`: linking/including external dependencies/headers without warnings +- `target_link_cuda`: linking Cuda to a target [![ci](https://github.com/aminya/project_options/actions/workflows/ci.yml/badge.svg)](https://github.com/aminya/project_options/actions/workflows/ci.yml) From 94c5579b28f33400f4b9080ff84d07654cd4ea41 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 23 Oct 2022 12:01:39 -0700 Subject: [PATCH 39/43] fix: update cmake-forward-arguments to v1.0.0 --- src/PackageProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PackageProject.cmake b/src/PackageProject.cmake index eb17bd4a..f06c9c93 100644 --- a/src/PackageProject.cmake +++ b/src/PackageProject.cmake @@ -158,7 +158,7 @@ function(package_project) # download ForwardArguments FetchContent_Declare( _fargs - URL https://github.com/polysquare/cmake-forward-arguments/archive/8c50d1f956172edb34e95efa52a2d5cb1f686ed2.zip) + URL https://github.com/polysquare/cmake-forward-arguments/archive/refs/tags/v1.0.0.zip) FetchContent_GetProperties(_fargs) if(NOT _fargs_POPULATED) FetchContent_Populate(_fargs) From 01b975a274401221e8f32574a88d7fb07aee076d Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 23 Oct 2022 15:09:44 -0700 Subject: [PATCH 40/43] docs: fix the typos in the readme [skip ci] --- README.md | 32 ++++++++++++++++---------------- cspell.config.yaml | 11 ++++------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 17ec41f6..fa2e5308 100644 --- a/README.md +++ b/README.md @@ -4,22 +4,22 @@ A general-purpose CMake library that provides functions that improve the CMake e ## Features -- `project_options`: - - compiler warnings, - - compiler optimizations (interprocedureal, native), - - caching (ccache), - - sanitizers, - - static code analyzers (clang-tidy, cppcheck, visual studio, iwwu), - - document generation (doxygen), - - test coverage analysis, - - precopmiled headers, - - build time measurement, - - unity builds - - using custom linkers (e.g. lld) -- `package_project`: automatic packaging/installation of the project for seamless usage via find_package/target_link through CMake's FetchContent, vcpkg, etc. +- `project_options`: + - compiler warnings, + - compiler optimizations (intraprocedural, native), + - caching (ccache), + - sanitizers, + - static code analyzers (clang-tidy, cppcheck, visual studio, iwwu), + - document generation (doxygen), + - test coverage analysis, + - precompiled headers, + - build time measurement, + - unity builds + - using custom linkers (e.g. lld) +- `package_project`: automatic packaging/installation of the project for seamless usage via find_package/target_link through CMake's FetchContent, vcpkg, etc. - `run_vcpkg`: automatic installation of vcpkg and the project dependencies - `ENABLE_CONAN` in `project_options`: automatic installation of Conan and the project dependencies -- `dynamic_project_options`: a wrapper around `project_options` to change the options on the fly dynamically +- `dynamic_project_options`: a wrapper around `project_options` to change the options on the fly dynamically - `target_link_system_libraries` and `target_include_system_directories`: linking/including external dependencies/headers without warnings - `target_link_cuda`: linking Cuda to a target @@ -265,6 +265,7 @@ run_vcpkg() ``` Or by specifying the options + ```cmake run_vcpkg( VCPKG_URL "https://github.com/microsoft/vcpkg.git" @@ -344,7 +345,7 @@ Other arguments that are automatically found and manually specifying them is not - `CONFIG_INSTALL_DESTINATION`: the destination for installation of the configuration files. Defaults to `${CMAKE_INSTALL_DATADIR}/${NAME}` -## Disabling static analysis for external targets: +## Disabling static analysis for external targets This function disables static analysis for the given target: @@ -358,7 +359,6 @@ There is also individual functions to disable a specific analysis for the target - `target_disable_vs_analysis(target)` - `target_disable_clang_tidy(target)` - ## Changing the project_options dynamically During the test and development, it can be useful to change options on the fly. For example, to enable sanitizers when running tests. You can include `DynamicOptions.cmake`, which imports the `dynamic_project_options` function. diff --git a/cspell.config.yaml b/cspell.config.yaml index 0aa60cb0..d3fe0b48 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -22,12 +22,14 @@ words: - ccmake - choco - cmake + - CMAKE - cmakelint - cmds - cond - CPATH - Cppcheck - cppcoreguidelines + - cppdbg - CPPFLAGS - cpprc - ctest @@ -45,6 +47,7 @@ words: - gcovr - Graphviz - hwrap + - iwwu - kcov - LDFLAGS - libc @@ -62,6 +65,7 @@ words: - myprogram - myproj - myproject + - mythirdpartylib - nothrow - nvcc - Opencppcoverage @@ -104,10 +108,3 @@ words: - Wuseless - xcrun - Yahyaabadi - - "ARGN" - - "CMAKE" - - "fargs" - - "shlib" - - "vcpkg" - - cppdbg - - mythirdpartylib From dab87c561eb1c4d6adbc5cce2909ced5015ce877 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 24 Oct 2022 12:02:19 -0700 Subject: [PATCH 41/43] docs: add sccache to the readme [skip ci] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fa2e5308..76ad7171 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ A general-purpose CMake library that provides functions that improve the CMake e - `project_options`: - compiler warnings, - compiler optimizations (intraprocedural, native), - - caching (ccache), + - caching (ccache, sccache), - sanitizers, - - static code analyzers (clang-tidy, cppcheck, visual studio, iwwu), + - static code analyzers (clang-tidy, cppcheck, visual studio, include-what-you-use), - document generation (doxygen), - test coverage analysis, - precompiled headers, From 8a47da668e8730b285e411e6b964509a5b6b1452 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 27 Oct 2022 18:49:42 -0700 Subject: [PATCH 42/43] fix: ensure that the given vcpkg remote is the current remote --- src/Vcpkg.cmake | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Vcpkg.cmake b/src/Vcpkg.cmake index f1b2c0d2..4f689c29 100644 --- a/src/Vcpkg.cmake +++ b/src/Vcpkg.cmake @@ -47,13 +47,13 @@ macro(run_vcpkg) STREQUAL "") # detect if the head is detached, if so, switch back before calling git pull on a detached head - set(GIT_STATUS "") + set(_vcpkg_git_status "") execute_process( COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--abbrev-ref" "--symbolic-full-name" "HEAD" - OUTPUT_VARIABLE GIT_STATUS + OUTPUT_VARIABLE _vcpkg_git_status WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}" OUTPUT_STRIP_TRAILING_WHITESPACE) - if("${GIT_STATUS}" STREQUAL "HEAD") + if("${_vcpkg_git_status}" STREQUAL "HEAD") message(STATUS "Switching back before updating") execute_process(COMMAND "${GIT_EXECUTABLE}" "switch" "-" WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}") endif() @@ -65,12 +65,24 @@ macro(run_vcpkg) else() message(STATUS "Installing vcpkg at ${_vcpkg_args_VCPKG_DIR}") # clone vcpkg from Github + if("${_vcpkg_args_VCPKG_URL}" STREQUAL "") + set(_vcpkg_args_VCPKG_URL "https://github.com/microsoft/vcpkg.git") + endif() if(NOT EXISTS "${_vcpkg_args_VCPKG_DIR}") - if("${_vcpkg_args_VCPKG_URL}" STREQUAL "") - set(_vcpkg_args_VCPKG_URL "https://github.com/microsoft/vcpkg.git") - endif() execute_process(COMMAND "${GIT_EXECUTABLE}" "clone" "${_vcpkg_args_VCPKG_URL}" WORKING_DIRECTORY "${VCPKG_PARENT_DIR}" COMMAND_ERROR_IS_FATAL LAST) + else() + # ensure that the given vcpkg remote is the current remote + execute_process( + COMMAND "${GIT_EXECUTABLE}" "remote" "-v" + WORKING_DIRECTORY "${VCPKG_PARENT_DIR}" COMMAND_ERROR_IS_FATAL LAST + OUTPUT_VARIABLE _vcpkg_git_remote_info) + string(FIND "${_vcpkg_git_remote_info}" "${_vcpkg_args_VCPKG_URL}" _vcpkg_has_remote) + if(NOT ${_vcpkg_has_remote}) + message( + FATAL + "The current vcpkg remote at ${_vcpkg_args_VCPKG_DIR} does not match the given URL ${_vcpkg_args_VCPKG_URL}") + endif() endif() # Run vcpkg bootstrap if(WIN32) From 0a757c1f1a1999358afcad21d8dd8bba1245c691 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 28 Oct 2022 13:28:36 -0700 Subject: [PATCH 43/43] chore: v0.26.1 [skip ci] --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 76ad7171..12c8ba22 100644 --- a/README.md +++ b/README.md @@ -38,11 +38,11 @@ cmake_minimum_required(VERSION 3.20) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.26.0 +# Add project_options v0.26.1 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.26.0.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.26.1.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) @@ -391,11 +391,11 @@ cmake_minimum_required(VERSION 3.20) # If commented, the latest supported standard for your compiler is automatically set. # set(CMAKE_CXX_STANDARD 20) -# Add project_options v0.26.0 +# Add project_options v0.26.1 # https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.26.0.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.26.1.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake)