[CMake] Problem with ADD_CUSTOM_COMMAND & ARGS

Eric Tellefsen eric.tellefsen at db.com
Wed Sep 16 16:27:48 EDT 2009


Hi,

During one of my more complex migrations from Solaris make to CMake, I 
have run into a problem with an argument passed into the custom command.

A key part of this project generates CXX & HXX  source files from a series 
of .xsd files in project sub directories.  In order to reuse this 
functionality if need be, I have created a separate macro file for this 
task.

My project is constructed with a CMakeLists.txt file for the main project 
(a static library) and another CMakeLists.txt file in one of the 
subdirectories containing .xsd files.

My problem has to do with the ARGS section of the custom command. 
Specifically the 'legacy' Makefile uses an argument  --include-regex 
"#../../XML/Types/##"  in order to remove this prefix from the generated 
HXX files, where applicable.

While everything works fine with the legacy Makefile, it does not seem to 
work in my CMake Makefile.  Everything works with the exception that some 
of the generated HXX files still contain the "../../Types/" prefix, which 
breaks the subsequent source compilation as the headers with the 
"#../../XML/Types/##" prefix cannot be found by the compiler.   I'm 
guessing that this problem has something to do with the value being passed 
to the option --include-regex is not tracking correctly but I'm not sure 
why.

I have tried every possible permutation of fixing this problem, going as 
far as including the custom command in the body of the CMakeLists.txt file 
(for the subdirectory) and not using the macro.  All attempts to generate 
'correct' HXX files have failed up to this date.

Is there something I'm not getting?  I will include my macro as well as 
the relevant information from the calling CMakeLists.txt file below if 
that helps.

Thanks,

Eric

----------- Code which invokes macro
SET( STUBDIR ${CMAKE_BINARY_DIR}/Stubs )
SET( TYPE_XSD_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
SET( TYPE_REGEX_FLAG "#../../XML/Types/##" )

XSDGenCXXSources( TypesOutputFiles
                    "${TYPE_REGEX_FLAG}"
                    "${TYPE_XSD_DIR}"
                    "${STUBDIR}"
                    "${CMAKE_CURRENT_SOURCE_DIR}"
                    )

----------- Macro -----------------------------
macro ( XSDGenCXXSources OUTPUT_FILES REGEX XSD_DIR OUTPUT_DIR Working_Dir 
)

    SET( XSD_EXE $ENV{CODE_SYNTHESIS_HOME}/bin/xsd )

    ADD_CUSTOM_COMMAND(
            OUTPUT  ${${OUTPUT_FILES}}
            COMMAND mkdir
            ARGS    -p ${OUTPUT_DIR}
            COMMAND ${XSD_EXE}
          ARGS    cxx-tree --generate-serialization --output-dir 
${OUTPUT_DIR} --include-regex " ${REGEX} " ${XSD_DIR}/*.xsd
            COMMENT "Generating CXX files from ${XSD_DIR} and placing them 
in ${OUTPUT_DIR}"
            WORKING DIRECTORY ${Working_Dir}
            )
endmacro ( XSDGenCXXSources )
~

---
This communication may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this communication
in error) please notify the sender immediately and destroy this
communication. Any unauthorized copying, disclosure or distribution of the
material in this communication is strictly forbidden.

Deutsche Bank does not render legal or tax advice, and the information
contained in this communication should not be regarded as such.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090916/1a2745b8/attachment.htm>


More information about the CMake mailing list