nlohmann/cmake_min_version

error on (project)

Closed this issue · 9 comments

cmake 3.0 - 3.20 have an error on the line 3: project(cmake_min_test1 VERSION 0.1)
on the test project: https://github.com/yalov/cmake_min_test1

I have compiled this project on cmake 3.29.0 (windows 10) and cmake 3.16.3 (ubuntu 20.04, aarch64), so I believe there might be something wrong with the tool.

I use the tool on the windows 10 x64.

powershell output:

PS D:\Repos\cmake_min_version> .\venv\Scripts\python.exe cmake_min_version.py --full_search true D:\Repos\cmake_min_test
1
Found 33 CMake binaries from directory tools

[ 0%] CMake 2.4.8 ✘ error
The source directory "C:/Users/user/AppData/Local/Temp/tmpg8rx3pxp/-Wno-dev" does not exist.
[ 12%] CMake 2.6.4 ✘ error
Error in cmake code at
[ 22%] CMake 2.8.12.2 ✘ error
Error in cmake code at
[ 30%] CMake 3.0.2 ✘ error
CMakeLists.txt:3 (project)
[ 36%] CMake 3.1.3 ✘ error
CMakeLists.txt:3 (project)
[ 42%] CMake 3.2.3 ✘ error
CMakeLists.txt:3 (project)
[ 46%] CMake 3.3.2 ✘ error
CMakeLists.txt:3 (project)
[ 50%] CMake 3.4.3 ✘ error
CMakeLists.txt:3 (project)
[ 53%] CMake 3.5.2 ✘ error
CMakeLists.txt:3 (project)
[ 56%] CMake 3.6.3 ✘ error
CMakeLists.txt:3 (project)
[ 59%] CMake 3.7.2 ✘ error
CMakeLists.txt:3 (project)
[ 61%] CMake 3.8.2 ✘ error
CMakeLists.txt:3 (project)
[ 63%] CMake 3.9.6 ✘ error
CMakeLists.txt:3 (project)
[ 65%] CMake 3.10.3 ✘ error
CMakeLists.txt:3 (project)
[ 67%] CMake 3.11.4 ✘ error
CMakeLists.txt:3 (project)
[ 68%] CMake 3.12.4 ✘ error
CMakeLists.txt:3 (project)
[ 70%] CMake 3.13.5 ✘ error
CMakeLists.txt:3 (project)
[ 71%] CMake 3.14.7 ✘ error
CMakeLists.txt:3 (project)
[ 72%] CMake 3.15.7 ✘ error
CMakeLists.txt:3 (project)
[ 73%] CMake 3.16.9 ✘ error
CMakeLists.txt:3 (project)
[ 74%] CMake 3.17.5 ✘ error
CMakeLists.txt:3 (project)
[ 75%] CMake 3.18.6 ✘ error
CMakeLists.txt:3 (project)
[ 76%] CMake 3.19.8 ✘ error
CMakeLists.txt:3 (project)
[ 77%] CMake 3.20.6 ✘ error
CMakeLists.txt:3 (project)
[ 77%] CMake 3.21.7 ✔ works
[ 78%] CMake 3.22.6 ✔ works
[ 79%] CMake 3.23.5 ✔ works
[ 79%] CMake 3.24.4 ✔ works
[ 80%] CMake 3.25.3 ✔ works
[ 81%] CMake 3.26.6 ✔ works
[ 81%] CMake 3.27.9 ✔ works
[ 82%] CMake 3.28.4 ✔ works
[ 82%] CMake 3.29.0 ✔ works
[100%] Minimal working version: CMake 3.21.7

I will check locally. Maybe we need an option to dump the actual error message for each version.

I tried the project locally using macOS. I first had an error with all CMake versions, because Boost was not installed. Once I fixed that (brew install boost), I got

❯ ./cmake_min_version.py ~/Downloads/cmake_min_test1
Found 32 CMake binaries from directory tools

[  0%] CMake 3.13.5   ✔ works
[ 17%] CMake 3.5.2    ✘ error
[ 33%] CMake 3.9.6    ✔ works
[ 50%] CMake 3.7.2    ✘ error
[ 80%] CMake 3.8.2    ✔ works
[100%] Minimal working version: CMake 3.8.2

cmake_minimum_required(VERSION 3.8.2)

it's something I had expected.

I have repeated the same with WSL ubuntu 20.04 and have installed boost there (apt install libboost-all-dev), and I got the same 3.8.

On windows I have installed boost using the
https://sourceforge.net/projects/boost/files/boost-binaries/

the problem probablly within if (WIN32) in the CMakeLists.txt

I now added an --error_details flag. With it, you can display the stderr output which could help identifying the reason why CMake failed.

I have updated the https://github.com/yalov/cmake_min_test1 a little bit
and have launched the tool with the --error_details,
the OP error is about using Visual Studio Command Prompt:

     CMake Error at CMakeLists.txt:3 (project):
     The CMAKE_CXX_COMPILER: cl
     is not a full path and was not found in the PATH.

     To use the NMake generator with Visual C++, cmake must be run from a shell
     that can use the compiler cl from the command line.  This environment is
     unable to invoke the cl compiler.  To fix this problem, run cmake from the
     Visual Studio Command Prompt (vcvarsall.bat).

     Tell CMake where to find the compiler by setting either the environment
     variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
     to the compiler, or to the compiler name if it is in the PATH.

