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.
Related
Here is the instructions: https://github.com/json-c/json-c/blob/master/README.md#build-instructions--
This is the first time I've ever built from source.
I'm on Windows 10 and I used CMake to build.
I did this and it all worked fine:
$ git clone https://github.com/json-c/json-c.git
$ mkdir json-c-build
$ cd json-c-build
$ cmake ../json-c
But I don't understand this part:
$ make
$ make test
$ make USE_VALGRIND=0 test # optionally skip using valgrind
$ make install
Can someone explain to me what these lines do?
I installed mingw32-make but when I run mingw32-make on its own like in the this tutorial it just says:
mingw32-make: *** No targets specified and no makefile found. Stop.
Do I need to create a Makefile? It doesn't say anywhere in the installation notes to do this but I cannot get past this step, what am I doing wrong?
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
I am new to programming and I have several c-files I want to run from the terminal in mac. I have installed cmake from homebrew and it seems to be installed correctly (when I type "brew install cmake", I get the message "Warning: cmake-3.6.3 already installed").
My problem is, that I don't know what to type next to compile/run the file. I'm sorry if this seems really basic, but I don't understand the answers I found on Google. I have changed the directory to the folder containing my files "cd /Users/..." and I have a CMakeList.txt file from a friend and put in the same folder.
I have tried typing "cmake ." and it creates a lot of new folders, but I doesn't print anything. I have a "printf"-command in my main.c.
Can anyone tell me, what I should type to make the code print to the terminal?
CMake doesn't run your program.
CMake generates a Makefile. This Makefile can be interpreted by "make" by calling "make" in the same directory (you can also specify other names or paths, but not needed here). "make" will call the compiler, linker and maybe some other stuff to build your program. At the end and with no errors, you have a executable named as written in the "add_executable" instruction in your CMakeLists.txt. To run this program it should be sufficient to type "./program_name" in the build directory.
One hint: It is better to create a subfolder for building. "mkdir build && cd build && cmake ../ && make".
I am working on a system on which I am a non-root user.
While trying to install gcc 5.1 in a custom directory as the present shared version of gcc isn't working for postgresql installation, I started out by
wget gcc 5.1.
After unzipping the folder, ran the commands below:
cd /seq/genome_portal/lib
mkdir bld
mkdir gcc
cd bld
/seq/genome_portal/lib/gcc-5.1/configure --prefix=/seq/genome_portal/lib/gcc
However config.log still shows this error:
/../../redhat_6_x86_64/pkgs/gcc_4.9.0/libexec/gcc/x86_64-redhat-linux/4.9.0/cc1: error while loading shared libraries: libmpfr.so.4: cannot open shared object file: No such file or directory
The prerequisites that come after
./contrib/download_prerequisites
are gmp,mpfr and mpc. I started with gmp and ended up in the same error as above. I somehow need to tell these programs that I do not want to use the existing gcc.
But I get the same error as mentioned before. Any advice as to how I can proceed to install it?
Building a compiler is much more complicated that building a straightforward utility; just running configure is not enough.
Primarily, you need to read the instructions; they are provided in the GCC source directory in the INSTALL subdirectory. They are in HTML so point your browser at it.
I know you didn't do this yet because the step on configuration makes very clear you should be using an out-of-source configuration; e.g., something like:
mkdir ../bld
cd ../bld
../gcc-5.1/configure ...
rather than running ./configure.
Regarding the missing dependencies, there's a "prerequisites" section in the docs. To get MPFR and other helpful things you can run:
cd gcc-5.1
./contrib/download_prerequisites
ETA: This should work:
rm -rf newgcc
mkdir newgcc
cd newgcc
tar xzf gcc-5.1.tar.gz
cd gcc-5.1
./contrib/download_prerequisites
mkdir ../bld
cd ../bld
../gcc-5.1/configure <configopts>
make -j8
make install
(or whatever -j you prefer).
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?