A mechanism in CMake allowing users to define build steps other than compiling libraries and linking executables, supporting a more generalized concept of a build. Involves the add_custom_command and add_custom_target commands.
Questions tagged [cmake-custom-command]
104 questions
1
vote
1 answer
How to add_custom_command() for the CMake build process itself?
Is there any way to do the equivalent of add_custom_command (run an external script when a certain file changes), but for something that should be run during CMake script execution itself? (That is, for dependency graph generation.)
We have our…

R.M.
- 3,461
- 1
- 21
- 41
1
vote
1 answer
cmake add_custom_command and DEPENDS/TARGET
I have this in my toplevel CMakeLists.txt:
add_subdirectory (src) # add_executable (${PROJECT_NAME} ${_SOURCES})
add_subdirectory (data)
In data subdirectory I want to create a file, when ${PROJECT_NAME} is build. The following doesn't work,…

Joel
- 1,805
- 1
- 22
- 22
1
vote
2 answers
cmake add_custom_command that is executed on every build
I want to have something in CMake that will be executed whenever I enter make
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/build_date.cc
PRE_BUILD
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/mk_build_date.py
…

Alexander Oh
- 24,223
- 14
- 73
- 76
0
votes
2 answers
How to generate source files during the build time using python script in CMake and build them successfully
I have a requirement where I need to auto generate the list of source files from a python script during the build time and build them. Please note that the file names are generated within the python script and the list is huge. Here is…

Sriram
- 1
- 2
0
votes
1 answer
warning MSB8065: specified output has not been created
Any "custom build" generated with Cmake is not having the output file generated.
Apparently the output directories are lowercase.
This only happens on ASUS computer with Ryzem 9 7950X
I have no idea what else to do to resolve this issue and get back…

newbye
- 5
- 4
0
votes
1 answer
Shipping a library-only package with CMake
I want to have my own little library and collect any useful code that I manage to write in the future. My idea is to have it structured like lib-boost and whenever I start a new project, I also use this library if necessary. Lets call this…

DEKKER
- 877
- 6
- 19
0
votes
1 answer
Is the output location of CMake's add_custom_command different on Windows and Linux?
I'm using add_custom_command() in CMakeLists.txt in a project of mine. I seem to have worked it out nicely for building on Linux, but for when I try and build on Windows, something strange happens.
Here's a snippet from a subdirectory's…

einpoklum
- 118,144
- 57
- 340
- 684
0
votes
0 answers
CMake BOOL generator expression evaluates an empty list to true
I'm trying to add a custom command target to my build, and I'm trying to append a list of arguments based on a variable which contains itself a generator expression. My code looks like this:
list(
APPEND MY_INCLUDE_DIRECTORIES
…

Jazzwave06
- 1,883
- 1
- 11
- 19
0
votes
1 answer
How to replace FetchContent_Declare to copy the already cloned local repo
We are using CMakeLists.txt for compiling our huge code base.
We are cloning the repo at compilation stage, using FetchContent_Declare as below.
FetchContent_Declare(miniz
GIT_REPOSITORY https://github.com/richgel999/miniz.git
GIT_TAG …

Darshan Belanke
- 13
- 9
0
votes
0 answers
CMAKE: How to get multiple files generated by a add_custom_command
using CMake add_custom_command, we cannot automatically find the output files.
the script generate many cpp/h files but it is base on some templates. Of course the template change from time to time.
so we have:
set(THE_SCRIPT…

Daniel Anderson
- 67
- 5
0
votes
0 answers
cmake add_custom_command POST_BUILD doesn't work as expected
I generate a iOS framework in my project and pass the GCC_GENERATE_DEBUGGING_SYMBOLS to generate dsym for the built framework. The dsym gets generated as expected, but when I try to copy it to another location it doesn't fully work. It copies only…

rstr1112
- 308
- 4
- 13
0
votes
0 answers
How can i link a custom library with Cmake?
im new in Cmake, im trying to link a library to a project using Cmake, the following code is this:
code of the header:
my_library.h
#ifndef MY_LIBRARY
#define MY_LIBRARY
int get_random_number();
#endif
implementation of the…

Jairo Qlmbqn
- 1
- 1
0
votes
0 answers
How to change the normal variable in parent level CMakeLists
I need to compile several open sources, one of them has CMakeLists.txt which includes
##############################################################
# Output…

caorenxxy
- 1
- 1
0
votes
0 answers
How to execute custom command before each compile command in CMake
I'm trying to create a CMake script that will 'bind' so to speak "my custom command" action to every compile command.
Example scenario
I have 3 sources:
source1.c
source2.c
main.c
This is what I expect to happen:
"my custom command" -> compile:…

fskoras
- 68
- 7
0
votes
0 answers
CMakeList esp-idf run python script each build
I am using ESP32 with eclipse esp-idf plugin. It uses CMake to build the application. I want to run on each build a python script. In standard C eclipse project I do using prebuild steps in project configuration. In case of esp-idf project there is…