From ae6bea3b581e32ae0da5e5347ea8401094326d3d Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sat, 28 Jan 2023 11:57:22 +0100 Subject: [PATCH 1/4] Improve reference documentation --- docs/cmake-toml.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/cmake-toml.md b/docs/cmake-toml.md index 16a7a86..27d4e32 100644 --- a/docs/cmake-toml.md +++ b/docs/cmake-toml.md @@ -137,6 +137,7 @@ components = ["mycomponent"] condition = "mycondition" git = "https://github.com/myuser/gitcontent" tag = "v0.1" +shallow = false [fetch-content.svncontent] condition = "mycondition" @@ -146,7 +147,10 @@ rev = "svn_rev" [fetch-content.urlcontent] condition = "mycondition" url = "https://content-host.com/urlcontent.zip" -hash = "123123123123" +# These are equivalent, supported algorithms: +# md5, sha1, sha224, sha256, sha384, sha512, sha3_224, sha3_256, sha3_384, sha3_512 +hash = "SHA1 502a4e25b8b209889c99c7fa0732102682c2e4ff" +sha1 = "502a4e25b8b209889c99c7fa0732102682c2e4ff" ``` ## Targets From 51dc49e6f1eaa888df28f25c91f819f3118acc20 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sun, 19 Feb 2023 20:06:58 +0100 Subject: [PATCH 2/4] Improve CI performance for non-tagged builds --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 599cb0e..5af2eb9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,11 +46,13 @@ jobs: - name: Get lowercase OS name id: osname uses: ASzc/change-string-case-action@07c1e24a97f0951e13f88870b99c058fcf0b14cf # v5 + if: ${{ startsWith(github.ref, 'refs/tags/') }} with: string: ${{ runner.os }} - name: Compress artifacts uses: vimtor/action-zip@26a249fb00d43ca98dad77a4b3838025fc226aa1 # v1.1 + if: ${{ startsWith(github.ref, 'refs/tags/') }} with: files: install/bin/ dest: ${{ github.event.repository.name }}-${{ steps.osname.outputs.lowercase }}.zip From 8dcc11e34910cb9a315ac37c7952573f5cc53536 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sun, 19 Feb 2023 22:19:12 +0100 Subject: [PATCH 3/4] Add helper function Project::cmake_minimum_version for version-dependent features --- include/project_parser.hpp | 1 + src/project_parser.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/project_parser.hpp b/include/project_parser.hpp index 1887029..33e4d7a 100644 --- a/include/project_parser.hpp +++ b/include/project_parser.hpp @@ -199,6 +199,7 @@ struct Project { Project(const Project *parent, const std::string &path, bool build); const Project *root() const; + bool cmake_minimum_version(int major, int minor) const; }; bool is_root_path(const std::string &path); diff --git a/src/project_parser.cpp b/src/project_parser.cpp index 206de11..5c4220a 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -741,6 +741,26 @@ const Project *Project::root() const { return root; } +bool Project::cmake_minimum_version(int major, int minor) const { + // NOTE: this code is like pulling teeth, sorry + auto root_version = root()->cmake_version; + puts(root_version.c_str()); + auto range_index = root_version.find("..."); + if (range_index != std::string::npos) { + root_version.resize(range_index); + } + + auto period_index = root_version.find('.'); + auto root_major = atoi(root_version.substr(0, period_index).c_str()); + int root_minor = 0; + if (period_index != std::string::npos) { + auto end_index = root_version.find('.', period_index + 1); + root_minor = atoi(root_version.substr(period_index + 1, end_index).c_str()); + } + + return std::tie(root_major, root_minor) >= std::tie(major, minor); +} + bool is_root_path(const std::string &path) { const auto toml_path = fs::path(path) / "cmake.toml"; if (!fs::exists(toml_path)) { From bc6359805de3103f85f19c575f865de9c9106177 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sun, 19 Feb 2023 22:23:34 +0100 Subject: [PATCH 4/4] Change the `clang` condition to not detect clang-cl References: - https://github.com/cursey/safetyhook/issues/18 - https://discourse.cmake.org/t/clang-on-windows-detected-with-msvc-interface/3470 --- docs/cmake-toml.md | 2 +- src/project_parser.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/cmake-toml.md b/docs/cmake-toml.md index 27d4e32..1b7aea7 100644 --- a/docs/cmake-toml.md +++ b/docs/cmake-toml.md @@ -72,7 +72,7 @@ unix = "UNIX" bsd = "CMAKE_SYSTEM_NAME MATCHES \"BSD\"" linux = "CMAKE_SYSTEM_NAME MATCHES \"Linux\"" gcc = "CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\" OR CMAKE_C_COMPILER_ID STREQUAL \"GNU\"" -clang = "CMAKE_CXX_COMPILER_ID MATCHES \"Clang\" OR CMAKE_C_COMPILER_ID MATCHES \"Clang\"" +clang = "(CMAKE_CXX_COMPILER_ID MATCHES \"Clang\" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES \"^MSVC$\") OR (CMAKE_C_COMPILER_ID MATCHES \"Clang\" AND NOT CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES \"^MSVC$\")" msvc = "MSVC" root = "CMKR_ROOT_PROJECT" x64 = "CMAKE_SIZEOF_VOID_P EQUAL 8" diff --git a/src/project_parser.cpp b/src/project_parser.cpp index 5c4220a..c26b1ef 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -265,7 +265,8 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p conditions["bsd"] = R"cmake(CMAKE_SYSTEM_NAME MATCHES "BSD")cmake"; conditions["linux"] = conditions["lunix"] = R"cmake(CMAKE_SYSTEM_NAME MATCHES "Linux")cmake"; conditions["gcc"] = R"cmake(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")cmake"; - conditions["clang"] = R"cmake(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "Clang")cmake"; + conditions["clang"] = + R"cmake((CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC$") OR (CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC$"))cmake"; conditions["msvc"] = R"cmake(MSVC)cmake"; conditions["root"] = R"cmake(CMKR_ROOT_PROJECT)cmake"; conditions["x64"] = R"cmake(CMAKE_SIZEOF_VOID_P EQUAL 8)cmake";