While giving the cmake command I am using the flag "-DWITH_DAY=1" option as the flag.
This flag is available in the code and wokrs fine.
But when I want to build other ibrary using the same code but without this flag I need to erase the definition of this flag because in my code I have statements like
"if(NOT DEFINED WITH_DAY)"
But when I do a cmake without this flag the WITH_DAY still remains defined! and hence my build fails.
It only works if I remove the CMakeCache.txt file or the entire build directory.
I want is to be disabled if I do not specify it in the command line.
You should run cmake -U WITH_DAY . before building other library. It's because CMake saves WITH_DAY's value in the cache (CMakeCache.txt).
Alternatively, as #Caduchon has mentioned, you can make WITH_DAY an option and change your if statement to just
if(WITH_DAY)
Related
I am trying to build SOCI on Windows with a different library suffix using the CMAKE_SHARED_LIBRARY_SUFFIX option, but the script seems to ignore it.
Here is the command I run in a batch file:
cmake^
-G "NMake Makefiles"^
-DCMAKE_BUILD_TYPE=Release^
-DCMAKE_SHARED_LIBRARY_SUFFIX="-vc140-x64-mt.dll"^
..\soci.3.2.3
The documentation does not say anything about the CMAKE_SHARED_LIBRARY_SUFFIX option, but the core/CMakeLists.txt script uses it to define the SOCI_LIB_SUFFIX option, which is reported on the screen when cmake is run. However, its value is always ".dll" instead of "-vc140-x64-mt.dll", so it must be overwritten somewhere I don't know.
Any idea why is this happening and how fix it?
I have a library with a bunch of different configuration options. We usually configure the build with cmake-gui and ticking a few checkboxes.
I want to automate this into a .sh script using just cmake.
e.g.
In GUI -> selects a bunch of different options
equivalent cmake command -> cmake -D CMAKE_XXX=X -D CMAKE_XXY=XXY [a bunch of options here] ..
How can I find the "equivalent" cmake command-line command to any arbitrary configuration I choose from the GUI?
The equivalent cmake command to cache a variable is explained here (-D option). Note that previous documentation was ambiguous, so take care of always checking the latest one.
Basically:
-D<var>:<type>=<value>
You have to specify also the type to have the variable cached in the same way as through your cmake-gui procedure. Note that variable definition is necessary only the first time: if not specified anymore, the cached value will be used.
cmake-gui generates CMakeVars.txt and CMakeCache.txt files in the build directory once you click "Configure" button. They cache all variables you configured through the GUI.
Had the same question ... and as you asked I looking up some of the options in the menu and found it. Menu Tools -> Show My Changes
Bringing up an Dialog with an edit field with content for command line options or cache file options.
yeah
p.s. I used cmake 3.11.1
just read file named like CMakeCache.txt (iirc) in the root of build directory and see variable names there
You can write a file containing all variables you want to set with set(<var_name> <value>) and pass this file to the CMake call via -C:
cmake -C <fileWithInitialValues> <pathToSrcDir>
Documentation:
https://cmake.org/cmake/help/v3.3/manual/cmake.1.html
This should would similar with cmake-gui and ccmake, but it is not a pure solution with the graphic interface.
I need to use make-3.8.2 version for compiling code. I have modified makefile in following way.
export PATH := /home/make-3.82/bin:$(PATH)
I am able to change PATH variable But it Invoke current make version which is make-3.7.6.
if I set manually in terminal than it's work fine which is also correct as it takes from Path
So is it possible to override make file version or any init function where we can override make file version after running make command
In simple words, check make file version and if it's not set make file version 3.8.2 or report any error ( any option is fine)
My Purpose is, we can handle make file version inside Makefile rather than any .cshrc or .bashrc to avoid any enviroment setup
I have doing following way in makefile.
ifneq ($(MAKE_VERSION), 3.82)
$(error Please add /home/make-3.82/bin in PATH enviroment and re run)
endif
If you set PATH from your makefile make already runs in the old version. I don't know under which OS/shell you are working. For bash you have to set your PATH var in ~/.bashrc.
I am trying to compile a section of a library with cmake and make. I am getting the error when I run Make that the include is failing:
/home/user/Sean/PCL/pcl/apps/src/face_detection/openni_face_detection.cpp:9:57: fatal error: pcl/apps/face_detection/openni_frame_source.h: No such file or directory compilation terminated.
I know that with gcc, you can get the compiler to read to you where it looked for the include, but is there a way to accomplish this with make and cmake.
If the Makefile is automatically generated by CMake, you can launch make like this:
> make VERBOSE=1
to interleave the progression on targets with the actual commands make is executing.
From these commands you should be able to extract the current include paths.
You may probably want to take also a look at the include_directories CMake command,
in case some include paths are missing.
I'm cross-compiling a Win32 target on SUSE Linux using mingw32. None of the conventional verbose/debug options provided the #include search path.
This forced my (lazy) hand to manually reproduce the compile operation that ultimately revealed the header search path.
A brief description...
Run the make operation and take note of the compiler, the directory, and the command line it's executing. Yeah, it's messy, but not impossible. Capture the output to a file if headless.
Change into the directory
Execute the compiler with the --help option. Take note of its verbose option.
Run the compile command specifying the verbose option.
Here's what I got...
#include "..." search starts here:
#include <...> search starts here:
/home/me/rpmbuild/BUILD/the-app-0.0.0/core/src/win32/include
/home/me/rpmbuild/BUILD/the-app-0.0.0/core/src/win32/compat/include
/home/me/rpmbuild/BUILD/the-app-0.0.0/core/src
/home/me/rpmbuild/BUILD/the-app-0.0.0/core/src/win32/generic
/home/me/rpmbuild/BUILD/the-app-0.0.0/core/src/win32/filed
/usr/lib64/gcc/x86_64-w64-mingw32/8.2.0/include/c++
/usr/lib64/gcc/x86_64-w64-mingw32/8.2.0/include/c++/x86_64-w64-mingw32
/usr/lib64/gcc/x86_64-w64-mingw32/8.2.0/include/c++/backward
/usr/lib64/gcc/x86_64-w64-mingw32/8.2.0/include
/usr/lib64/gcc/x86_64-w64-mingw32/8.2.0/include-fixed
/usr/x86_64-w64-mingw32/sys-root/mingw/include
End of search list.
Not too bad...
BTW, this is a cmake 3.5.2 configuration.
I compiled my program with intel C++ compiler for windows (from Intel Composer 2011), and got an error message that libmmdd.lib cannot be found. I googled this problem, and some people said that I have to reinstall my compiler, and I did; however, that didn't resolve the problem, so I started looking in the intel compiler directory, and found that this file (and other required libraries as well) are located at
%CompilerDirectory%\compiler\lib\ia32
It doesn't make sense to write in the make file the whole absolute path of the libraries, so I started searching, and I could only find that %mklroot% points to the math kernel directory. And even with a -L%mklroot%/../compiler/lib/ia32 approach for linking I couldn't link to the libraries correctly, so eventually I did a lame move to solve the problem, which is, I copied every file the linker asks for to the source directory, and so was the problem temporarily solved.
Since this way of solving the problem isn't the best one, I wonder if there's a way to link to those libraries without having to copy the files. It's strange because the compiler should find its own libraries alone, but... I don't know...!
Any ideas? is there something like, %compilerroot%, that points to the compiler directory and that I could put in my makefile (or actually my qmake, since I'm using Qt).
Thanks for any efforts :-)
Instead of using %mklroot% try $$(mklroot) or $(mklroot).
You can find the explanation here:
Variables can be used to store the contents of environment variables.
These can be evaluated at the time that qmake is run, or included in
the generated Makefile for evaluation when the project is built.
To obtain the contents of an environment value when qmakeis run, use
the $$(...) operator:
DESTDIR = $$(PWD)
message(The project will be installed in $$DESTDIR)
In the above assignment, the value of the PWD environment variable is
read when the project file is processed.
To obtain the contents of an environment value at the time when the
generated Makefile is processed, use the $(...) operator:
DESTDIR = $$(PWD)
message(The project will be installed in $$DESTDIR)
DESTDIR = $(PWD)
message(The project will be installed in the value of PWD)
message(when the Makefile is processed.)
In the above assignment, the value of PWD is read immediately when the
project file is processed, but $(PWD) is assigned to DESTDIR in the
generated Makefile. This makes the build process more flexible as long
as the environment variable is set correctly when the Makefile is
processed.
EDIT:
It is strange that neither $$(mklroot) nor $(mklroot) gave you the result you would expect. I did a simple test to verify what I wrote above:
Opened a Command Prompt
Created a new environment variable 'mklroot' with a test value: set mklroot=C:\intel_libs
Verified the result of the previos step: echo %mklroot%. I got C:\intel_libs
Placed your 3 qmake functions at the end of my .pro file:
warning($(%MKLROOT%))
warning($(MKLROOT))
warning($$(MKLROOT))
Ran qmake: qmake. The result:
Project WARNING:
Project WARNING: c:\intel_libs
Project WARNING: c:\intel_libs
As you can see the 2nd and the 3rd warning() displayed the string I set to the environment variable.