Then I launched from the Visual Studio Command Prompt,
and the error is about being unable to find the older Platform Toolset.
Is there any way to bypass this and force the use of the installed toolset?

[ 63%] CMake 3.9.6    ✘ error
       CMake Error at CMakeLists.txt:3 (project):
         Failed to run MSBuild command:

           MSBuild.exe

         to get the value of VCTargetsPath:

           MSBuild version 17.9.8+b34f75857 for .NET Framework
           Build started 2024-04-02 23:17:52.

           Project "C:\Users\user\AppData\Local\Temp\tmpw5_v39s0\CMakeFiles\3.9.6\VCTargetsPath.vcxproj" on node 1 (default targets).
           C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\user\AppData\Local\Temp\tmpw5_v39s0\CMakeFiles\3.9.6\VCTargetsPath.vcxproj]
           Done Building Project "C:\Users\user\AppData\Local\Temp\tmpw5_v39s0\CMakeFiles\3.9.6\VCTargetsPath.vcxproj" (default targets) -- FAILED.

           Build FAILED.

           "C:\Users\user\AppData\Local\Temp\tmpw5_v39s0\CMakeFiles\3.9.6\VCTargetsPath.vcxproj" (default target) (1) ->
           (PrepareForBuild target) ->
             C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\user\AppData\Local\Temp\tmpw5_v39s0\CMakeFiles\3.9.6\VCTargetsPath.vcxproj]
               0 Warning(s)
               1 Error(s)
           Time Elapsed 00:00:00.23
         Exit code: 1

Can you successfully run cmake from the command line? You can pass any parameter also to cmake_min_version.

yes, cmake by itself is working.
there is a full log.
3.9 - 3.12 — it tried to build using the v141 toolset, while the v143 is installed

[  0%] CMake 3.0.2  ✘ error
       CMake Error at CMakeLists.txt:8 (message):
         CMAKE_PROJECT_VERSION is not defined


[ 14%] CMake 3.1.3  ✘ error
       CMake Error at CMakeLists.txt:8 (message):
         CMAKE_PROJECT_VERSION is not defined


[ 25%] CMake 3.2.3  ✘ error
       CMake Error at CMakeLists.txt:8 (message):
         CMAKE_PROJECT_VERSION is not defined


[ 33%] CMake 3.3.2  ✘ error
       CMake Error at CMakeLists.txt:8 (message):
         CMAKE_PROJECT_VERSION is not defined


[ 40%] CMake 3.4.3  ✘ error
       CMake Error at CMakeLists.txt:8 (message):
         CMAKE_PROJECT_VERSION is not defined


[ 45%] CMake 3.5.2  ✘ error
       CMake Error at CMakeLists.txt:8 (message):
         CMAKE_PROJECT_VERSION is not defined


[ 50%] CMake 3.6.3  ✘ error
       CMake Error at CMakeLists.txt:8 (message):
         CMAKE_PROJECT_VERSION is not defined


[ 54%] CMake 3.7.2  ✘ error
       CMake Error at CMakeLists.txt:8 (message):
         CMAKE_PROJECT_VERSION is not defined


[ 57%] CMake 3.8.2  ✘ error
       CMake Error at CMakeLists.txt:3 (project):
         No CMAKE_C_COMPILER could be found.



       CMake Error at CMakeLists.txt:3 (project):
         No CMAKE_CXX_COMPILER could be found.



[ 60%] CMake 3.9.6  ✘ error
       CMake Error at CMakeLists.txt:3 (project):
         Failed to run MSBuild command:

           MSBuild.exe

         to get the value of VCTargetsPath:

           MSBuild version 17.9.8+b34f75857 for .NET Framework
           Build started 2024-04-09 23:50:42.

           Project "C:\Users\user\AppData\Local\Temp\tmpz4a0861r\CMakeFiles\3.9.6\VCTargetsPath.vcxproj" on node 1 (default targets).
           C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\user\AppData\Local\Temp\tmpz4a0861r\CMakeFiles\3.9.6\VCTargetsPath.vcxproj]
           Done Building Project "C:\Users\user\AppData\Local\Temp\tmpz4a0861r\CMakeFiles\3.9.6\VCTargetsPath.vcxproj" (default targets) -- FAILED.

           Build FAILED.

           "C:\Users\user\AppData\Local\Temp\tmpz4a0861r\CMakeFiles\3.9.6\VCTargetsPath.vcxproj" (default target) (1) ->
           (PrepareForBuild target) ->
             C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\user\AppData\Local\Temp\tmpz4a0861r\CMakeFiles\3.9.6\VCTargetsPath.vcxproj]

               0 Warning(s)
               1 Error(s)

           Time Elapsed 00:00:00.20


         Exit code: 1



