project_options icon indicating copy to clipboard operation
project_options copied to clipboard

Ninja prefers Clang over MSVC

Open FeignClaims opened this issue 1 year ago • 2 comments
trafficstars

log of Test(windows-2022, msvc, _, _):

-- The CXX compiler identification is Clang 17.0.6 with GNU-like command-line
-- The C compiler identification is Clang 17.0.6 with GNU-like command-line

I couldn't track down which commit introduced this issue because the logs have been outdated.

FeignClaims avatar Sep 13 '24 05:09 FeignClaims

@aminya I have just tested the current main with the example cpp_vcpkg_project project on windows 10 with

MSBuild-Version 17.11.2+c078802d4 für .NET Framework Microsoft Visual Studio Professional 2022 (64-bit) - Current Version 17.11.2

It have tested the Workflow presets:

  • "windows-msvc-debug"
  • "windows-msvc-release"

I dit not generate a VS solution with cmake, I just opended the project directory from VS2022!

But I had to change some values, first, than in works for me:

MINGW64 ~/Workspace/cmake/project_options/examples/cpp_vcpkg_project (main)
$ git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 93f08e6..02adf7f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.21...3.28)
+cmake_minimum_required(VERSION 3.25...3.30)

 # 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.
@@ -14,13 +14,14 @@ endif()

 # Add project_options from 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)
-set(PROJECT_OPTIONS_VERSION "v0.36.4")
-FetchContent_Declare(
-  _project_options
-  URL https://github.com/aminya/project_options/archive/refs/tags/${PROJECT_OPTIONS_VERSION}.zip)
-
-FetchContent_MakeAvailable(_project_options)
-include(${_project_options_SOURCE_DIR}/Index.cmake)
+## set(PROJECT_OPTIONS_VERSION "v0.36.4")
+## FetchContent_Declare(
+##   _project_options
+##   URL https://github.com/aminya/project_options/archive/refs/tags/${PROJECT_OPTIONS_VERSION}.zip)
+##
+## FetchContent_MakeAvailable(_project_options)
+## include(${_project_options_SOURCE_DIR}/Index.cmake)
+include(../../Index.cmake)

 # Define the features of the project
 include("./Features.cmake")
@@ -84,8 +85,8 @@ project_options(
   PREFIX
   "my"
   ENABLE_CACHE
-  ${ENABLE_CPPCHECK}
-  ${ENABLE_CLANG_TIDY}
+  # ${ENABLE_CPPCHECK}
+  # ${ENABLE_CLANG_TIDY}
   ${ENABLE_VS_ANALYSIS}
   # ENABLE_CONAN
   # ENABLE_INTERPROCEDURAL_OPTIMIZATION
diff --git a/cmake/presets/CMakeUnixPresets.json b/cmake/presets/CMakeUnixPresets.json
index 25551d0..dd57396 100644
--- a/cmake/presets/CMakeUnixPresets.json
+++ b/cmake/presets/CMakeUnixPresets.json
@@ -2,7 +2,7 @@
   "version": 6,
   "cmakeMinimumRequired": {
     "major": 3,
-    "minor": 27,
+    "minor": 25,
     "patch": 0
   },
   "include": [
diff --git a/cmake/presets/CMakeWindowsPresets.json b/cmake/presets/CMakeWindowsPresets.json
index 3e63a17..f40eebf 100644
--- a/cmake/presets/CMakeWindowsPresets.json
+++ b/cmake/presets/CMakeWindowsPresets.json
@@ -27,10 +27,12 @@
         "value": "host=x64",
         "strategy": "external"
       },
-      "cacheVariables": {
-        "ENABLE_CPPCHECK_DEFAULT": false,
-        "ENABLE_CLANG_TIDY_DEFAULT": false
-      }
+        "cacheVariables": {
+            "CMAKE_VS_VERSION_RANGE": "[17.0,)",
+            "CMAKE_HOST_SYSTEM_PROCESSOR": "AMD64",
+            "ENABLE_CPPCHECK_DEFAULT": false,
+            "ENABLE_CLANG_TIDY_DEFAULT": false
+        }
     },
     {
       "name": "windows-msvc-debug",

MINGW64 ~/Workspace/cmake/project_options/examples/cpp_vcpkg_project (main)
$

ClausKlein avatar Sep 13 '24 20:09 ClausKlein

It seems that Ninja prefers Clang over MSVC. This can be fixed in setup-cpp by setting CXX/CC to cl

aminya avatar Sep 17 '24 19:09 aminya