CMake post build use - a little confusion

Hi everyone,

I am trying to run auval after a build in xcode (configured by CMake) and having a bit of a challenge.

I added a custom command in my CMakeLists.txt file, shown below, and found something surprising.

The build fails (FATAL ERROR: didn’t find the component). Removing this, it builds and is available to auval and everything works as expected.

I am sure I am just misunderstanding something obvious. Any ideas why it won’t complete the build and then run auval?

add_custom_command(
TARGET {BaseTargetName} POST_BUILD COMMAND cd {PlugLocation}/Components
COMMAND killall -9 AudioComponentRegistrar
COMMAND auval -v aufx Tst5 Abcd
)

auval seems to be picky about the shell in which it is run. For me, it normally finds all custom AUs from the built-in Terminal app, but only finds Apple’s AUs when running from iTerm/tmux. Perhaps the environment that CMake uses to run the auval command suffers from the same issue.

One maybe obvious thing:
To parse a variable in CMake you need to also add the “$” sign, so:

${BaseTargetName}

instead of

{BaseTargetName}

What helps me is sometimes add debug messages like:

message("Plugin location: ${PlugLocation}/Components")

Just to make sure I’m parsing the correct things into the commands

Also note that the commands aren’t necessarily run in the same shell, so if you cd in one COMMAND, the following commands aren’t guaranteed to use the new directory as the working directory.

Thank you both very much!

Edit: I found the (simple) solution. For anyone who finds this in the future (probably including me), I was missing the DEPENDS command…

Also, as mentioned by @eyalamir, the ‘$’, are needed. However, they were stripped out when I posted. To get them to show on the forum, you need to escape them using ‘\’.

add_custom_command(TARGET ${BaseTargetName}
POST_BUILD
DEPENDS ${PlugLocation}/Components/${BaseTargetName}.component
COMMAND cd ${PlugLocation}/Components; killall -9 AudioComponentRegistrar; auval -v aufx Tst5 Abcd > output.auval.txt
)

Code in forum posts should be marked as such in order to avoid that (and preserve whitespaces).
It is done by putting three backticks ``` before and after your code snippet, or by adding four spaces before every line, or by selecting the code portion and clicking the “</>” button while editing the post