cmake - NMake Makefiles issue - c

I have a source code tree as follows
daily_build
->src_dir1
->src_dir2
..
We have been using cmake-gui to configure and generate for Visual Studio 8 2005.
However, on a separate machine, we are trying to automate the build process for nightly builds.
In order to this we are trying to run cmake from command line as follows
1) vcvars32.bat
2) svn co <url path> D:\daily_build
3) cd daily_build\build\gen\host
4) cmake -G"NMake Makefiles" D:\daily_build
However, CMake exits with error
CMake Error :CMake was unable to find a build program corresponding to "NMake Makefiles"......
However, in the very same prompt, I can run cl.exe and nmake.
Further, If I look in the CMakeFiles folder, there is no error.log. All I can see is CMakeOutput.txt and the ouput file shows that CMakeCCompilerId.exe and CMakeCXXCompilerId.exe were both generated successfully.
Does anyone have any ideas what am I doing wrong?

Related

compile putty 0.78 for windows

in the new version of putty there is no Makefile.vc or project file for visual studio. How can I compile putty under visual studio 2019? can someone help me?
link to zipped source
I tried to open the windows folder in visual studio with the following error:
Severity Code Description Project File Line Suppression State
Error CMake Error at C:\Usersuser\Downloads\Compressed\putty-src\windows\CMakeLists.txt:3 (add_sources_from_current_dir):
Unknown CMake command "add_sources_from_current_dir". C:\Users\user\Downloads\Compressed\putty-src\windows\CMakeLists.txt 3
You don't need to open Visual Studio or any IDE to compile the executables.
Download cmake and make sure Visual C compiler is installed.
Unzip the .zip file, open a command prompt where the readme and CMakeLists.txt reside
Then, as the readme states:
run these commands in the source directory:
cmake .
cmake --build .
In the Debug directory, you'll find a lot of .exe files.
Then, to install in the simplest way on Linux or Mac:
cmake --build . --target install
I didn't need that part. I suppose that it copies the executables & other files somewhere in the path.
Problem with creating a distro using Microsoft compiler is that the executables then require a lot of Microsoft runtime DLLs. For instance if you deploy the executables on other machines it may not work.
An alternative is to use gcc and make to build the executables.
First:
install a recent gcc for windows
install make
Installing a recent MinGW distribution should do it. Personally I used another gcc distribution so I had to grab make too.
Now, I followed Setting default compiler in CMake, the key part being to enable mingw makefiles: -G "MinGW Makefiles", else cmake ignores your compiler requirements and keeps on using Microsoft compiler.
cmake -DCMAKE_MAKE_PROGRAM=/path/to/make/make.exe -DCMAKE_C_COMPILER=/path/to/gcc/gcc.exe -G "MinGW Makefiles" .
Note that specifying full paths require that / are used. Backslashes conflict with escaping in cmake/make files.
Then
cmake --build .

Clion projects are not running

Basically all projects are run only on Clionprojects file. BUT if I save the project in different file, then it shows me that I need to add configuration.
I installed cygwin and all what I need like gcc-core, gcc-g++, gdb, make.
In the console it says:
CMake Error: The source directory "file path"" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
CMake Error:
------------------------------------------------------------------------------------
Selected CMake might be incompatible with the Cygwin environment.
In order to run on Cygwin, CMake needs to be specially compiled.
Please select either CMake bundled with CLion or CMake from the Cygwin installation.
------------------------------------------------------------------------------------
[Failed to reload]

Eigen3 fails to install with cmake : RegexUtils not found

