[CMake] xsd and add_custom_command to generate sources

ope ope-devel at gmx.de
Sat Jul 14 11:32:49 EDT 2007


Hi,

in CMakeList file I have the following entries:

find_package(Xsd REQUIRED)
include_directories(${XSD_INCLUDE_DIR})

and

set(XSD_METALINK_ARGS "cxx-tree" "--namespace-map
'http://www.metalinker.org/'=metalink")
add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/metalink.cxx
  COMMAND ${XSD_EXECUTABLE}
  ARGS ${XSD_METALINK_ARGS}
${CMAKE_CURRENT_SOURCE_DIR}/schemata/metalink.xsd
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/schemata/metalink.xsd
)

and the FindXsd.cmake attached. Why does these not generate and compile
the ${CMAKE_CURRENT_BINARY_DIR}/metalink.cxx file?

Thanks
Olaf
-------------- next part --------------
# Locate Xsd from code synthesis
# Xsd at http://codesynthesis.com/products/xsd/
# written by Olaf Petzold ope-devel. at .gmx. dot .de

# XSD_INCLUDE_DIR - where to find the includes.
# XSD_EXECUTABLE  - the xsd compiler.
# XSD_FOUND       - True if Xerces-C found.

FIND_PATH(XSD_INCLUDE_DIR xsd/cxx/parser/elements.hxx
  "[HKEY_CURRENT_USER]\\software\\xsd\\include]"
  "[HKEY_CURRENT_USER]\\xsd\\include]"
  $ENV{XSDDIR}/include
  /usr/local/include
  /usr/include
)

FIND_PROGRAM(XSD_EXECUTABLE 
  NAMES 
    xsd
  PATHS
    "[HKEY_CURRENT_USER]\\xsd\\bin"
    $ENV{XSDDIR}/bin 
    /usr/local/bin
    /usr/bin
)


IF(XSD_INCLUDE_DIR AND XSD_EXECUTABLE)
  SET(XSD_FOUND TRUE)
ENDIF(XSD_INCLUDE_DIR AND XSD_EXECUTABLE)

IF(XSD_FOUND)
   IF(NOT XSD_FIND_QUIETLY)
     MESSAGE(STATUS "Found xsd: ${XSD_EXECUTABLE}")
   ENDIF(NOT XSD_FIND_QUIETLY)
ELSE(XSD_FOUND)
   IF(XSD_FIND_REQUIRED)
      MESSAGE(STATUS "Looked for code synthesis xsd.")
      MESSAGE(FATAL_ERROR "Could NOT find xsd.")
   ENDIF(XSD_FIND_REQUIRED)
ENDIF(XSD_FOUND)


MARK_AS_ADVANCED(
  XSD_INCLUDE_DIR
  XSD_EXECUTABLE
) 


More information about the CMake mailing list