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

How to pass arguments to memcheck with ctest?

I want to use ctest from the command line to run my tests with memcheck and pass in arguments for the memcheck command. I can run ctest -R my_test to run my test, and I can even run ctest -R my_test -T memcheck to run it through memcheck. But I…
dcmm88
  • 1,445
  • 1
  • 12
  • 30
11
votes
2 answers

In CMake how do I make `TARGET_LINK_LIBRARIES` suppress warnings from 3rd party library code?

In CMake, you can make TARGET_INCLUDE_DIRECTORIES() add include directories as system include directories (i.e. use -isystem) in order to not let warnings pop up which have their root in 3rd party code: TARGET_INCLUDE_DIRECTORIES(mytarget …
frans
  • 8,868
  • 11
  • 58
  • 132
11
votes
2 answers

Obtaining the CUDA include dir in C++ targets with native-CUDA-support CMake?

In CMake version 3.8, native support for CUDA as a language was introduced. When a project has CUDA as one of its languages, CMake will proceed to locate CUDA (e.g. it locates the nvcc binary). As long as you only compile CUDA code - this is enough.…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
11
votes
2 answers

What's the ideal cmake installation directory structure for a relocatable multiple platform installation?

CMake install takes destination dirs, often using GNUInstallDirs to load standard values for the destination names. For example: include(GNUInstallDirs) install(TARGETS Foo EXPORT Foo INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} …
johnb003
  • 1,821
  • 16
  • 30
11
votes
3 answers

How to set qt5 path with cmake find_package on Windows?

I am adding QT like this: find_package(Qt5 COMPONENTS Core Quick REQUIRED) ... target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Quick ${OpenCV_LIBS}) but cmake finds some python artifacts instead of expected C:\QT... How can I change this?…
Stepan Yakovenko
  • 8,670
  • 28
  • 113
  • 206
11
votes
2 answers

Android NDK CMake uses C++17

The Problem I'd like to use decomposition declarations in my Android NDK project. Therefore clang needs to be called with -std=c++17. Currently my code compiles without errors, but Clang prints the following warning: warning: decomposition…
Scindix
  • 1,254
  • 2
  • 15
  • 32
11
votes
3 answers

CMake install header files and maintain directory hierarchy

Using cmake 2.8 I would like to maintain the directory hierarchy while copying the header files from the source to the destination directory. For example, the header file that needs to be copied are abc/1.h, def/2.h and they should also be copied in…
infoclogged
  • 3,641
  • 5
  • 32
  • 53
11
votes
2 answers

Setting CMAKE_CXX_STANDARD to various values

I have a C++ library, that's intended to be usable across several compiler versions and several C++ standards. I have tests for this library - and I need to ensure that these tests pass for this matrix of compilers/versions that I wish to support. I…
Barry
  • 286,269
  • 29
  • 621
  • 977
11
votes
1 answer

MacOS - clang address sanitizer fails to link

I have been trying to use Clang's address code sanitizer, but the linker will not have it. The linker may be "ld", though my CMAKE settings assure me that clang is the linker. Added -fsanitize=address to compiler and linker flags. Error: Undefined…
iseale
  • 111
  • 1
  • 4
11
votes
1 answer

CMake transitive dependency is not found via find_package()

I have static library Foo, static library Bar that depends on Foo and executable Baz that depends on Bar. Relevant sections from Foo CMakeLists.txt: # Specifying files to copy during "make install" command. install(TARGETS Foo EXPORT FooConfig …
user3624760
11
votes
1 answer

cmake doesnt rebuild externalProject on changes

I have the following CMakeLists.txt: cmake_minimum_required( VERSION 3.0) project(addProject) include (ExternalProject) set(ExternalProjectCMakeArgs -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} …
Jeremy Fouriaux
  • 151
  • 1
  • 7
11
votes
3 answers

CMake Error: Could not create named generator Visual Studio 15 2017 Win64-T

I want to build this project :https://github.com/xmrig/xmrig according to the instructions here: https://github.com/xmrig/xmrig/wiki/Windows-Build, but when I try to run command below: C:\Users\dmin\Documents\xmrig-2.3.1\build>cmake .. -G "Visual…
Nizar
  • 1,112
  • 4
  • 17
  • 29
11
votes
1 answer

CMake set environment variable

According to the CMake documentation https://cmake.org/cmake/help/v3.3/command/set.html One can do set(ENV{} ) but this gives the result set(ENV{FOO} foo) message("variable is $ENV{FOO}") at configure time variable is foo But at…
Pedro Vicente
  • 681
  • 2
  • 9
  • 21
11
votes
1 answer

How to use Jenkins declarative pipeline to build and test on multiple platforms

I'm trying to do something that I feel should be simple to do, but I can't figure out how. Basically I have a Jenkins master (running on Linux) and two slaves, one on Windows and the other on macOS. I want to build my project on all 3 platforms and…
11
votes
1 answer

cannot find boost_process cmake find_package

I'm trying to import boost libraries into my C++ project, and for some reason it cannot find Boost.Process, although it finds the others. My CMakeLists.txt file: cmake_minimum_required(VERSION 3.9 FATAL_ERROR) set (PROJECT_NAME "test-stuff"…
Nate C
  • 211
  • 2
  • 7