Questions tagged [cmake-modules]

Use this tag for questions regarding CMake modules that are part of the CMake distribution, or loading custom CMake modules into the current CMake context.

CMake Modules are CMake source files (typically .cmake files) that can be loaded into the current context using the include() command. CMake provides many modules that can be used out-of-the-box; these are split into two general types:

  • Utility modules
  • Find modules

Utility modules are loaded using the include() command, while Find modules are loaded by calling the find_package() command. Custom user-defined modules can also be written and loaded in a similar manner, but their location must be specified in the CMAKE_MODULE_PATH variable.

132 questions
3
votes
1 answer

How do I specify an optional dependency in a CMake package configuration file?

I'm trying to specify correctly the dependencies in the MyLibConfig.cmake file of my project. In CMakeLists.txt I have something like this: find_package(aLib REQUIRED) find_package(bLib) So in MyLibConfig.cmake I wrote something…
rotolof
  • 33
  • 1
  • 3
3
votes
0 answers

How to make CTest run few tests within one executable

We have over 10 Google Test executables which, in sum, provide over 5000 test cases. So far, our CTest configuration used add_test command which resulted in each test executable being a single test from CTest point of view. Recently, we used the…
Adam Badura
  • 5,069
  • 1
  • 35
  • 70
3
votes
2 answers

find_package(Backtrace) behaves strangely

I'm looking at the documentation for the FindBacktrace module, and unlike with, say, FindThreads - I see no mention of a proper library target I can depend on, e.g. Backtrace::Backtrace. Is it really missing or just undocumented? Also, when I use…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
3
votes
1 answer

Modern CMake 3 with QT5 "Qt5::QtCore" but the target was not found

I am having an issue with CMake and a simple QT example. I am updating my CMake configuration to follow the modern way of doing it, meaning supporting CMake > v3.0. Here is my CMakeLists.txt cmake_minimum_required(VERSION…
Hugo Serrat
  • 149
  • 2
  • 12
3
votes
2 answers

What is the proper way to document a CMake module?

A quick Google search (...actually many rather extensive Google searches) have not been able to explain how to properly document a CMake module. What I'm looking for is a way to document custom CMake modules so that they work with the cmake…
tjwrona1992
  • 8,614
  • 8
  • 35
  • 98
3
votes
2 answers

Testing our CMake Modules

We created multiple additional functions for CMake. They became quite a lot, and we need to (unit) test them. There are simple ones, that are only variable bases like: function(join_list LIST GLUE) These can be tested with a custom CMake Script,…
kuga
  • 1,483
  • 1
  • 17
  • 38
2
votes
1 answer

Cmake FindMatlab does not find correct version

I am trying to setup a CMakeLists.txt under Windows to compile matlab-mex-files. But I struggle with find_package(Matlab) to select the correct version. I am using cmake 3.26.4 under Windows 10. I have matlab versions 8.2, 9.3, 9.12, and 9.13…
Gunter
  • 321
  • 4
  • 13
2
votes
1 answer

How to use check_prototype_definition in CMake

I am looking at the documentation of check_prototype_definition here: https://cmake.org/cmake/help/latest/module/CheckPrototypeDefinition.html check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE) FUNCTION - The name of the function…
eri0o
  • 2,285
  • 4
  • 27
  • 43
2
votes
0 answers

How to create and use Pre-compiled headers in CMake 3.15 for clang++/gcc

In my project there are some headers which almost using in all files. So, to increase the speed of building I've decided to use Pre-compiled headers. I'm using CMake 3.15 and clang++. In CMake 3.16 we can use target_precompile_headers(). But in 3.15…
Aravind
  • 41
  • 5
2
votes
0 answers

CMake Generator Expression not recognized by Ninja

I was trying to use a CMake Generator Expression such as: $,PROP_BAR>> This expression works fine when the Generator used is Visual Studio or Unix Makefiles but fails when the…
2
votes
1 answer

Cannot generate 32 bit configuration for Visual Studio 2019 with host=x86 or -A Win32

I am trying to configure cmake to build for 32bit and 64bit separately... So far 64bit is easy as I just need to add -A x64 cmake -G "Visual Studio 16 2019" -A x64 But I am not able to set 32bit arch. Official documentation suggest -A Win32 or…
AtiqGauri
  • 1,483
  • 13
  • 26
2
votes
0 answers

findFoo.cmake with transitive dependencies

I have a large pre-compiled c++ code base organized like so: Project0/ libA/ include/ libA.so libADependencies.txt -> depends on libB libB/ include/ libB.so libBDependencies.txt -> depends on…
Touloudou
  • 2,079
  • 1
  • 17
  • 28
2
votes
1 answer

Cmake is unable to find boost_pyhton libraries in Homebrew

I am trying to build a C++ code on Mac. I am using CMake for my setup. This is my file (note, I get an error with python3.7, python37, python, but more on that below): find_package(Boost COMPONENTS python3.7) message("Includes:…
David R.
  • 855
  • 8
  • 17
2
votes
2 answers

Cmake: accessing qtvirtual keyboard module

Can anyone do a simple example of including qtvirtualkeyboard module into a cmake file? I want to access the classes but I cannot figure out how to include it.
kpo8
  • 59
  • 1
  • 7
2
votes
2 answers

Set LINK_FLAGS for INTERFACE libraries in cmake

I am working on a header-only C++11 library which uses modern CMake. By "modern," I mean not only using CMake v3.0+ but also trying to use as much as possible the best practices in Daniel Pfeifer's talk. I have done some research on my question, but…
Arda Aytekin
  • 1,231
  • 14
  • 24
1
2
3
8 9