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
1
vote
0 answers
include_directories doesn't work when adding a new language in CMake
I am trying to add a new C-like language which called "foo" in CMake, which needs to use a specific modifed complier
I tried from Generic rule from makefile to CMake and it seems work when compiling a single foo file.
However I found that command…

yao
- 11
- 2
1
vote
1 answer
Optional dependencies for add_custom_command
If I include non-existent files in DEPENDS section of add_custom_command, it fails. Is there a way to specify the dependency may not exist, but if it's created the command should be rerun?
Specifically, I am using Coco/R, which requires Parser.frame…

Alexey Romanov
- 167,066
- 35
- 309
- 487
1
vote
1 answer
CMake: set_target_properties fails with target defined by generator expression
I'm having a problem with the cmake Generator Expression TARGET_NAME_IF_EXISTS. With this CMakeLists.txt:
cmake_minimum_required(VERSION 3.13.0)
option(SLIB_BUILD_STATIC "" ON)
project(slib VERSION 1.0)
add_library(slibObjects OBJECT…

Stewart
- 4,356
- 2
- 27
- 59
1
vote
2 answers
Can I control sources exclusion from target_sources in CMake?
I am new in CMake and I was wondering whether there is a possibility to exclude certain sources from target_sources() based on a variable.
Let's say I have this below
target_sources(myTarget
PUBLIC
PRIVATE
myDir1/src/a.c
…

ndarkness
- 1,011
- 2
- 16
- 36
1
vote
2 answers
How to call a cmake method from shell script?
I have a parameterised function in mytestprogram.cmake written like below:
function(get_output_from_input output input)
set(${output} "test" PARENT_SCOPE)
endfunction()
Question:
How do I call the cmake method get_output_from_input from a…

TheWaterProgrammer
- 7,055
- 12
- 70
- 159
1
vote
3 answers
How to append semicolon (;) to cmake string
In cmake 3.19.2 i try to add semicolon to string by the following way:
cmake_minimum_required(VERSION 3.12)
project(some_project)
#--------------------------------------------------------------------
# Set CPP…

Vladimir Pogonin
- 83
- 1
- 4
1
vote
0 answers
Adding a library with CMake with generated source files
tl;dr;
When using ADD_LIBRARY in CMake it will check during cmake .. that all the source files exist. I have some that are generated during compile time. Is there a way to force CMake to ignore the missing files since they will exist when they are…

Questionable
- 768
- 5
- 26
1
vote
1 answer
How can I detect what version of macOS my Cmake code is running on?
I need to determine what version of MacOS the cmake file is running on.
if(BIGSUR)
# do something
else()
# do something else
endif()

rTanna
- 31
- 5
1
vote
1 answer
Constraining Values with ComboBoxes in CMake (cmake-gui)
I encountered CMake project where cache entry in cmake-gui was presented as combobox. But I can't find this project. How to add cache entry to CMakeLists.txt with values constrained with combobox?

stnk
- 13
- 4
1
vote
2 answers
Problem using Qt4 with find_package of CMake, inside a macro
I have defined the following macro in CMake (version 3.10):
macro(configureQt4 requiredVersion selectedPackages)
message(STATUS "selectedPackages: ${selectedPackages}")
find_package(Qt4 ${requiredVersion} COMPONENTS ${selectedPackages}…

Soo
- 885
- 7
- 26
1
vote
1 answer
How can I remove the file extension from the object name in the build step?
CMAKE__COMPILE_OBJECT is a variable to set compile rules.
set(" -o

linuxUser123
- 529
- 3
- 17
0
votes
1 answer
Update the list defined in a top-level CMakeLists.txt in a .cmake function called from sub directory CMakeLists.txt file
I am trying to use a .cmake file to update a global list to collect all the library names and use that list to link all the libraries from the top-level CMakeLists.txt file but unfortunately at the end I see the list is empty. Please see the…

Sriram
- 1
- 2
0
votes
0 answers
how to include .node extentions in cmake
can I kindly ask you what all do i need to put into cmakelists.txt if i have fresh project?
I have compiled node-rfc extention of node.js so now i have the build folder (c:\Qt\nodejs\node_modules\npm\node_modules\node-rfc\build\Release) with files…

Jiri Zaloudek
- 326
- 3
- 19
0
votes
1 answer
CMake Error: Unknown Language comes while try to build
I am trying to compile an really old piece of code- wireshark version 1.9.2, on Ubuntu.
when i run the command cmake .. on it the following error shows up.
CMake Error at /usr/share/cmake-3.16/Modules/CheckIncludeFiles.cmake:76 (message):
Unknown…

Dying Falcon
- 3
- 2
0
votes
1 answer
Why is a new file added in visual studio cmake project a miscellaneous files?
Part of teh CMakeLists.txt are as followed:
add_library(pslite)
file(GLOB_RECURSE SOURCE "src/*.cc")
target_include_directories(pslite PUBLIC "${PROJECT_SOURCE_DIR}/include/")
target_sources(pslite PRIVATE ${SOURCE})
I am using vs2022 to develop…

Abilyf
- 1
- 1