0

I tried using the VS_DEBUGGER_COMMAND property with generator expressions.

According to the CMake manual it should work: https://cmake.org/cmake/help/v3.16/prop_tgt/VS_DEBUGGER_COMMAND.html

My CMake script is the following:

set_property(TARGET ${MAYA_PLUGIN_NAME} PROPERTY VS_DEBUGGER_COMMAND
    $<$<CONFIG:Debug2017>:"C:/Program Files/Autodesk/Maya2017/bin/maya.exe">
    $<$<CONFIG:Release2017>:"C:/Program Files/Autodesk/Maya2017/bin/maya.exe">
    $<$<CONFIG:Debug2018>:"C:/Program Files/Autodesk/Maya2018/bin/maya.exe">
    $<$<CONFIG:Release2018>:"C:/Program Files/Autodesk/Maya2018/bin/maya.exe">
    $<$<CONFIG:Debug2019>:"C:/Program Files/Autodesk/Maya2019/bin/maya.exe">
    $<$<CONFIG:Release2019>:"C:/Program Files/Autodesk/Maya2019/bin/maya.exe">
)

What I got for the Debug2018 configuration for the Debugger command is:

Command                 ;;"C:/Program Files/Autodesk/Maya2018/bin/maya.exe";;;

which is not correct of course.

Question: What am I doing wrong?

Kevin
  • 16,549
  • 8
  • 60
  • 74

1 Answers1

0

Generator expressions placed on multiple lines is interpreted differently by CMake than placing them all on one line (related question here). In this case, for set_property(), CMake interprets the multi-line generator expression as a list. Therefore, for the Debug2018 configuration, one list entry evaluates to the maya.exe path, while the others evaluate to empty strings. All are placed in a semicolon-separated list.

To prevent CMake from interpreting the expression as a list, place the entire generator expression on one line:

set_property(TARGET ${MAYA_PLUGIN_NAME} PROPERTY VS_DEBUGGER_COMMAND
    $<$<CONFIG:Debug2017>:"C:/Program Files/Autodesk/Maya2017/bin/maya.exe">$<$<CONFIG:Release2017>:"C:/Program Files/Autodesk/Maya2017/bin/maya.exe">$<$<CONFIG:Debug2018>:"C:/Program Files/Autodesk/Maya2018/bin/maya.exe">$<$<CONFIG:Release2018>:"C:/Program Files/Autodesk/Maya2018/bin/maya.exe">$<$<CONFIG:Debug2019>:"C:/Program Files/Autodesk/Maya2019/bin/maya.exe">$<$<CONFIG:Release2019>:"C:/Program Files/Autodesk/Maya2019/bin/maya.exe">
)

You could also use CMake's string(CONCAT ...) command to construct the generator expression as a single string, then pass this string to the set_property() command:

string(CONCAT MY_CONFIG_GENEX
    "$<$<CONFIG:Debug2017>:\"C:/Program Files/Autodesk/Maya2017/bin/maya.exe\">"
    "$<$<CONFIG:Release2017>:\"C:/Program Files/Autodesk/Maya2017/bin/maya.exe\">"
    "$<$<CONFIG:Debug2018>:\"C:/Program Files/Autodesk/Maya2018/bin/maya.exe\">"
    "$<$<CONFIG:Release2018>:\"C:/Program Files/Autodesk/Maya2018/bin/maya.exe\">"
    "$<$<CONFIG:Debug2019>:\"C:/Program Files/Autodesk/Maya2019/bin/maya.exe\">"
    "$<$<CONFIG:Release2019>:\"C:/Program Files/Autodesk/Maya2019/bin/maya.exe\">"
)
set_property(TARGET ${MAYA_PLUGIN_NAME} PROPERTY VS_DEBUGGER_COMMAND
    ${MY_CONFIG_GENEX}
)

In this case, you must escape the quotes around the maya.exe path with backslashes (e.g. \"...\").

Kevin
  • 16,549
  • 8
  • 60
  • 74