0

My question about using cmake functions in add_custom/_target/commands, which is a continuation to How to call a CMake function from add_custom_target/command? and CMake: execute a macro/function as the command of add_custom_command

at present my code is written as functions and sometimes called recursively, I understand above links suggest to use CMAKE script, Can we have multiple functions in that cmake script? if yes where do we mention the function name during call? would such CMAKE script look like below?

function(name1)
endfunction()
function(name2)
endfunction()

can someone share the content of such cmake script with functions?

3
  • It looks like you don't understand what COMMAND ${CMAKE_COMMAND} -P path_to_script does: it tells CMake to execute given script, that is performs commands listed in that script, line by line. As usual, actions listed in function's definition (function(name1) ... endfunction()) are performed only at function's invocation. Also, executed script doesn't see function's declared in the CMakeLists.txt called it. Commented Dec 12, 2017 at 20:13
  • Can we parallelise function1, 2 from same CMAKE script? anyway without splitting into multiple CMAKE SCRIPTS? l Commented Dec 13, 2017 at 0:38
  • If you want to execute some actions concurrently, then no, CMake scripts are processed only sequentially. After all, CMake is not a general purpose programming language. Exception is execute_process command, which execute different COMMANDs as different processes (but with output of one process piped to the input of the next). However, COMMANDs specified for different add_custom_command and add_custom_target are executed by the build system, which could run them concurrently (e.g. with make -j). Commented Dec 13, 2017 at 8:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.