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/

FindXSD.cmake 2.71 KB
Newer Older
Emmanuel Promayon's avatar
Emmanuel Promayon committed
1
2
# Locate code synthesis xsd and define include paths, binary and determine installed version
# xsd can be found at http://codesynthesis.com/products/xsd/
3
# Originally written by Frederic Heem, frederic.heem _at_ telsey.it
4
5

# This module defines
Emmanuel Promayon's avatar
Emmanuel Promayon committed
6
7
8
9
10
# 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
11

12
find_path(XSD_INCLUDE_DIR 
13
          NAMES "xsd/cxx/parser/elements.hxx"
14
15
16
17
18
19
20
21
22
23
          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
24
25
26
)

# check if the plateform can compile the xsd automatically
27
28
29
30
31
32
33
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 
34
35
)

Emmanuel Promayon's avatar
Emmanuel Promayon committed
36
# if the include and the program are found then it is installed and found
37
38
39
40
41
if(XSD_INCLUDE_DIR)
    if(XSD_EXECUTABLE)
       set(XSD_FOUND TRUE)
    endif()
endif()
42

43
44
45
46
47
if(XSD_FOUND)
    # find out more information about XSD
    unset(XSD_VERSION_TEXT)
    execute_process(COMMAND ${XSD_EXECUTABLE} --version
                    OUTPUT_VARIABLE XSD_VERSION_TEXT
48
                    ERROR_VARIABLE  XSD_VERSION_TEXT
49
50
51
                    OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    # extract xsd version number
52
    string(REGEX REPLACE "^.*compiler (.*)[\\r\\n\\t ]*Copyright.*" "\\1" XSD_VERSION "${XSD_VERSION_TEXT}")
53
54
55
56
57
58
59
60
61

    # 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)
62
63
        string(REGEX REPLACE "\n$" "" XSD_VERSION_WITHOUT_TRAILING_NEWLINE "${XSD_VERSION}")
        message(STATUS "Found XSD executable: ${XSD_EXECUTABLE} version ${XSD_VERSION_WITHOUT_TRAILING_NEWLINE}")
64
65
66
67
68
69
70
71
    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(
72
73
  XSD_INCLUDE_DIR
  XSD_EXECUTABLE
74
75
  XSD_VERSION
  XSD_CXX_STD_FLAG
76
)