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.

92 questions
9
votes
2 answers

CMake find_package: where did it find the package?

In my CMake package, there is a call to find_package. This succeeds, great! However, it turns out to be the wrong version of the package. I now want to go and delete that package. However, I have no idea where the heck it is on my system, nor where…
Ben Farmer
  • 1,860
  • 15
  • 31
7
votes
1 answer

How to write cmake modules for "boost-like" multi-component library?

I'm currently writing a c++ library, that has several "sub libraries", like for example the boost library. Let's name the library "TestLib" and the sub libraries "Base" and "Ext", where Base contains come basic stuff, that doesn't depend an any…
6
votes
1 answer

How to Create Packages with CMake

. +-- MyPack | +-- Lib1 | | +-- include | | | +-- Lib1.h | | +-- src | | | +-- Lib2.cpp | | +-- CMakeLists.txt | +-- Lib2 | | +-- include | | | +-- Lib2.h | | +-- src | | | +-- Lib2.cpp | | +--…
r.stagi
  • 63
  • 1
  • 3
6
votes
1 answer

How to set specific CMAKE_C_OUTPUT_EXTENSION for cross-compiling configurations with CMAKE?

I am trying to setup a toolchain file for cross compilation with CMake 3.12.0 version. My object files have a different extensions than .obj on Windows and .o in UNIX. Thus, I set my CMAKE_LANG_OUTPUT_EXTENSION to .src. Unfortunately, this variable…
John Smith
  • 707
  • 1
  • 10
  • 36
6
votes
0 answers

Python C Extension: Fatal Python error: PyThreadState_Get: no current thread

I am trying to build a C based Python extension that uses a ffmpeg libraries. Since there are a bunch of libraries I have to import. I used CMake. I followed the instructions from python doc The build with CMake goes fine without any issues. But…
Guru Govindan
  • 1,287
  • 1
  • 13
  • 22
4
votes
1 answer

How to include two different versions of the same dependency in a CMake project?

I have ExternalProject in both versions 1.2 and 2.2 present in my system. ExternalProject is a CMake project and CMake finds the both versions without trouble when I ask for them. Command find_package(ExternalProject 1.2 EXACT) finds version 1.2 and…
4
votes
0 answers

How can I ignore all cmake dev warnings from subdirectories?

I am using a few external libraries that are included as git submodules using the add_subdirectory command. Some of them are using old versions of cmake and they're issuing warnings about policies CMP0048 and CMP0077. Is there a way to turn off all…
Person93
  • 1,004
  • 8
  • 22
4
votes
2 answers

Cmake FindBoost.cmake MinGW-W64: searching for library with incorrect name

I have built Boost 1.68 (using instructions from https://gist.github.com/sim642/29caef3cc8afaa273ce6, and adding link=static,shared to the b2 command line to also build shared libraries.) The libraries appear to build correctly, and I have set the…
Paul Belanger
  • 2,194
  • 11
  • 20
4
votes
0 answers

How to use "modern" CMake exported targets in the context of existing libraries

I'm updating a (very old) find-module of a library. So the situation is an existing shared library which uses CMake itself. Users might already have this installed somewhere, in package repos or whatever. Now they want to use this. The good way…
Flamefire
  • 3,954
  • 2
  • 22
  • 50
4
votes
2 answers

What's deprecated in KitWare's guide to Finding libraries in CMake?

I need to write a CMake FindXYZ-type module. Googling, I've found this guide: https://cmake.org/Wiki/CMake:How_To_Find_Libraries from Kitware, but there's a disclaimer about it being deprecated. Which significant changes, if any, have been made to…
einpoklum
  • 86,754
  • 39
  • 223
  • 453
3
votes
2 answers

How to use and link boost on macOS using CMake?

Thank you for all who helped! What finally worked was changing: set(CMAKE_CXX_COMPILER "gcc-10") set(CMAKE_C_COMPILER "g++-10") to: set(CMAKE_CXX_COMPILER "/usr/local/opt/llvm/bin/clang") set(CMAKE_C_COMPILER "/usr/local/opt/llvm/bin/clang++") I…
adisidev
  • 90
  • 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
  • 7,723
  • 5
  • 26
  • 76
2
votes
1 answer

Excluding cmake's own distribution modules with `find_package()`

Cmake includes various distribution modules (i.e., populated inside the Modules/ directory of a cmake installation; e.g., /usr/share/cmake-3.5/Modules/FindBoost.cmake). This creates challenges when developing code that includes internal libraries…
sircolinton
  • 5,486
  • 3
  • 16
  • 17
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
  • 1,535
  • 9
  • 14
2
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
  • 109
  • 1
  • 9
1
2 3 4 5 6 7