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
17
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
  • 2,387
  • 1
  • 25
  • 44
9
votes
1 answer

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…
Michael
  • 1,263
  • 1
  • 12
  • 28
8
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…
8
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
  • 93
  • 1
  • 1
  • 6
7
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
  • 777
  • 2
  • 14
  • 37
6
votes
1 answer

What does FindPackageHandleStandardArgs do exactly?

I am trying to write a Find Module for a package that I have installed. But I am having trouble understanding the CMake functions. Here is a snippet of my code. find_package(PkgConfig) pkg_check_modules(PC_zcm QUIET zcm) find_path(zcm_INCLUDE_DIR …
shawn_WWW
  • 71
  • 1
  • 5
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…
Gatothgaj
  • 1,633
  • 2
  • 16
  • 27
5
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…
Mikko Koivunalho
  • 331
  • 2
  • 14
4
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
  • 162
  • 1
  • 15
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,354
  • 14
  • 23
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
  • 5,313
  • 3
  • 35
  • 70
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
  • 118,144
  • 57
  • 340
  • 684
3
votes
0 answers

Exporting and packaging prebuilt libraries in cmake

instead of asking a question directly, I'll expose my use case and the way I tried (but failed) to solve it. Say I have: 3 shared libraries A, B and C A require B and C A comes with a set of headers That's it, no extra information, it's provided…
Etienne M
  • 604
  • 3
  • 11
3
votes
0 answers

librsvg - cmake module debug mode appends a suffix

I'm trying to get a native Windows build working in which we depend on librsvg-2. It's correctly installed through vcpkg. We usually build with cmake and have made a custom module to find this library. This works great in the unix world, but not…
Baklap4
  • 3,914
  • 2
  • 29
  • 56
3
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
  • 6,536
  • 3
  • 21
  • 19
1
2 3
8 9