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

Hinting Find.cmake Files with a custom directory

In CMake, is there a way to make built-in Find scripts to prioritize a custom directory that we specify? Because especially in windows, module finding scripts usually can't detect the module in, for example visual studio directories. Therefore I…
deniz
  • 2,427
  • 4
  • 27
  • 38
11
votes
3 answers

Add quotation mark in CMake string

I am using CMake to create and build my project solution. i am using the following command to add a post build event to copy a .tlb from the local bin to the program bin. ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} POST_BUILD COMMAND xcopy /D /Y…
PowPowPowell
  • 255
  • 1
  • 2
  • 11
11
votes
1 answer

CMake "TARGET_LINK_LIBRARIES cannot find -lfoo" but it is in the same directory as another library

As mentioned above i have problems with compiling my c++ project (using CMake) which uses some dynamic libraries (.so). There are 3 libs in my directory (i.e. home/sources/lib/). When i only tell the compiler (in the CMake file) to use the first lib…
TryToSolveItSimple
  • 873
  • 1
  • 12
  • 23
11
votes
2 answers

Replacing values in CMake lists

I needed to replace a value in a CMake list, however there does not seem to be any support for this list operation. I've come up with this code: macro (LIST_REPLACE LIST INDEX NEWVALUE) list (REMOVE_AT ${LIST} ${INDEX}) list (LENGTH ${LIST}…
Přemysl J.
  • 307
  • 4
  • 11
11
votes
3 answers

Can CMake detect if I need to link to libm when using pow in C?

With some compilers, using pow and certain other functions in a C program requires linking to the m library. However, some compilers don't require this and would error out on linking to the m library. An almost identical situation exists for C++…
LB--
  • 2,506
  • 1
  • 38
  • 76
11
votes
1 answer

CMake with gmock

I just want to make sure that my understanding about CMakeLists.txt is correct. My dummy project structure: |-+ dummy |-+ CMakeLists.txt |-+ src |-- CMakeLists.txt |-- Converter.cpp |-- Converter.hpp |-- main.cpp …
dptd
  • 274
  • 1
  • 3
  • 12
11
votes
2 answers

Can we know the directory where the macro or functions are located in cmake

In CMAKE, it defines the following variables to indicate the directories of files: CMAKE_CURRENT_LIST_DIR CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_SOURCE_DIR They are useful when you process CMake scripts. However, none of them can tell you the…
feelfree
  • 11,175
  • 20
  • 96
  • 167
11
votes
5 answers

How to set cmake CXX variable on windows

I am getting the following error Working on: Microsoft Windows [Versión 6.1.7601] ErrorS: CMake Warning at CMakeLists.txt:4 (project): To use the NMake generator, cmake must be run from a shell that can use the compiler cl from the command line.…
user3808307
  • 2,270
  • 9
  • 45
  • 99
11
votes
4 answers

CMake link a shared library to static libraries

I am porting an AutoTools project to CMake. What AutoTools does: builds some static libraries builds some shared libraries and links static ones into shared builds an executable, links it to shared libraries What I've managed to do with…
Velkan
  • 7,067
  • 6
  • 43
  • 87
11
votes
1 answer

Is there a way for CMake to utilize dependencies generated by `swig -MM`?

SWIG generates wrapper code from your C/C++ in a desired target language (Python, Java, C#, etc) using an interface (.i) file that specifies the input code to be wrapped as described in the SWIG tutorial. CMake can be used to call swig in order to…
taranaki
  • 803
  • 9
  • 15
11
votes
2 answers

CMake cannot find a static library using relative file paths

I'd like to play around with the Allegro library, but I can't seem to get my test project to link properly. To be exact, I'm getting cannot find -l<...> errors, where <...> is a file I specified using target_link_libraries. (See below for…
vvye
  • 1,208
  • 1
  • 10
  • 25
11
votes
2 answers

CLion: Error:The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple test program

I'm trying to run CLion on windows 7 with MinGW but for some reason CMake can't compile the simple test program but when I create a simple hello world file it compiles just fine when I call the compiler directly instead of CMake. I already tried…
Jim Bransen
  • 111
  • 1
  • 1
  • 6
11
votes
6 answers

cmake - osx/mac - openssl brew

I am using the following cmake commands # Search OpenSSL find_package(PkgConfig REQUIRED) pkg_search_module(OPENSSL REQUIRED openssl) if( OPENSSL_FOUND ) include_directories(${OPENSSL_INCLUDE_DIRS}) message(STATUS "Using OpenSSL…
Helmut Januschka
  • 1,578
  • 3
  • 16
  • 34
11
votes
4 answers

Purpose of CMake ENDIF and ELSE arguments

In CMake the ELSE and ENDIF control flow functions take expressions as arguments. These are optional according to the documentation. What is the purpose of these then? Is it just to make the original IF expression clearer for maintenance purposes,…
Jake
  • 7,565
  • 6
  • 55
  • 68
11
votes
2 answers

OpenSSL compile from source using Cmake?

I would like to pull in OpenSSL to our cross platform project and compile from source code. We have many platforms (Windows, Mac, iOS, Android, Xamarin Andriod) so using maintaining/updating binaries can be a headache. We are using cmake. Has…
M W
  • 1,269
  • 5
  • 21
  • 31