1

I'm using generator expressions in a custom command to compile hlsl shaders:

add_custom_command(TARGET Shaders COMMAND vendor/shader-compiling/fxc.exe /nologo /Emain /Tvs_5_0 $<$<CONFIG:Debug>:/Od> /Zi /Fo ${TARGET_SHADER_PATH}/hlsl/${FILE_WE}_vs.cso /Fd ${CMAKE_BINARY_DIR}/${FILE_WE}_vs.pdb ${TARGET_SHADER_PATH}/hlsl/${FILE_WE}_vs.hlsl COMMAND vendor/shader-compiling/fxc.exe /nologo /Emain /Tps_5_0 $<$<CONFIG:Debug>:/Od> /Zi /Fo ${TARGET_SHADER_PATH}/hlsl/${FILE_WE}_fs.cso /Fd ${CMAKE_BINARY_DIR}/${FILE_WE}_fs.pdb ${TARGET_SHADER_PATH}/hlsl/${FILE_WE}_fs.hlsl MAIN_DEPENDENCY ${FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Compiling HLSL shader ${TARGET_SHADER_PATH}/hlsl/${FILE_WE}.hlsl" VERBATIM) 

and in debug mode everything works fine. However, in release mode, my expected result is the /Od flag does not get included in the command at all. However, what ended up happening is $<$<CONFIG:Debug>:/Od> gets evaluated to two double quotes and the command doesn't work.

Any ideas on why this is happening?

1 Answer 1

1

Just in case anybody finds this useful, I solved the problem by adding COMMAND_EXPAND_LISTS to my add_custom_command command. Not sure why that works but it does get rid of the empty pair of quotes in the middle of the command therefore the command works.

Sign up to request clarification or add additional context in comments.

1 Comment

It works because it expanded an empty list to nothing. Every other element in your command is a one-element list so they expanded to itself.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.