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
82
votes
5 answers

How can I make CMake use GCC instead of Clang on Mac OS X?

I can't find any info on it, but only the other way around (e.g., how to set CMake to use clang). I've installed gcc-4.8 using brew, setup all dependencies, headers, etc, and now CMake refuses to use gcc. I've set my bash profile with both aliases…
Ælex
  • 14,432
  • 20
  • 88
  • 129
81
votes
14 answers

Could not find module FindOpenCV.cmake ( Error in configuration process)

I wrote a CMakeLists.txt for a project in C++, which uses OpenCV libraries. When I try to create the project using cmake, I get the next configuration problem: CMake Error at CMakeLists.txt:15 (find_package): Could not find module FindOpenCV.cmake…
Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
81
votes
6 answers

CMake support "make uninstall"?

I am trying to find some sudo-free solution to enable my users install and unistall my application. Using set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/opt/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}/") SET(CMAKE_INSTALL_RPATH…
katang
  • 2,474
  • 5
  • 24
  • 48
81
votes
3 answers

Overriding a default option(...) value in CMake from a parent CMakeLists.txt

I am trying to include several third-party libraries in my source tree with minimal changes to their build system for ease of upgrading. They all use CMake, as do I, so in my own CMakeLists.txt I can use add_subdirectory(extern/foo) for libfoo. But…
user79758
81
votes
6 answers

I have 2 versions of python installed, but cmake is using older version. How do I force cmake to use the newer version?

I have 2 versions of python installed, but cmake is using older version. How do I force cmake to use the newer version?
Sanjeev
  • 811
  • 1
  • 6
  • 5
80
votes
13 answers

rc.exe no longer found in VS 2015 Command Prompt

I just installed Windows 10 Creators Update (version 10.0.15063). I have multiple versions of Visual Studio installed (2012, 2013, 2015 and 2017). I installed VS 2017 only a couple weeks ago. Problem CMake (version 3.8.1) no longer finds the C/C++…
François Beaune
  • 4,270
  • 7
  • 41
  • 65
79
votes
5 answers

Why am I warned that the "CMAKE_TOOLCHAIN_FILE" variable is not used by the project?

When I build some third-party code, I am seeing the following warning from CMake: CMake Warning: Manually-specified variables were not used by the project: CMAKE_TOOLCHAIN_FILE What is causing this warning? I checked the configuration files,…
pleerock
  • 18,322
  • 16
  • 103
  • 128
78
votes
2 answers

How do you rename a library filename in CMake?

Some libraries follow different conventions for their filenames, such as the PAM libs -- pam_unix.so, not libpam_unix.so. How do you override the target library filename in CMake to get something like new_thing.so instead of the default…
CivFan
  • 13,560
  • 9
  • 41
  • 58
78
votes
14 answers

Cmake is not able to find Python-libraries

Getting this error: sudo: unable to resolve host coderw@ll -- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message): Could NOT…
Amit Pal
  • 10,604
  • 26
  • 80
  • 160
77
votes
3 answers

Listing include_directories in CMake

I have a cmake build in which I'm searching for a bunch of dependencies, i.e. I have many instances of: FIND_PACKAGE(SomePackage) if(SOMEPACKAGE_FOUND) include_directories(${SOMEPACKAGE_INCLUDE_DIR}) …
rcv
  • 6,078
  • 9
  • 43
  • 63
76
votes
3 answers

CMake with include and source paths - basic setup

I'm trying to set up a test project looking like my own project just to get things working first and it looks like this: /MainProject/inc/main.h /MainProject/src/main.cpp /LibProject/inc/test.h /LibProject/src/test.cpp I've found some tutorials,…
bitgregor
  • 1,085
  • 2
  • 14
  • 17
76
votes
5 answers

How to set the LDFLAGS in CMakeLists.txt?

I set the CFLAGS in CMake by CMAKE_C_FLAGS. Is something like this to set LDFLAGS?
hich9n
  • 1,578
  • 2
  • 15
  • 32
76
votes
3 answers

CMake add_custom_command not being run

I'm trying to use add_custom_command to generate a file during the build. The command never seemed to be run, so I made this test file. cmake_minimum_required( VERSION 2.6 ) add_custom_command( OUTPUT hello.txt COMMAND touch hello.txt DEPENDS…
Jonathan Sternberg
  • 6,421
  • 7
  • 39
  • 58
76
votes
2 answers

Passing an argument to CMAKE via command prompt

I have a makefile for my project, with which I can pass an argument that controls certain build flags. Now I want to do the same using CMake. I have created CMakeLists.txt but I don't know how to pass the argument and check for the argument value in…
Meluha
  • 1,460
  • 3
  • 14
  • 19
76
votes
2 answers

Why does CMake make a distinction between a "target" and a "command"?

In CMake semantics there is some sort of distinction between "targets" and commands" that is baffling me. In Makefiles, there is no such distinction: targetname:dependency command i.e. Targets correspond to a generated file of the same…
Andrew Wagner
  • 22,677
  • 21
  • 86
  • 100