Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit d5654250 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

UPDATED Check XSD version and determine if strict c++11 is possible + findXSD cleanup

Win7 CamiTK env is deployed with xsd 3.3 which does not have the std option.
xsd version is checked and if it is at least 4.0.0, option "--std c++11" is used
to generate the C++ source code from the XSD documents. This results in a strict
C++11 code that does not generate compiler warning on modern c++ compiler
(mainly due to the generation of C++98 "auto_ptr" instead of C++11 "unique_ptr")
parent 869d9660
......@@ -5,24 +5,19 @@ find_package(XSD REQUIRED)
file (GLOB_RECURSE XSD_INPUT_FILES *.xsd)
# generates headers from scratch
set (XSD_H)
set (XSD_SRCS)
unset(XSD_H)
unset(XSD_SRCS)
if (XSD_COMMAND)
set(XSD_COMMAND xsdcxx CACHE STRING "Name of the XSD code synthesis compiler")
# generates headers from scratch
foreach(xsdFile ${XSD_INPUT_FILES})
get_filename_component(xsdFileName ${xsdFile} NAME_WE)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx
COMMAND ${XSD_COMMAND}
ARGS cxx-tree --std c++11 --generate-polymorphic --polymorphic-type Load --generate-serialization --namespace-map =load ${xsdFile}
# generates headers from scratch
foreach(xsdFile ${XSD_INPUT_FILES})
get_filename_component(xsdFileName ${xsdFile} NAME_WE)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx
COMMAND ${XSD_EXECUTABLE}
ARGS cxx-tree ${XSD_CXX_STD_FLAG} --generate-polymorphic --polymorphic-type Load --generate-serialization --namespace-map =load ${xsdFile}
DEPENDS ${xsdFile})
set(XSD_H ${XSD_H} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx)
set(XSD_SRCS ${XSD_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx)
endforeach()
else()
message(FATAL_ERROR "Cannot find xsd or xsdcxx command: please install XSD / check xsd or xsdcxx binary is in your sytem PATH")
endif()
set(XSD_H ${XSD_H} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx)
set(XSD_SRCS ${XSD_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx)
endforeach()
camitk_library(STATIC
SOURCES ${XSD_H} ${XSD_SRCS}
......
# XSD really needed
find_package(XSD REQUIRED)
# Create lib files from xsd
set(monitorLib_XSD
${CMAKE_CURRENT_SOURCE_DIR}/MonitoringModel.xsd
${CMAKE_CURRENT_SOURCE_DIR}/MonitorIn.xsd
${CMAKE_CURRENT_SOURCE_DIR}/MonitorOut.xsd
${CMAKE_CURRENT_SOURCE_DIR}/MonitoringModel.xsd
${CMAKE_CURRENT_SOURCE_DIR}/MonitorIn.xsd
${CMAKE_CURRENT_SOURCE_DIR}/MonitorOut.xsd
)
if (XSD_COMMAND)
set(XSD_COMMAND xsdcxx CACHE STRING "name of the XSD code synthesis compiler")
# generates headers from scratch
foreach(xsdFile ${monitorLib_XSD})
get_filename_component(xsdFileName ${xsdFile} NAME_WE)
message(STATUS "Generating code from ${xsdFileName}")
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx
COMMAND ${XSD_COMMAND}
ARGS cxx-tree --std c++11 --generate-polymorphic --generate-serialization --namespace-map =mml --polymorphic-type Method --polymorphic-type Criteria ${xsdFile}
DEPENDS ${xsdFile})
set(monitoringLib_H ${monitoringLib_H} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx)
set(monitoringLib_SRCS ${monitoringLib_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx)
endforeach()
else()
message(FATAL_ERROR "Cannot find xsd or xsdcxx command: please install XSD / check xsd or xsdcxx binary is in your sytem PATH")
endif()
# accumulate all headers
unset(monitoringLib_H)
unset(monitoringLib_SRCS)
# generates headers from scratch
foreach(xsdFile ${monitorLib_XSD})
get_filename_component(xsdFileName ${xsdFile} NAME_WE)
message(STATUS "Generating code from ${xsdFileName}")
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx
COMMAND ${XSD_EXECUTABLE}
ARGS cxx-tree ${XSD_CXX_STD_FLAG} --generate-polymorphic --generate-serialization --namespace-map =mml --polymorphic-type Method --polymorphic-type Criteria ${xsdFile}
DEPENDS ${xsdFile})
set(monitoringLib_H ${monitoringLib_H} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx)
set(monitoringLib_SRCS ${monitoringLib_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx)
endforeach()
# add lib as a camitk tool
# force to mmlschema (default should be schema as it is in the schema dir, but schema is too generic!)
......
......@@ -5,29 +5,24 @@ find_package(XSD REQUIRED)
file (GLOB_RECURSE XSD_INPUT_FILES *.xsd)
# generates headers from scratch
set (XSD_H)
set (XSD_SRCS)
unset(XSD_H)
unset(XSD_SRCS)
if (XSD_COMMAND)
set(XSD_COMMAND xsdcxx CACHE STRING "Name of the XSD code synthesis compiler")
# generates headers from scratch
foreach(xsdFile ${XSD_INPUT_FILES})
get_filename_component(xsdFileName ${xsdFile} NAME_WE)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx
COMMAND ${XSD_COMMAND}
ARGS cxx-tree --std c++11 --generate-polymorphic --generate-serialization --namespace-map =physicalModel --generate-wildcard ${xsdFile}
DEPENDS ${xsdFile})
set(XSD_H ${XSD_H} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx)
set(XSD_SRCS ${XSD_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx)
endforeach()
else()
message(FATAL_ERROR "Cannot find xsd or xsdcxx command: please install XSD / check xsd or xsdcxx binary is in your sytem PATH.")
endif()
# generates headers from scratch
foreach(xsdFile ${XSD_INPUT_FILES})
get_filename_component(xsdFileName ${xsdFile} NAME_WE)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx
COMMAND ${XSD_EXECUTABLE}
ARGS cxx-tree ${XSD_CXX_STD_FLAG} --generate-polymorphic --generate-serialization --namespace-map =physicalModel --generate-wildcard ${xsdFile}
DEPENDS ${xsdFile})
set(XSD_H ${XSD_H} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx)
set(XSD_SRCS ${XSD_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx)
endforeach()
camitk_library(STATIC
SOURCES ${XSD_H} ${XSD_SRCS}
NEEDS_XSD
HEADERS_TO_INSTALL ${XSD_H}
CEP_NAME CEP_MODELING
DESCRIPTION "Data description of PML: Physical Markeup Language."
DESCRIPTION "Data description of PML: Physical Markup Language."
)
# Locate Xsd from code synthesis include paths and binary
# Locate Xsd from code synthesis include paths and binary, and determine installed version
# Xsd can be found at http://codesynthesis.com/products/xsd/
# Written by Frederic Heem, frederic.heem _at_ telsey.it
# Originally written by Frederic Heem, frederic.heem _at_ telsey.it
# This module defines
# XSD_INCLUDE_DIR, where to find elements.hxx, etc.
# XSD_EXECUTABLE, where is the xsd compiler
# XSD_FOUND, If false, don't try to use xsd
# XSD_VERSION, the xsd version that was found
# XSD_CXX_STD_FLAG force to C++11 if and only if xsd version is greater or equals to 4.0.0, empty string otherwise
FIND_PATH(XSD_INCLUDE_DIR xsd/cxx/parser/elements.hxx
"[HKEY_CURRENT_USER\\software\\xsd\\include]"
"[HKEY_CURRENT_USER]\\xsd\\include]"
$ENV{XSDDIR}/include
$ENV{XERCESC_ROOT_DIR}/include
$ENV{XERCESC_DIR}/include
${XERCESC_INCLUDE_DIR}
${XERCESC_INCLUDE_DIR}/include
${XERCESC_INCLUDE_DIR}/..
/usr/local/include
/usr/include
find_path(XSD_INCLUDE_DIR
NAMES elements.hxx
PATH_SUFFIXES xsd/cxx/parser
PATHS "[HKEY_CURRENT_USER\\software\\xsd\\include]"
"[HKEY_CURRENT_USER]\\xsd\\include]"
$ENV{XSDDIR}/include
$ENV{XERCESC_ROOT_DIR}/include
$ENV{XERCESC_DIR}/include
${XERCESC_INCLUDE_DIR}
${XERCESC_INCLUDE_DIR}/include
${XERCESC_INCLUDE_DIR}/..
/usr/local/include
/usr/include
)
# check if the plateform can compile the xsd automatically
FIND_PROGRAM(XSD_COMMAND
NAMES xsdcxx xsd
PATHS
"[HKEY_CURRENT_USER\\xsd\\bin"
$ENV{XSDDIR}/bin
/usr/local/bin
/usr/bin
${CMAKE_FIND_ROOT_PATH}/bin #Add paths here
find_program(XSD_EXECUTABLE
NAMES xsdcxx xsd
PATHS "[HKEY_CURRENT_USER\\xsd\\bin"
$ENV{XSDDIR}/bin
/usr/local/bin
/usr/bin
${CMAKE_FIND_ROOT_PATH}/bin
)
# if the include and the program are found then we have it
IF(XSD_INCLUDE_DIR)
IF(XSD_EXECUTABLE)
SET( XSD_FOUND "YES" )
ENDIF(XSD_EXECUTABLE)
ENDIF(XSD_INCLUDE_DIR)
if(XSD_INCLUDE_DIR)
if(XSD_EXECUTABLE)
set(XSD_FOUND TRUE)
endif()
endif()
MARK_AS_ADVANCED(
if(XSD_FOUND)
# find out more information about XSD
unset(XSD_VERSION_TEXT)
execute_process(COMMAND ${XSD_EXECUTABLE} --version
OUTPUT_VARIABLE XSD_VERSION_TEXT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# extract xsd version number
string(REGEX REPLACE "^.*compiler (.*)\nCopyright.*" "\\1" XSD_VERSION ${XSD_VERSION_TEXT})
# force c++11 version if possible
if(${XSD_VERSION} VERSION_LESS "4.0.0")
set(XSD_CXX_STD_FLAG "")
else()
set(XSD_CXX_STD_FLAG "--std;c++11") # use ";" so that it will be escaped as " " in the xsd command line arg
endif()
if(NOT XSD_FIND_QUIETLY)
message(STATUS "Found XSD executable: ${XSD_EXECUTABLE} version ${XSD_VERSION} using ${XSD_CXX_STD_FLAG}")
endif()
else()
if(XSD_FIND_REQUIRED)
message(FATAL_ERROR "Cannot find xsdcxx command: please install XSD / check xsd binary is in your sytem PATH.")
endif()
endif()
mark_as_advanced(
XSD_INCLUDE_DIR
XSD_EXECUTABLE
XSD_VERSION
XSD_CXX_STD_FLAG
)
# XSD really needed
find_package(XSD REQUIRED)
# Create lib files from xsd
file (GLOB_RECURSE XSD_INPUT_FILES *.xsd)
# Create lib files from xsd
file (GLOB_RECURSE XSD_INPUT_FILES *.xsd)
# generates headers from scratch
set (XSD_H)
set (XSD_SRCS)
# generates headers from scratch
unset(XSD_H)
unset(XSD_SRCS)
if (XSD_COMMAND)
set(XSD_COMMAND xsdcxx CACHE STRING "name of the XSD code synthesis compiler")
# generates headers from scratch
foreach(xsdFile ${XSD_INPUT_FILES})
get_filename_component(xsdFileName ${xsdFile} NAME_WE)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx
COMMAND ${XSD_COMMAND}
# Using strict C++11 flags with xsd cxx
ARGS cxx-tree --std c++11 --generate-polymorphic --generate-serialization --namespace-map =cepcoreschema --polymorphic-type Method --polymorphic-type Criteria ${xsdFile}
COMMAND ${XSD_EXECUTABLE}
ARGS cxx-tree ${XSD_CXX_STD_FLAG} --generate-polymorphic --generate-serialization --namespace-map =cepcoreschema --polymorphic-type Method --polymorphic-type Criteria ${xsdFile}
DEPENDS ${xsdFile})
set(XSD_H ${XSD_H} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.hxx)
set(XSD_SRCS ${XSD_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/${xsdFileName}.cxx)
endforeach()
else()
message(FATAL_ERROR "Cannot find xsdcxx command: please install XSD / check xsd binary is in your sytem PATH.")
endif()
camitk_library(STATIC
SOURCES ${XSD_H} ${XSD_SRCS}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment