Skip to content

Commit adad351

Browse files
committed
fix: correct cmake project build logic
Since we do not bundle XSD any more, it is now a compulsory requirement that the user must install themselves along with Xerces. This also adds a new option `REGENERATE_BINDINGS` that can be used to regenerate bindings.
1 parent 01427ca commit adad351

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

CMakeLists.txt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ configure_file(
5252
"${PROJECT_SOURCE_DIR}/src/neuroml.hxx.in"
5353
"${PROJECT_BINARY_DIR}/src/neuroml.hxx"
5454
)
55-
55+
5656
# Add the binary tree to the search path for include files
5757
# so that we will find generated sources
5858
include_directories("${PROJECT_BINARY_DIR}/src")
@@ -61,10 +61,15 @@ include_directories("${PROJECT_BINARY_DIR}/src")
6161
find_package(XercesC REQUIRED)
6262
list(APPEND NeuroML_INCLUDES "${XercesC_INCLUDE_DIRS}")
6363

64-
# Can we regenerate the schema wrapper?
65-
find_package(XSD)
66-
if (XSD_FOUND)
67-
list(APPEND NeuroML_INCLUDES "${XSD_INCLUDE_DIRS}")
64+
# XSD
65+
find_package(XSD REQUIRED)
66+
list(APPEND NeuroML_INCLUDES "${XSD_INCLUDE_DIRS}")
67+
68+
# Regenerate bindings?
69+
set (REGENERATE_BINDINGS OFF CACHE BOOL "Regenerate the C++ bindings. [default: OFF]")
70+
71+
# Yes: and use newly generated copy
72+
if (REGENERATE_BINDINGS)
6873
file(GLOB _XSD_DEPS "src/schema/*.txt")
6974
xsd_schema(NeuroML_SCHEMA_SRCS "${NeuroML_SCHEMA_PATH}" "${_XSD_DEPS}"
7075
--options-file "${PROJECT_SOURCE_DIR}/src/schema/XsdOptions.txt")
@@ -74,7 +79,12 @@ if (XSD_FOUND)
7479
${PROJECT_SOURCE_DIR}/src/schema
7580
COMMENT "Copying new XSD wrappers to source tree"
7681
VERBATIM)
77-
endif (XSD_FOUND)
82+
else (REGENERATE_BINDINGS)
83+
# No: use pre-generated bindings
84+
# Will fail if bindings cannot be found in the src/schema directory
85+
list(APPEND NeuroML_INCLUDES "${PROJECT_SOURCE_DIR}/src/schema")
86+
set(NeuroML_SCHEMA_SRCS "${PROJECT_SOURCE_DIR}/src/schema/${NeuroML_SCHEMA_NAME}.cxx")
87+
endif (REGENERATE_BINDINGS)
7888

7989
# The main API library
8090
add_library(neuroml ${NeuroML_SCHEMA_SRCS} src/NeuroML_custom.cxx)

0 commit comments

Comments
 (0)