[CMake] xsd rules

ope ope-devel at gmx.de
Sat Jul 14 10:50:28 EDT 2007


Hi,

I try to build the rules for codesynthesis xsd schema compiler using
these FindXsd.cmake rule attached.

The problems starts with the "required" argument. There comes no error
message if the compiler xsd isn't found (e.g. renamed to xsd2). Why?

The next one, the source isn't generated:

find_package(Xsd REQUIRED)
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
)

What's wrong here? Adding the generated source to app's sources:

set(APP_SRC
  ${APP_SRC}
  ${CMAKE_CURRENT_BINARY_DIR}/metalink.cxx
)

doesn't solve it.

BTW, what is the prefered way to express depencies? Xsd requires Xerces-C.

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