From adad351bf31551034ba83e98f3a3f4da80a35783 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Thu, 11 Mar 2021 11:37:52 +0000 Subject: [PATCH] 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. --- CMakeLists.txt | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5513ec5..27a60ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ configure_file( "${PROJECT_SOURCE_DIR}/src/neuroml.hxx.in" "${PROJECT_BINARY_DIR}/src/neuroml.hxx" ) - + # Add the binary tree to the search path for include files # so that we will find generated sources include_directories("${PROJECT_BINARY_DIR}/src") @@ -61,10 +61,15 @@ include_directories("${PROJECT_BINARY_DIR}/src") find_package(XercesC REQUIRED) list(APPEND NeuroML_INCLUDES "${XercesC_INCLUDE_DIRS}") -# Can we regenerate the schema wrapper? -find_package(XSD) -if (XSD_FOUND) - list(APPEND NeuroML_INCLUDES "${XSD_INCLUDE_DIRS}") +# XSD +find_package(XSD REQUIRED) +list(APPEND NeuroML_INCLUDES "${XSD_INCLUDE_DIRS}") + +# Regenerate bindings? +set (REGENERATE_BINDINGS OFF CACHE BOOL "Regenerate the C++ bindings. [default: OFF]") + +# Yes: and use newly generated copy +if (REGENERATE_BINDINGS) file(GLOB _XSD_DEPS "src/schema/*.txt") xsd_schema(NeuroML_SCHEMA_SRCS "${NeuroML_SCHEMA_PATH}" "${_XSD_DEPS}" --options-file "${PROJECT_SOURCE_DIR}/src/schema/XsdOptions.txt") @@ -74,7 +79,12 @@ if (XSD_FOUND) ${PROJECT_SOURCE_DIR}/src/schema COMMENT "Copying new XSD wrappers to source tree" VERBATIM) -endif (XSD_FOUND) +else (REGENERATE_BINDINGS) + # No: use pre-generated bindings + # Will fail if bindings cannot be found in the src/schema directory + list(APPEND NeuroML_INCLUDES "${PROJECT_SOURCE_DIR}/src/schema") + set(NeuroML_SCHEMA_SRCS "${PROJECT_SOURCE_DIR}/src/schema/${NeuroML_SCHEMA_NAME}.cxx") +endif (REGENERATE_BINDINGS) # The main API library add_library(neuroml ${NeuroML_SCHEMA_SRCS} src/NeuroML_custom.cxx)