How to tell CMake where to find the compiler? - cmake

I am trying to install slycot and I get the following issue.
The CMAKE_C_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 "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH
I downloaded Visual Studio 2019. I tried to run "CMake" from a VS command prompt, but nothing happens.
I have found the vcvarsall.bat file location in the VS folder, but I do not know what to do with it. Would anyone be so kind to tell me what to do next? (I am new to scripting, so please be explicit).
Thanks

Normally cmake uses the program vswhere.exe to detect your VS2019 installation. But sometimes this seems not to work.
You can run the
vcvarsall.bat Win64
to setup the environment variables in the command prompt. How to find the path to it can be found here. And I am pretty sure the script vcvarsall.bat will show you the option when calling it without a parameter.

Related

Blender in CLion: MSVC_REDIST_DIR-NOTFOUND, LIBDIR cmake variable

I am trying to build the Blender project in CLion, and failing with just configuring the IDE.
First, but not so crucial IMO, I am not sure which Architecture should I select in the Settings. By default CLion decided to go with x86, but that sounds like 32bit Windows to me... in 2022?
(But as long as I can build the project I guess win32 should not bother me.)
This seems like a bigger problem:
CMake Warning at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.21/Modules/InstallRequiredSystemLibraries.cmake:601 (message):
system runtime library file does not exist:
'MSVC_REDIST_DIR-NOTFOUND/x86/Microsoft.VC142.CRT/msvcp140.dll'
...
'MSVC_REDIST_DIR-NOTFOUND/x86/Microsoft.VC142.CRT/vcruntime140.dll'
...
'MSVC_REDIST_DIR-NOTFOUND/x86/Microsoft.VC142.CRT/concrt140.dll'
...
'MSVC_REDIST_DIR-NOTFOUND/x86/Microsoft.VC142.OPENMP/vcomp140.dll'
...
CMake Error at build_files/cmake/platform/platform_win32.cmake:264 (message):
32 bit compiler detected, blender no longer provides pre-build libraries
for 32 bit windows, please set the `LIBDIR cmake variable` to your own
library folder
All those "missing" files are scattered in the Visual Studio subdirectory "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.30.30704\x86\Microsoft.VC143*" directories, but for some reason CMake "decided" to go with VC142.
1) How does one convince CMake to go with VC143?
2) How does one set the LIBDIR cmake variable?
I suppose this one could go away once the Nr.1 problem gets resolved, but if not... Where should the variable point to, and what would its full name be? Just LIBDIR? (I am seeing CMAKE_INSTALL_ and CMAKE_INSTALL_FULL_ prefixes mentioned in GNUInstallDirs.cmake.)
Anyways, I suspect it should be set here?
So apparently there's a bug in VS2022. This version comes with CRT143 (whatever it is) yet the bundled scripts identify the VS as 2019 which only knows/recognizes CRT up to version 142.
https://developercommunity.visualstudio.com/t/1616850

QtCreator is failing to run CMake after updating

I've been using QtCreator as my CMake IDE for a long time in Ubuntu. Today I was notified there was an update. So I updated and it looks like I can't compile CMake projects anymore.
This is the error I get when I run CMake from the IDE.
error: The source directory "/tmp/QtCreator-jNrmHx/qtc-cmake-OgPpycUx" does not appear to contain CMakeLists.txt.Specify --help for usage, or press the help button on the CMake GUI.
Any ideas what could be the problem?
I had a similar issue when setting up a new build config with QtC 4.14.
In "CMake Initial parameters", make sure that there is no empty lines, and that each option is one per line. I then deleted the temp source folder re-ran CMake.

Can Kdevelop 5.0 still load existing external cmake project

I know that KDevelop 4 was able to import CMake projects (hand written CMakeLists.txt not generated by KDevelop) ... but now after I installed ubuntu 18.04 it seems this is not possible anymore (the Project > Open/Import Project dialog simply refuse take CMakeLists.txt when I click on it )? Or I miss something?
I tried to run cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS
as described here but it refuse with error message:
prokop#s2-041:~/git/SimpleSimulationEngine/cpp/Build$ cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS
Parse error in command line argument: -DCMAKE_EXPORT_COMPILE_COMMANDS
Should be: VAR:type=value
CMake Error: No cmake script provided.
CMake Error: Problem processing arguments. Aborting.
EDIT
OK, so according to the advice below I run
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
and now it generate compile_commands.json but I still cannot open it with KDevelope ... the Import Project dialog still shows everything gray and inactive (see screenshots below). Not sure if it matters that I run KDevelop under xubuntu 18.04 LTS (not Kubuntu) and Gnome-Flashback Desktop environment.
This should still work in KDevelop 5. There's no need to run cmake -DCMAKE_EXPORT_COMPILE_COMMANDS .., KDevelop will do it for you.
The version of KDevelop packaged in Ubuntu 18.04 is rather old and has many known bugs, please try the 5.4.2 AppImage and see if that resolves your problem.
You should put the path to your source (top-level CMakeLists.txt file) at the end of your command, after any options.
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
Here is the command line syntax documentation.
Edit: As Tsyvarev points out, CMake specifically complains about your -D syntax, which is missing the assignment to ON.

CLion CMake problems

I am having a problem when loading CMake on CLion. I'm attempting to setup my proper environment for Arduino programming.
I'm probably missing something obvious, but I was unable to find a functional solution to this. Could anyone give me a hint as to what is causing the following errors?
Error:The CMAKE_C_COMPILER:
avr-gcc
is not a full path and was not found in the PATH.
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
Error:The CMAKE_CXX_COMPILER:
avr-g++
is not a full path and was not found in the PATH.
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.
I got it working following the steps given in the arduino-cmake repo. If you're working on windows make sure you have the arduino sdk installed. And set the correct path in to the sdk.
If you're working on linux make sure you have all the correct dependencies installed as specified in the readme.md in the github repo.
And last but not least, ensure that de cmake directory and toolchain file are present in the project folder.
See
https://github.com/arduino-cmake/arduino-cmake
For proper instructions.

Building gdcm-2.4.3 with CMake 3.2.2

I have previously downloaded gdcm-2.4.3 and built it using CMake with the following command.
cmake -G "Visual Studio 10 2010 Win64" ..\gdcm-2.4.3
Which worked fine. I now want to repeat this but now it says it can't find a bunch of header files (sys/time.h, lanfinfo, pthread.h etc - all very Unix-y) and the build fails.
Is there a step I'm missing? I thought I noted everything down last time.
This is probably OK to ignore. It's using the CheckIncludeFiles CMake module to check for the existence of these files and that module outputs a message to show whether it found the file or not.
If there are any actual hard errors while running CMake, there will be output to show this and ultimately the .sln won't be produced.