[ 62%] CMake 3.10.3 ✘ error
       CMake Error at CMakeLists.txt:3 (project):
         Failed to run MSBuild command:

           MSBuild.exe

         to get the value of VCTargetsPath:

           MSBuild version 17.9.8+b34f75857 for .NET Framework
           Build started 2024-04-09 23:50:42.

           Project "C:\Users\user\AppData\Local\Temp\tmp5al3om8x\CMakeFiles\3.10.3\VCTargetsPath.vcxproj" on node 1 (default targets).
           C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\user\AppData\Local\Temp\tmp5al3om8x\CMakeFiles\3.10.3\VCTargetsPath.vcxproj]
           Done Building Project "C:\Users\user\AppData\Local\Temp\tmp5al3om8x\CMakeFiles\3.10.3\VCTargetsPath.vcxproj" (default targets) -- FAILED.

           Build FAILED.

           "C:\Users\user\AppData\Local\Temp\tmp5al3om8x\CMakeFiles\3.10.3\VCTargetsPath.vcxproj" (default target) (1) ->
           (PrepareForBuild target) ->
             C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\user\AppData\Local\Temp\tmp5al3om8x\CMakeFiles\3.10.3\VCTargetsPath.vcxproj]

               0 Warning(s)
               1 Error(s)

           Time Elapsed 00:00:00.20


         Exit code: 1



[ 65%] CMake 3.11.4 ✘ error
       CMake Error at CMakeLists.txt:3 (project):
         Failed to run MSBuild command:

           MSBuild.exe

         to get the value of VCTargetsPath:

           MSBuild version 17.9.8+b34f75857 for .NET Framework
           Build started 2024-04-09 23:50:43.

           Project "C:\Users\user\AppData\Local\Temp\tmpdy45fod8\CMakeFiles\3.11.4\VCTargetsPath.vcxproj" on node 1 (default targets).
           C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\user\AppData\Local\Temp\tmpdy45fod8\CMakeFiles\3.11.4\VCTargetsPath.vcxproj]
           Done Building Project "C:\Users\user\AppData\Local\Temp\tmpdy45fod8\CMakeFiles\3.11.4\VCTargetsPath.vcxproj" (default targets) -- FAILED.

           Build FAILED.

           "C:\Users\user\AppData\Local\Temp\tmpdy45fod8\CMakeFiles\3.11.4\VCTargetsPath.vcxproj" (default target) (1) ->
           (PrepareForBuild target) ->
             C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\user\AppData\Local\Temp\tmpdy45fod8\CMakeFiles\3.11.4\VCTargetsPath.vcxproj]

               0 Warning(s)
               1 Error(s)

           Time Elapsed 00:00:00.20


         Exit code: 1



[ 67%] CMake 3.12.4 ✘ error
       CMake Error at CMakeLists.txt:3 (project):
         Failed to run MSBuild command:

           MSBuild.exe

         to get the value of VCTargetsPath:

           MSBuild version 17.9.8+b34f75857 for .NET Framework
           Build started 2024-04-09 23:50:43.

           Project "C:\Users\user\AppData\Local\Temp\tmp4fv8p4w5\CMakeFiles\3.12.4\VCTargetsPath.vcxproj" on node 1 (default targets).
           C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\user\AppData\Local\Temp\tmp4fv8p4w5\CMakeFiles\3.12.4\VCTargetsPath.vcxproj]
           Done Building Project "C:\Users\user\AppData\Local\Temp\tmp4fv8p4w5\CMakeFiles\3.12.4\VCTargetsPath.vcxproj" (default targets) -- FAILED.

           Build FAILED.

           "C:\Users\user\AppData\Local\Temp\tmp4fv8p4w5\CMakeFiles\3.12.4\VCTargetsPath.vcxproj" (default target) (1) ->
           (PrepareForBuild target) ->
             C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\user\AppData\Local\Temp\tmp4fv8p4w5\CMakeFiles\3.12.4\VCTargetsPath.vcxproj]

               0 Warning(s)
               1 Error(s)

           Time Elapsed 00:00:00.20


         Exit code: 1



[ 68%] CMake 3.13.5 ✔ works
[ 70%] CMake 3.14.7 ✔ works
[ 71%] CMake 3.15.7 ✔ works
[ 73%] CMake 3.16.9 ✔ works
[ 74%] CMake 3.17.5 ✔ works
[ 75%] CMake 3.18.6 ✔ works
[ 76%] CMake 3.19.8 ✔ works
[ 77%] CMake 3.20.6 ✔ works
[ 78%] CMake 3.21.7 ✔ works
[ 79%] CMake 3.22.6 ✔ works
[ 79%] CMake 3.23.5 ✔ works
[ 80%] CMake 3.24.4 ✔ works
[ 81%] CMake 3.25.3 ✔ works
[ 81%] CMake 3.26.6 ✔ works
[ 82%] CMake 3.27.9 ✔ works
[ 82%] CMake 3.28.4 ✔ works
[ 83%] CMake 3.29.0 ✔ works
[100%] Minimal working version: CMake 3.13.5

cmake_minimum_required(VERSION 3.13.5)

I am not using Windows myself, so I have no way to check this. Could there be environment variables that need to be set?

I will close that issue, if I will have something to say about the Platform Toolset I will open the new one