CMake (cmake) input files are written in the “CMake Language” in source files named CMakeLists.txt
or ending in a .cmake
file name extension.
Questions tagged [cmake-language]
112 questions
0
votes
0 answers
How to hide cmake compiler definitions -D from printing in the terminal
I have hundreds of compiler definitions added using add_compile_definitions(var=value......) to my root CMakeLists.txt which gets printed out in the commandline/terminal with -Dvar=value during build. I want to turn off the echo to hide the prints…

deb
- 15
- 7
0
votes
0 answers
Linker error : unresolved external symbol, Cmake issue
I don't have any experience with CMake, so sorry ahead if there's something I'm doing completely wrong here.
The directories I have on my project
CMakeLists.txt:
INCLUDE_DIRECTORIES(BEFORE
${PROJECT_SOURCE_DIR}/src
…

Dolev
- 1
0
votes
3 answers
Cmake string to get key value pairs from a string list containing key values separated by colon
I have a stringlist (input):
set(MY_LIST "A:1;B:2;C:3")
I want to fetch the key values using foreach and set them as cmake constants. Something like:
foreach(ITEM ${MY_LIST})
SET( )
endforeach()
So basically i want the end…

deb
- 15
- 7
0
votes
2 answers
0
votes
1 answer
How to set environment variables in CMake so that they can be visible at build time?
On macOS 12, I tried to set some environment variables in CMakeLists.txt file like this.
# Add environment variables
set(ENV{VK_ICD_FILENAMES} /Users/username/VulkanSDK/macOS/share/vulkan/icd.d/MoltenVK_icd.json)
set(ENV{VK_LAYER_PATH}…

Jaxon
- 164
- 9
0
votes
2 answers
CMake: what is the correct syntax for $ or $?
Using CMake version 3.20.1, I'm doing something that I consider to be relatively simple: verify that the value of cfg pass via -DCMAKE_BUILD_TYPE= is a valid configuration.
Referencing the CMake generator expressions docs, it appears that…

PfunnyGuy
- 750
- 9
- 22
0
votes
0 answers
Is it possible to refer to an additional .txt-file inside the CMakeLists.txt?
I have a CMakeLists.txt for my project. There are a few lines I want to exclude into a new seperate .txt-file.
Is there a command in cmake-language that refers to a .txt-file as input? (like \input in Latex)
Thank you!

Dnk8000
- 3
- 3
0
votes
0 answers
CMake relative path Libraries communication
Lets say that we have a directory which also has two libraries inside like :
/Example
-/libA:
CMakeLists.txt
source1.c
-/libB:
source2.c
source2.h
Is there any way, without having an external CMakeLists.txt file…

gregni
- 417
- 3
- 12
0
votes
0 answers
Alternative to GET_TARGET_PROPERTY(... LOCATION) when using older LibTool Macro
I want to generate a libtool file for a library that I'm building with CMake 3. I found this macro, which would have helped with an older version of CMake: https://gitlab.kitware.com/cmake/community/-/wikis/contrib/macros/LibtoolFile
Here's the code…

Crankycyclops
- 552
- 5
- 25
0
votes
0 answers
CMake list(APPEND...) switching forward slash to backslash
I'm running into a very strange issue with CMake list(APPEND ...). My script is the following (just an example):
cmake_minimum_required(VERSION 3.20)
include(CMakePrintHelpers)
project(exe)
file(WRITE ${PROJECT_NAME}.cpp "#include…

Uri
- 479
- 1
- 4
- 10
0
votes
1 answer
CMake add_custom_command() POST_BUILD generator expression expansion not working
I want to run a POST_BUILD action after the build (but only in the Debug configuration).
After reading add_custom_command docs and a possible solution I understood that I can "wrap" my COMMAND into $ generator expression (to be sure…

sthlm58
- 1,142
- 1
- 9
- 28
0
votes
1 answer
Ninja Make system not accepting GENERATED command
I have a set of assembly files which should be compiled by a special compiler. After this it should be added to the library created by the compiler i have set in CMAKE_C_COMPILER. it was working fine with Mingw Makefile system but not working with…

Deepan Muthusamy
- 7
- 4
0
votes
0 answers
Printing Interface library in cmake
How to print the interface library in cmake. Actually i want to do this for a debugging purpose.
so want to know how to print what are all the include directories in that interface library
I have a interface library A which is linked to 2 interface…

Deepan Muthusamy
- 7
- 4
0
votes
0 answers
Maximum limit on number of Interface libraries in cmake
does anyone know is there any maximum limit on the number of interface libraries
we can link to a executable target in cmake

Deepan Muthusamy
- 7
- 4
0
votes
0 answers
How to tell my CMake script to place .lib files in output/lib
Currently, when I build my windows project (dynamic library) using CMake, my .dll files go in ./output/bin, my .h files go in ./output/include, but my .lib files go only to ./lib.
Is there anything I can do to make my .lib files go to ./output/lib…

Luis Angel Urena Lopez
- 331
- 5
- 14