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
11
votes
1 answer

Pass a list of prefix paths to ExternalProject_Add in CMAKE_ARGS

I have a CMake project that I want to build with the ExternalProject_Add command. In the CMAKE_ARGS parameter, I want to pass a list of prefix paths which contain CMake packages that are needed by the external project. set(CMAKE_PREFIX_PATH…
tomvodi
  • 5,577
  • 2
  • 27
  • 38
11
votes
2 answers

How to make imported target GLOBAL afterwards?

From the FindBoost.cmake module of CMake 3.8: foreach(COMPONENT ${Boost_FIND_COMPONENTS}) if(_Boost_IMPORTED_TARGETS AND NOT TARGET Boost::${COMPONENT}) string(TOUPPER ${COMPONENT} UPPERCOMPONENT) if(Boost_${UPPERCOMPONENT}_FOUND) …
Torbjörn
  • 5,512
  • 7
  • 46
  • 73
11
votes
1 answer

How to compile with different compile options for different files in CMAKE?

I have a project like this: |--CMakeLists.txt(1) |--File1.cpp -W -W-all |--Folder1 |--CMakeLists.txt(2) |--File2.cpp -W -W-all -fno-rtti As you can see above, File2.cpp needs to compile with -fno-rtti whereas the other files should compile…
Utkarsh Kumar
  • 567
  • 1
  • 5
  • 17
11
votes
2 answers

Formatting CMakeLists.txt with Clang-Format

Is there a way to get clang-format to correctly format a CMake file? I have a .clang-format file with Language: Cpp and BasedOnStyle: Google. No other language is specified. Ideally, I would like to customize the style, however the biggest problem…
Unapiedra
  • 15,037
  • 12
  • 64
  • 93
11
votes
1 answer

Qt Cmake configuration has no path to a C++ compiler set

The warning I get is: "Qt Cmake configuration has no path to a C++ compiler set, even though the toolkit has a valid tool chain." I am not sure how to change the CMake configuration so that it has a path to the compiler. I do have a C++ compiler…
Shubby
  • 131
  • 1
  • 5
11
votes
1 answer

What is MODULE library type in cmake?

cmake add_library documentation says, SHARED libraries are linked dynamically and loaded at runtime. MODULE libraries are plugins that are not linked into other targets but may be loaded dynamically at runtime using dlopen-like…
sherlock
  • 2,397
  • 3
  • 27
  • 44
11
votes
1 answer

cmake find_path not working as expected

I have the following CMake script, it works: find_path( GLES_SDK_INCLUDE_DIR NAMES "GLES2/gl2.h" PATHS "${CMAKE_FRAMEWORK_PATH}/include") But this one returns a -NOTFOUND: find_path( GLES_SDK_INCLUDE_DIR NAMES "gl2.h" PATHS…
CDZ
  • 813
  • 1
  • 11
  • 27
11
votes
3 answers

CMake is dropping the item c++

I work on windows with QtCreator .I try to use freeglut/opengl2 all libs have been build and install properly But have undefined references to all glut components certainly due to : Targets may link only to libraries. CMake is dropping the…
Otha
  • 121
  • 1
  • 1
  • 6
11
votes
3 answers

CMake graphviz auto generated

I know the common way to generate a CMake project dependencies graph by the CLI: cmake --graphviz=[file] But is there a way for it to be autogenerated by just setting a flag or command within a CMakeList? The idea is for the CMakeLists.txt itself…
Javier Calzado
  • 111
  • 1
  • 1
  • 4
11
votes
1 answer

Can clang static analyzer (scan-build) be used with cmake --build?

I'd like to use the clang static analyzer command line tool scan-build with the convenience of cmake --build. Most of the resources I found online seem to indicate you need a two-step process: scan-build cmake . scan-build make For example for this…
phoenix
  • 7,988
  • 6
  • 39
  • 45
11
votes
2 answers

CMake library dependencies

This may be a tad hard to explain in full. I have setup a directory structure for a series of C++ libraries I am writing. I intend to use CMake to handle building these libraries. For the most part these libraries are completely separate…
tomasbasham
  • 1,695
  • 2
  • 18
  • 37
11
votes
1 answer

How to "install" Python code from CMake?

I have a mainly c++ project that I use CMake to manage. After setting cmake_install_prefix and configuring, it generates makefiles which can then be used to build and install with the very standard: make make install At this point, my binaries end…
David Doria
  • 9,873
  • 17
  • 85
  • 147
11
votes
1 answer

Mixing C++ and Fortran

Is there a way to use the Clang compiler while mixing C++ and Fortran? Until now I use cmake with project(mixing CXX Fortran) but this triggers the use of g++. -- The CXX compiler identification is GNU 6.2.0 CMakeLists.txt of my project with…
DrDirk
  • 1,937
  • 3
  • 25
  • 36
11
votes
3 answers

Why CMake adds unnecessary libraries to Visual Studio projects?

I have this simple CMake file cmake_minimum_required(VERSION 2.8) project(test) set(SOURCES source.cpp) add_executable(test ${SOURCES}) where source.cpp is a simple hello world program. I then generate the Visual Studio project cmake -G"Visual…
Ali
  • 1,001
  • 2
  • 14
  • 32
11
votes
2 answers

which suits linux ? GNU make vs cmake vs codeblocks vs qmake

In front of me some different Technologies and I'm confused between them. GNU make, CMAKE, Qmake, Code::blocks methodology Code::Blocks uses a custom build system, which stores its information in XML-based project files, but can optionally use…
Ismail Marmoush
  • 13,140
  • 25
  • 80
  • 114