From ad90b1ad3e8dcce88a5addbd83c71d3212e4d879 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sun, 9 Jul 2023 16:15:42 +0200 Subject: [PATCH] Add 'clang-cl' and 'clang-any' conditions --- docs/cmake-toml.md | 4 +++- src/project_parser.cpp | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/cmake-toml.md b/docs/cmake-toml.md index ce15d77..6920acf 100644 --- a/docs/cmake-toml.md +++ b/docs/cmake-toml.md @@ -72,8 +72,10 @@ 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\" 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" +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$\")" +clang-cl = "(CMAKE_CXX_COMPILER_ID MATCHES \"Clang\" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES \"^MSVC$\") OR (CMAKE_C_COMPILER_ID MATCHES \"Clang\" AND CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES \"^MSVC$\")" +clang-any = "CMAKE_CXX_COMPILER_ID MATCHES \"Clang\" OR CMAKE_C_COMPILER_ID MATCHES \"Clang\"" root = "CMKR_ROOT_PROJECT" x64 = "CMAKE_SIZEOF_VOID_P EQUAL 8" x32 = "CMAKE_SIZEOF_VOID_P EQUAL 4" diff --git a/src/project_parser.cpp b/src/project_parser.cpp index abc0a4c..22d9e7f 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -265,9 +265,12 @@ 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["msvc"] = R"cmake(MSVC)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["clang-cl"] = + R"cmake((CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC$") OR (CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC$"))cmake"; + conditions["clang-any"] = R"cmake(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "Clang")cmake"; conditions["root"] = R"cmake(CMKR_ROOT_PROJECT)cmake"; conditions["x64"] = R"cmake(CMAKE_SIZEOF_VOID_P EQUAL 8)cmake"; conditions["x32"] = R"cmake(CMAKE_SIZEOF_VOID_P EQUAL 4)cmake";