29,371 questions
658
votes
28
answers
892k
views
Looking for a 'cmake clean' command to clear up CMake output
Just as make clean deletes all the files that a makefile has produced, I would like to do the same with CMake. All too often I find myself manually going through directories removing files like ...
555
votes
3
answers
319k
views
What is the difference between using a Makefile and CMake to compile the code?
I code in C/C++ and use a (GNU) Makefile to compile the code. I can do the same with CMake and get a Makefile. However, what is the difference between using a Makefile and CMake to compile the code?
449
votes
6
answers
473k
views
Define a preprocessor macro through CMake
How do I define a preprocessor variable through CMake?
The equivalent code would be #define foo.
431
votes
17
answers
599k
views
How do I activate C++ 11 in CMake?
When I try to run a CMake generated makefile to compile my program, I get the error that
range based for loops are not supported in C++ 98 mode.
I tried adding add_definitions(-std=c++0x) to my ...
353
votes
12
answers
420k
views
Switching between GCC and Clang/LLVM using CMake
I have a number of projects built using CMake and I'd like to be able to easily switch between using GCC or Clang/LLVM to compile them. I believe (please correct me if I'm mistaken!) that to use Clang ...
315
votes
8
answers
861k
views
How do I add a linker or compile flag in a CMake file?
I am using the arm-linux-androideabi-g++ compiler. When I try to compile a simple "Hello, World!" program it compiles fine. When I test it by adding a simple exception handling in that code it works ...
298
votes
7
answers
124k
views
What are the differences between Autotools, Cmake and Scons?
What are the differences between Autotools, Cmake and Scons?
273
votes
20
answers
517k
views
CMake not able to find OpenSSL library
I am trying to install a software that uses cmake to install itself. When I run cmake .. on the command line, it gives me following error in the CMakeLists.txt on the line that says find_package(...
265
votes
4
answers
263k
views
cmake and libpthread
I'm running RHEL 5.1 and use gcc.
How I tell cmake to add -pthread to compilation and linking?
249
votes
3
answers
116k
views
How exactly does CMake work? Why are so many files generated?
What exactly was going on behind the scenes when for such a small CMakeLists.txt file,
cmake_minimum_required (VERSION 2.6)
project(Tutorial)
add_executable(Tutorial tutorial.cpp)
and such a small ...
231
votes
2
answers
147k
views
What is the idiomatic way in CMAKE to add the -fPIC compiler option?
I've come across at least 3 ways to do this and I'm wondering which is the idiomatic way. This needs to be done almost universally to any static library. I'm surprised that the Makefile generator in ...
219
votes
4
answers
159k
views
Creating a directory in CMake
In CMake, I want to create a directory if it doesn't already exist. How can I do this?
214
votes
5
answers
296k
views
Automatically add all files in a folder to a target using CMake?
I am considering switching a cross platform project from separate build management systems in Visual C++, XCode and makefiles to CMake.
One essential feature I need is to add automatically all files ...
197
votes
10
answers
263k
views
Copy file from source directory to binary directory using CMake
I'm trying to create a simple project on CLion. It uses CMake to generate Makefiles to build project (or some sort of it)
All I need to is transfer some non-project file (some sort of resource file) ...
194
votes
1
answer
153k
views
Cause CMAKE to generate an error
How can I get CMAKE to generate an error on a particular condition. That is, I want something like this:
if( SOME_COND )
error( "You can't do that" )
endif()
193
votes
5
answers
120k
views
Is it possible to get CMake to build both a static and shared library at the same time?
Same source, all that, just want a static and shared version both. Easy to do?
186
votes
10
answers
235k
views
OS specific instructions in CMAKE: How to?
I am a beginner to CMAKE. Below is a simple cmake file which works well in mingw environment windows. The problem is clearly with target_link_libraries() function of CMAKE where I am linking ...
179
votes
8
answers
183k
views
How to set warning level in CMake?
How to set the warning level for a project (not the whole solution) using CMake? Should work on Visual Studio and GCC.
I found various options but most seem either not to work or are not consistent ...
176
votes
9
answers
249k
views
How do you add Boost libraries in CMakeLists.txt?
I need to add Boost libraries into my CMakeLists.txt. How do you do it or how do you add it?
173
votes
13
answers
130k
views
Using CMake, how do I get verbose output from CTest?
I'm using CMake to build my project. I have added a unit test binary which is using the Boost unit testing framework. This one binary contains all of the unit tests. I've added that binary to be run ...
160
votes
5
answers
65k
views
CMake target_link_libraries Interface Dependencies
I am new to CMake and a bit confused with the PUBLIC, PRIVATE and INTERFACE keywords related to target_link_libraries(). Documentation mentions that they can be used to specify both the link ...
155
votes
3
answers
173k
views
Most simple but complete CMake example [closed]
How should I structure my project, so that my CMake requires the least amount of maintainance in the future? For example, I don't want to update my CMakeList.txt when I am adding a new folder in my ...
154
votes
2
answers
56k
views
CMake target_include_directories meaning of scope
What is the meaning of the keyword PUBLIC, PRIVATE, and INTERFACE related to CMake's target_include_directories?
149
votes
5
answers
383k
views
How do I tell CMake to link in a static library in the source directory?
I have a small project with a Makefile which I'm trying to convert to CMake, mostly just to get experience with CMake. For purposes of this example, the project contains a source file (C++, though I ...
147
votes
31
answers
299k
views
CMake does not find Visual C++ compiler
After installing Visual Studio 2015 and running CMake on a previous project, CMake errors stating that it could not find the C compiler.
The C compiler identification is unknown
The CXX compiler ...