CMake does not support toolset specification - cmake

I'm trying to build the Checked-C project which uses CMake, but when I go to generate the makefile CMake gives the following error.
~/checkedc/build$ cmake ../llvm
CMake Error at CMakeLists.txt:57 (project):
Generator
Unix Makefiles
does not support toolset specification, but toolset
host=x64
was specified.
-- Configuring incomplete, errors occurred!
I have CMake version 3.9.1 installed along with GNU Make 4.1, Clang 5, and GCC 7. Anyone able to tell me what this CMake error means?
That section of CMakeLists.txt looks like this:
57 project(LLVM
58 ${cmake_3_0_PROJ_VERSION}
59 ${cmake_3_0_LANGUAGES}
60 C CXX ASM)
I've tried setting C/CXX/ASM but get the same error:
~/checkedc/build$ cmake -DCMAKE_C_COMPILER="clang-5.0" -DCMAKE_CXX_COMPILER="clang-5.0" -DCMAKE_ASM_COMPILER="clang-5.0" ../llvm
CMake Error at CMakeLists.txt:57 (project):
Generator
Unix Makefiles
does not support toolset specification, but toolset
host=x64
was specified.
-- Configuring incomplete, errors occurred!
I'm on Kubuntu 17.10 64bit.

It means that somewhere CMake file the variable CMAKE_GENERATOR_TOOLSET is set to host=x64. This only makes sense for Visual Studio generator so CMake opts to throw an error in this case.
To fix it double check the setup for your OS and generator. If this doesn't help then you'll need to find where this variable is set and remove this line.

I have the same issue - how I fixed it in my case. Indeed, I had copied the setup for cmake from windows then ported to Linux. When you run the first time, it will create in the build directory a file called: CMakeCache.txt. This file keeps some variables set initially for Windows. I removed it, together with all the CMakeFiles directory and rerun the cmake command to generate the project. It was working perfectly, but I had to set the CMAKE_CXX_COMPILER and CMAKE_C_COMPILER variables to the cmake command: -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_C_COMPILER=/usr/bin/gcc
Hope it is working for you too.

Related

Can't install bleeding edge CMake package

I need the freshest CMake installed on my OpenSuse in order to use an app. I'm trying to download it from the official site and follow the instructions: https://cmake.org/install/
However, I get the following errors:
aleksandr#linux-b0ak:~/Downloads/cmake-3.17.0-rc1> cmake .
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:7 (project):
No CMAKE_CXX_COMPILER could be found.
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.
-- Configuring incomplete, errors occurred!
See also "/home/aleksandr/Downloads/cmake-3.17.0-rc1/CMakeFiles/CMakeOutput.log".
See also "/home/aleksandr/Downloads/cmake-3.17.0-rc1/CMakeFiles/CMakeError.log".
aleksandr#linux-b0ak:~/Downloads/cmake-3.17.0-rc1> ./bootstrap
---------------------------------------------
CMake 3.17.0-rc1, Copyright 2000-2020 Kitware, Inc. and Contributors
C compiler on this system is: cc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
Please specify one using environment variable CXX.
The C++ flags are "".
They can be changed using the environment variable CXXFLAGS.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /home/aleksandr/Downloads/cmake-3.17.0-rc1/Bootstrap.cmk/cmake_bootstrap.log

CMake Error : execution of make failed on Windows