I try to install eigen3.3.7 with cmake on ubuntu 16 but cmake fails.
I follow the INSTALL file hints :
1) I extract the tar archive
2) Make a "build" dir named buildDir
3) Go to build dir : cd buildDir
4) Start cmake : cmake ../Eigen
Then the cmake process ends up with the error :
CMake Error at CMakeLists.txt:1 (include):
include could not find load file:
RegexUtils
CMake Error at CMakeLists.txt:2 (test_escape_string_as_regex):
Unknown CMake command "test_escape_string_as_regex".
May I ask you some hints please ?
Regards
Sylvain
I followed the advices of chtz, but it still fails, see below the console output :
syl#spica:~/tmp/eigen/eigen-eigen-323c052e1731$ cat INSTALL
Installation instructions for Eigen
***********************************
Method 2. Installing using CMake
********************************
Let's call this directory 'source_dir' (where this INSTALL file is).
Before starting, create another directory which we will call 'build_dir'.
Do:
cd build_dir
cmake source_dir
make install
syl#spica:~/tmp/eigen/eigen-eigen-323c052e1731$ mkdir build && cd build
syl#spica:~/tmp/eigen/eigen-eigen-323c052e1731/build$ cmake ../
CMake Error at CMakeLists.txt:1 (include):
include could not find load file:
RegexUtils
CMake Error at CMakeLists.txt:2 (test_escape_string_as_regex):
Unknown CMake command "test_escape_string_as_regex".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.5)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring incomplete, errors occurred!
See also "/home/syl/tmp/eigen/eigen-eigen-323c052e1731/CMakeFiles/CMakeOutput.log".
syl#spica:~/tmp/eigen/eigen-eigen-323c052e1731/build$ vim ../CMakeFiles/CMakeOutput.log
Thanks for helping.
This sequence of commands seems to work properly after downloading (in my case the currently latest version eigen-3.3.7):
bunzip2 eigen-3.3.7.tar.bz2
tar -xvf eigen-3.3.7.tar
cd eigen-3.3.7/
mkdir build
cd build
cmake ../.
sudo make install

Redirecting the Source Code errors in CMake

I am building the C Project using CMAKE. My build is working fine, but the problem is if any errors and warnings are there in the source code it's displaying on the command prompt. How can I redirect warnings and compilation errors to a file, So it's easy for me to resolve one by one? I am running my CMake using the following commands in the batch file.
cmake -G "MinGW Makefiles" ..
make
pause

cmake command line option

I am new to VS development and Cmake.
I have used CMake-GUI to generate a visual studio solution and am able to build it successfully.
However, our code has now reached a stage where we can finally build & link into a binary. With multiple people checking in code, we want to do a nightly build and so I was thinking of writing a batch file for this.
However, I am trying to invoke cmake from command line and am running into issues.
In cmake-gui, in order to configure, I provide two values
Path of my source code
Path where binaries will be generated
However, when I try to run the same over command line (using the following command)
cmake -G "NMake Makefiles" -D CMAKE_SOURCE_DIR="D:\source_code" -D CMAKE_BINARY_DIR="D:\source_code\build\gen\host"
CMake throws up an eror : The source directory "D:\" is a file not a directory.
I tried the following variations too without any luck
cmake -G "NMake Makefiles" -D PROJECT_SOURCE_DIR="D:\source_code" -D PROJECT_BINARY_DIR="D:\source_code\build\gen
Can someone please guide me to the correct syntax.
Thanks in advance
You shouldn't try and set any of these variables on the command line. They're automatically set by CMake the first time it reads the CMakeLists.txt.
Instead, you should run the CMake command from within the binary dir, and pass the path to the directory containing the top-level CMakeLists.txt. So something like:
cd D:\source_code\build\gen\host
cmake -G"NMake Makefiles" D:\source_code
By the way, CMake's command line parsing isn't great (e.g. see this answer). I'd recommend avoiding leaving spaces after -D arguments.
Try this
Remove space between -D and parameter
cmake -G "NMake Makefiles" -DCMAKE_SOURCE_DIR="D:\source_code" -DCMAKE_BINARY_DIR="D:\source_code\build\gen\host"
In my project, We used a CMake-GUI. But I created a shell script file to avoid repeatedly fill up the entries.
Sample gist is as follows.
cd <DIRECTORY_TO_BUILD> && <CMAKE-INSTALLATION-PATH>/bin/cmake.exe --build= "<BUILDSOURCE-PATH> -DQt5Widgets_DIR:PATH=C:/Qt/5.12.0/msvc2017/lib/cmake/Qt5Widgets
I have started with cd else the script will create the build folder from where the script is run.

Resources