[CMake] Using ADD_CUSTOM_COMMAND in a macro; Problems with quotes

Martin Lütken mlu at danware.dk
Mon Mar 10 07:12:00 EDT 2008


Using ADD_CUSTOM_COMMAND in a macro like shown below I cannot get rid of the 
quotes around my command when it gets used in Visual Studio.
This results in an error from Visual Studio.


---------------
--- Example ---
---------------
MACRO( ADD_GENERATED_SOURCE_FILE  inFile outFileName cmd1 )  
    
    IF ( NOT ${CBS_CURRENT}_AUTO_CUSTOM_TARGET_ADDED )
        SET ( ${CBS_CURRENT}_AUTO_CUSTOM_TARGET_ADDED  1 )
        ADD_CUSTOM_TARGET ( ${CBS_CURRENT}_AUTO_CUSTOM_TARGET ALL echo "${CBS_CURRENT}: Creating auto custom target '${outFileName}' source file" )    # Create target for the MOC_QT3 files
    ENDIF (  NOT ${CBS_CURRENT}_AUTO_CUSTOM_TARGET_ADDED )
    
    ADD_CUSTOM_COMMAND(
        OUTPUTS     ${CMAKE_CURRENT_BINARY_DIR}/${outFileName}
        SOURCE      ${CMAKE_CURRENT_SOURCE_DIR}/${inFile}
        COMMAND     ${cmd1}
        TARGET      ${CBS_CURRENT}_AUTO_CUSTOM_TARGET
    )
    
    SET ( ${CBS_CURRENT}_SRCS ${${CBS_CURRENT}_SRCS}   ${CMAKE_CURRENT_BINARY_DIR}/${outFileName}              )
    SET_SOURCE_FILES_PROPERTIES(                       ${CMAKE_CURRENT_BINARY_DIR}/${outFileName}    GENERATED )
ENDMACRO( ADD_GENERATED_SOURCE_FILE )

-------------------------------------------
If I invoke fx. like this:
ADD_GENERATED_SOURCE_FILE ( "glib.symbols" "glib.def"  "echo EXPORTS > ${CMAKE_CURRENT_BINARY_DIR}/glib.def" )
--------------------------------------------

Then the target created in MSVC2005 still has the quotes from the command.

I tried: STRING ( REPLACE "\"" "" NewCmd1 ${cmd1} )
But that does not make any difference.

Is this a bug or is there a way to get rid of the quotes ?

-Martin Lütken



More information about the CMake mailing list