I am getting errors when trying to build nanomsg project in Windows 7:
cmake ..
-- Building for: NMake Makefiles
-- The C compiler identification is GNU 4.7.1
-- Check for working C compiler: C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_5d837\fast"
-- Check for working C compiler: C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/cmake-3.9.4-win64-x64/share/cmake-3.9/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler "C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe" is not
able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/User/Documents/Internal/nanomsg-master/build/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_5d837\fast"
Generator: execution of make failed. Make command was: "nmake" "/NOLOGO"
"cmTC_5d837\fast"
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:29 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/User/Documents/Internal/nanomsg-master/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/User/Documents/Internal/nanomsg-master/build/CMakeFiles/CMakeError.log".
I use gcc compiler and make from Mingw toolchain and I can run succesfully gcc.exe and mingw32-make.exe on a simple example.
In the file CMakeCache.txt the cache variables are set as follows:
//C compiler
CMAKE_C_COMPILER:FILEPATH=C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe
//Program used to build from makefiles.
CMAKE_MAKE_PROGRAM:STRING=nmake
I think that the problem comes from CMAKE_MAKE_PROGRAM variable it should take C:/Program Files (x86)/CodeBlocks/MinGW/bin/mingw32-make.exe, however i dont understand from where it gets the value nmake.
Even i replaced it manually I get the same problem.
My questions :
How CMake fills the Cache variables ?
Why CMAKE_MAKE_PROGRAM takes the value nmake ?
Why changing manually this variable didn t solve the problem ?
CMake fills the cache file with the values it detects based what is in CMakeLists.txt and whatever files it includes in combination with any -D paramters supplied to cmake.
On Windows CMake will default to Microsoft's nmake tool. The way to override this is by passing parameter -G"MinGW Makefiles" to cmake, or in case you use MSYS shell -G"MSYS Makefiles".
But there is a faster build tool than make called Ninja (get it from https://ninja-build.org/) which you can use by passing -GNinja to cmake.
Note: I see you're using the old MinGW that comes with Code::Blocks. There is a more up to date successor to MinGW called MinGW-w64, which supports both Windows 32-bit and 64-bit. A recent standalone build can be downloaded from https://winlibs.com/ and it also includes ninja.exe.
P.S.: If you run into more issues building the nanomsg sources after following these tips, consider passing -DNN_TESTS:BOOL=OFF to cmake

Error while cmaking curlpp

I am trying to cmake curlpp using Cmake version 3.4.1 and I get an error in cmake saying: " Error in configuration process [...]". So all I did is in cmake-gui open the curlpp source (version 0.7.3), selected the destination folder and chose mingw. Here is the output in the gui http://pastebin.com/1gKyqd32.
It said Configuring incomplete, errors occurred!
See also "C:/c++/libraries/curlpp_built/CMakeFiles/CMakeOutput.log".
CMakeOutput.log
I setup CMake correctly and I could compile glfw library.
Quoting the relevant part of the output
CMake Error at src/utilspp/CMakeLists.txt:4 (add_subdirectory):
add_subdirectory given source "singleton" which is not an existing
directory.
The project's CMakeLists.txt in src/utilspp is broken.
The bug is already reported in curlpp's issue tracker:
https://github.com/jpbarrette/curlpp/issues/7
You can work around this bug by removing line 4 from src/utilspp/CMakeLists.txt it should contain something like add_subdirectory(singleton). If you are lucky, everything works; but other errors might pop up.

CMake cannot find MathGL's dependency PNG

I'm trying to generate Visual Studio 2013 projects files for MathGL 2.3.3 with CMake.
For some reason cmake does not understand my PNG_PNG_INCLUDE_DIR statement.
cmake "-DZLIB_INCLUDE_DIR=c:\users\chenning\projects\zlib-1.2.8\" "-DZLIB_LIBRARY_DEBUG=c:\users\chenning\projects\zlib-1.2.8\zlib.lib" "-DZLIB_LIBRARY_Release=c:\users\chenning\projects\zlib-1.2.8\zlib.lib" "-DPNG_PNG_INCLUDE_DIR=C:\Users\chenning\projects\lpng1620\" "-DPNG_LIBRARY_DEBUG=C:\Users\chenning\projects\lpng1620\projects\vstudio\x64\Debug\libpng16.lib" "-DPNG_LIBRARY_Release=C:\Users\chenning\projects\lpng1620\projects\vstudio\x64\Release\libpng16.lib" .
The Path exists and the variable is really called PNG_PNG_INCLUDE_DIR with two PNG.
cmake is telling me:
-- Found ZLIB: c:\users\chenning\projects\zlib-1.2.8\zlib.lib
-- Could NOT find PNG (missing: PNG_PNG_INCLUDE_DIR)
CMake Error at CMakeLists.txt:341 (message):
Couldn't find PNG library.
-- Configuring incomplete, errors occurred!
See also "C:/Users/chenning/projects/mathgl-2.3.3/CMakeFiles/CMakeOutput.log".
See also "C:/Users/chenning/projects/mathgl-2.3.3/CMakeFiles/CMakeError.log".
When I set the paths with cmake-gui all works fine.
Any ideas what's wrong?

CMAKE_CXX_COMPILER not set in qtcreator

Is there a way (like command line argument or some function in CMakeLists.txt) to print all command line arguments supplied to cmake invocation? Equivalent of bash "echo $#"
I need this to debug, why cmake invoked from qtcreator does not find my compiler (msvc12). After inspecting qtcreator sources, I see that it appends some environment by cmake arguments depending on selected kit. I got messages like
CMAKE_CXX_COMPILER not set
, when I select both "Nmake Desktop Qt MSVC2013 ..." or "Ninja Qt MSVC2013".
When I call cmake from command line, it finds compiler with no additional parameters:
-- Check for working CXX compiler using: Visual Studio 12 2013
-- Check for working CXX compiler using: Visual Studio 12 2013 -- works
My main problem was solved by installing ninja. I thought that the problem was not finding compiler by cmake invoked by qtcreator:
CMAKE_CXX_COMPILER not set
After installing ninja and restarting qtcreator, the problem was gone.
I had the same problem after upgrading Visual Studio 2017.
For some reason, when ADDING (?) CMAKE_CXX_COMPILER in the cmake configuration in Build & Run to the location of the Visual Studio compiler, it should work:
Key: CMAKE_CXX_COMPILER
Value: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe ==> replace version with the correct one
Don't forget to click "Apply Configuration Changes" below.
Very strange though, because after building, the cmake run becomes CMake Project was parsed successfully.and believe-it-or-not, the CMAKE_CXX_COMPILER is gone!