Questions tagged [cmake]

CMake is a cross-platform, open-source build system generator. It generates files for build systems like native makefiles, ninja-build and project files for several integrated development environments.

CMake is a cross-platform, open-source build system generator. It generates files for build systems like native makefiles, ninja-build and project files for several integrated development environments.

It is often used along with , and .

Official

Quick Start / Howtos

Wisdom of the Stack

Books

27471 questions
59
votes
2 answers

What does the `-H.` option means for CMake?

This answer to a former question on CMake shows this command line: cmake -H. -Bbuild -G "MSYS Makefiles" What task does the -H. option perform here? cmake --help says that -H prints the help... I am using CMake 3.2.3.
Eleno
  • 2,864
  • 3
  • 33
  • 39
59
votes
4 answers

Getting a CMake Error: Cannot specify link libraries for target which is not built by the project

I am implementing CMake in my code but I'm getting the error Cannot specify link libraries for target "Qt5::Widgets" which is not built by the project Below are the contents of the CMakeLists.txt: #Specify the version being used aswell as the…
user3859872
  • 777
  • 2
  • 9
  • 16
58
votes
3 answers

Optimize in CMake by default

I have a C++ project which uses CMake as its build system. I'd like the following behavior: If cmake is invoked as cmake .., then CMAKE_CXX_FLAGS is -O3 -Wall -Wextra If cmake is invoked as cmake .. -DCMAKE_BUILD_TYPE=Debug, then CMAKE_CXX_FLAGS is…
marmistrz
  • 5,974
  • 10
  • 42
  • 94
58
votes
7 answers

Combining several static libraries into one using CMake

I have a very similar problem to one described on the cmake mailing list where we have a project dependent on many static libraries (all built from source in individual submodules, each with their own CMakeLists.txt describing the build process for…
learnvst
  • 15,455
  • 16
  • 74
  • 121
58
votes
1 answer

In cmake, what is a "project"?

This question is about the project command and, by extension, what the concept of a project means in cmake. I genuinely don't understand what a project is, and how it differs from a target (which I do understand, I think). I had a look at the…
quant
  • 21,507
  • 32
  • 115
  • 211
58
votes
10 answers

CMake missing modules directory

I've installed CMake 2.8.11.2 package from CMake's website for Mac 64-bit. We recently upgraded a project from Qt 4 to Qt 5 and the CMake upgrade is mandatory for CMake to use Qt 5. However, when I type cmake . I get the following error: CMake…
roundtheworld
  • 2,651
  • 4
  • 32
  • 51
58
votes
1 answer

If value not equal in cmake 2.8

Short version: I have build options that only work on one platform. The autotools file I'm converting form has a check of the form if test "$platform_linux" != "yes". Can I do the same thing in my CMakeLists.txt (test if the value is NOT…
simont
  • 68,704
  • 18
  • 117
  • 136
57
votes
6 answers

CMake + GoogleTest

I just downloaded googletest, generated its makefile with CMake and built it. Now, I need to use it in my testing project. With CMake, I have been advised not pointing to gtest libraries directly (using include _directories or link_directories) but…
Korchkidu
  • 4,908
  • 8
  • 49
  • 69
57
votes
5 answers

Handling header files dependencies with cmake

I am using CMake on a small C++ project and so far it works great... with one twist :x When I change a header file, it typically requires recompiling a number of sources files (those which include it, directly or indirectly), however it seems that…
Matthieu M.
  • 287,565
  • 48
  • 449
  • 722
57
votes
2 answers

CMake finds Boost but the imported targets not available for Boost version

I use CMake to find Boost. Boost is found, but CMake errors out with Imported targets not available for Boost version See the complete error (from macOS) below. What am I doing wrong? CMake Warning at…
Sounak
  • 4,803
  • 7
  • 30
  • 48
56
votes
11 answers

How to reinstall the latest cmake version?

I would like to install cmake the latest version, on Linux environment. I have cmake version 3.5 installed and is not supported by some applications. I tried to upgrade it by uninstalling the current version. But when I reinstall with sudo apt-get…
Juniar
  • 1,269
  • 1
  • 15
  • 24
56
votes
4 answers

How to modify environment variables passed to custom CMake target?

Perhaps I am missing something obvious, but I can't seem to figure out how to explicitly set environment variables that can be seen by processes launched through add_custom_target(). I tried the following: set(ENV{PATH}…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
56
votes
2 answers

Where does CLion store executable files?

I install the CLion on a Ubuntu 14.04. I build my first project with help CMakeLists.txt: Source file: #include using namespace std; int main() { cout << "Hello, World!" << endl; return…
Denis
  • 3,595
  • 12
  • 52
  • 86
56
votes
5 answers

How do you concatenate string in cmake

Is there a way to concatenate strings in cmake? I have a folder that only contains .cpp files with main methods. I thought this would be easy by just using a foreach through all src files. This is what I've got this…
sighol
  • 2,678
  • 6
  • 28
  • 34
55
votes
3 answers

How to support both vcxproj to cmake on a project?

I'm developing cross-platform c++ project. The original idea is to work with msvc2010 and later compile for other systems with the help of CMake and Hudson. It doesn't seem to be convenient manually change CMake files after changes in studio…
tikkerey
  • 663
  • 1
  • 6
  • 7