Questions tagged [add-custom-target]

15 questions
4
votes
1 answer

How to use CMake cached variables inside subprocess called by custom target?

My project contains a custom target which generates some output via .cmake script. It looks like this: add_custom_target(TargetName COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/script.cmake BYPRODUCTS…
2
votes
1 answer

Visual Studio: "clean" command executes custom build target

I'm struggling with the following problem and I don't get it. I have a Visual Studio Xamarin project (VS 2019 on Windows 10). In the project file I defined a custom build target:
Jimmie
  • 61
  • 1
  • 5
2
votes
0 answers

Cython, CMake and out-of-source build results in double compilation

I have a big project containing multiple projects that create library/executables and some even a python module using a library. To keep it simple, I have an MWE included called myprogram that creates an executable and a shared library for use by…
pdj
  • 169
  • 8
2
votes
2 answers

CMake: Regenerate source file if target gets rebuilt

I am trying to embed the build date into a source file, so that every time a specific target gets built, the embedded date is refreshed, without regenerating every time the overall project built. I.e. I have a header file builddate.h that is…
villintehaspam
  • 8,540
  • 6
  • 45
  • 76
1
vote
2 answers

cmake add_dependencies, add_custom_command and add_custom_target not working together

I have been trying to get the simple use case of getting cmake to to generate some files with a script and then build an executable out of those generated files. After spending hours reading the documentation and various stack overflow answers, it…
1
vote
1 answer

Do I always need a target in CMake?

I have a python script, which generates some files for me, and in my script, I have an argument --outputdir to specify the location of output files. I want to run this script to generate these files and install them later. I…
code3
  • 81
  • 1
  • 8
1
vote
1 answer

How can I use library in cmake-base project if sources and CMakeLists.txt file for this library I have to generate by external tool

I have to generate sources by external tool (I generate c++ classes from IDL-files for fastDDS messages), this tool also generate CMakeLists.txt file that allows me to compile generated files to .a file. In my big superproject for one…
1
vote
1 answer

NLog, access layout renderers within custom target

I'm creating a custom target but I see no way to access layout renderers value such as aspnet-traceidentifier https://github.com/NLog/NLog/wiki/AspNetTraceIdentifier-Layout-Renderer from Write method. Here is the code I use…
Dragouf
  • 4,676
  • 4
  • 48
  • 55
1
vote
1 answer

cmake add_custom_command introduces false dependency unless add_custom_target also used

I'm using cmake to build some libraries, all of which generate some of their files. I've created the generated files using add_custom_command(), but I've discovered something which seems like a false dependency. If a downstream library has a…
Rick
  • 11
  • 1
  • 3
1
vote
0 answers

CMake replaces part of absolute path to command with relative "../../" in add_custom_target

I'm trying to add a custom target to my cmake setup. It's needed as I want to execute particular tool with a set of arguments. The executable itself is prebuild and located in the repo which I want to build (so there is explicit .exe in repo, it's…
eciu
  • 163
  • 2
  • 2
  • 6
0
votes
0 answers

Is it possible to install many output files generated from one input file using meson?

I am trying to migrate a repo from autotools build system to meson. The html pages for the manual are created using this simple command: xsltproc html.xsl manual.xml the manual.xml file contains a host of links to other .xml files in the same…
dgsga
  • 11
  • 2
0
votes
0 answers

generator expression in add_custom_target

I'm trying to create a cmake (3.22) function that creates a target called cppclean for the target that I provide in the arguments function (cppclean target) if(${STATIC_CODE_ANALYSIS}) find_program(CPP_CLEAN cppclean) …
Frank
  • 2,446
  • 7
  • 33
  • 67
0
votes
1 answer

CMake appends backslash to command added by add_custom_target

I've a company internal tool which takes multiple files per command line using the following pattern -i file1 -i file2 To add this tool to my CMake build I've been using the add_custom_target command like this add_custom_target( CustomTarget …
Vinci
  • 1,382
  • 10
  • 12
0
votes
0 answers

why CMake custom_target runs twice?

I have custom target to run my test after test target is built add_executable( my_unit_test ${SRC} ) Before running the test I patch elf add_custom_command( TARGET my_unit_test POST_BUILD COMMENT "=================== PATCH UNIT TEST…
chuong vo
  • 71
  • 6
0
votes
1 answer

CMake add_custom_target COMMAND find files and exec

I have a .cmake file and I have a custom target in which I need to add a command to find and sign apk files. I do the following: add_custom_target(${APK_BUILD_TARGET} ALL COMMAND find ${APK_DIR} -name "*.apk" -exec jarsigner -verbose -sigalg…
SteveTJS
  • 635
  • 17
  • 32