From 0010c4779c20ff3402a0dd130bea9647df085b11 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 18 Dec 2020 14:59:30 -0500 Subject: [PATCH 1/2] BUG: Do not override ITK_DIR in CMake package configurations Enable a different ITK to build built against when building the CLI, e.g. when cross-compiling. --- GenerateCLP/GenerateCLPConfig.cmake.in | 4 +++- GenerateCLP/GenerateCLPInstallConfig.cmake.in | 5 +++-- .../ModuleDescriptionParserConfig.cmake.in | 4 +++- .../ModuleDescriptionParserInstallConfig.cmake.in | 4 +++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/GenerateCLP/GenerateCLPConfig.cmake.in b/GenerateCLP/GenerateCLPConfig.cmake.in index c5feddc..7832588 100644 --- a/GenerateCLP/GenerateCLPConfig.cmake.in +++ b/GenerateCLP/GenerateCLPConfig.cmake.in @@ -11,7 +11,9 @@ set(SlicerExecutionModel_USE_UTF8 "@SlicerExecutionModel_USE_UTF8@") set(SlicerExecutionModel_CMAKE_DIR "@SlicerExecutionModel_CMAKE_DIR@") set(TCLAP_DIR "@TCLAP_DIR@") set(ModuleDescriptionParser_DIR "@ModuleDescriptionParser_DIR@") -set(ITK_DIR "@ITK_DIR_CONFIG@") +if (NOT DEFINED ITK_DIR) + set(ITK_DIR "@ITK_DIR_CONFIG@") +endif() set(GenerateCLP_JsonCpp_INCLUDE_DIR "@JsonCpp_INCLUDE_DIR@") if(NOT "${GenerateCLP_JsonCpp_INCLUDE_DIR}" STREQUAL "") diff --git a/GenerateCLP/GenerateCLPInstallConfig.cmake.in b/GenerateCLP/GenerateCLPInstallConfig.cmake.in index a53fa54..bbc88c6 100644 --- a/GenerateCLP/GenerateCLPInstallConfig.cmake.in +++ b/GenerateCLP/GenerateCLPInstallConfig.cmake.in @@ -18,5 +18,6 @@ set(GENERATECLP_EXE "${GENERATECLP_EXE}${__EXE_EXT}") get_filename_component(GENERATECLP_EXE "${GENERATECLP_EXE}" ABSOLUTE) set(TCLAP_DIR "@TCLAP_DIR@") set(ModuleDescriptionParser_DIR "@ModuleDescriptionParser_DIR@") -set(ITK_DIR "@ITK_DIR@") - +if (NOT DEFINED ITK_DIR) + set(ITK_DIR "@ITK_DIR@") +endif() diff --git a/ModuleDescriptionParser/ModuleDescriptionParserConfig.cmake.in b/ModuleDescriptionParser/ModuleDescriptionParserConfig.cmake.in index 04d5be2..ae1bf72 100644 --- a/ModuleDescriptionParser/ModuleDescriptionParserConfig.cmake.in +++ b/ModuleDescriptionParser/ModuleDescriptionParserConfig.cmake.in @@ -9,7 +9,9 @@ set(ModuleDescriptionParser_USE_FILE "@ModuleDescriptionParser_USE_FILE_CONFIG@" ) -set(ITK_DIR "@ITK_DIR_CONFIG@") +if (NOT DEFINED ITK_DIR) + set(ITK_DIR "@ITK_DIR_CONFIG@") +endif() set(ModuleDescriptionParser_ITK_COMPONENTS "@ModuleDescriptionParser_ITK_COMPONENTS@") diff --git a/ModuleDescriptionParser/ModuleDescriptionParserInstallConfig.cmake.in b/ModuleDescriptionParser/ModuleDescriptionParserInstallConfig.cmake.in index 0490599..a315b78 100644 --- a/ModuleDescriptionParser/ModuleDescriptionParserInstallConfig.cmake.in +++ b/ModuleDescriptionParser/ModuleDescriptionParserInstallConfig.cmake.in @@ -16,4 +16,6 @@ set(ModuleDescriptionParser_USE_FILE "${ModuleDescriptionParser_CONFIG_DIR}/UseModuleDescriptionParser.cmake" ) -set(ITK_DIR "@ITK_DIR@") +if (NOT DEFINED ITK_DIR) + set(ITK_DIR "@ITK_DIR@") +endif() From e39e5a3924b40e5d0106947899adbf9217d517ed Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 18 Dec 2020 18:43:59 -0500 Subject: [PATCH 2/2] COMP: Update JsonCpp API calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To address: [3/5] Building CXX object CMakeFiles/CLPExample1Lib.dir/CLPExample1.cxx.o In file included from /home/matt/src/itk-js/test/CLPExample1/CLPExample1.cxx:1: /home/matt/src/itk-js/test/CLPExample1/CLPExample1.cxx: In function ‘int ModuleEntryPoint(int, char**)’: ./CLPExample1CLP.h:36:20: warning: ‘Reader’ is deprecated: Use CharReader and CharReaderBuilder instead. [-Wdeprecated-declarations] 36 | Json::Reader reader; \ | ^~~~~~ ./CLPExample1CLP.h:715:62: note: in expansion of macro ‘GENERATE_DESERIALIZATION’ 715 | #define PARSE_ARGS GENERATE_LOGO;GENERATE_XML;GENERATE_TCLAP;GENERATE_DESERIALIZATION;GENERATE_ECHOARGS;GENERATE_ProcessInformationAddressDecoding;GENERATE_SERIALIZATION; | ^~~~~~~~~~~~~~~~~~~~~~~~ /home/matt/src/itk-js/test/CLPExample1/CLPExample1.cxx:5:3: note: in expansion of macro ‘PARSE_ARGS’ 5 | PARSE_ARGS; | ^~~~~~~~~~ In file included from /home/matt/src/jsoncpp/include/json/json.h:11, from /home/matt/src/SlicerExecutionModel/ModuleDescriptionParser/JsonSerializationUtilities.h:18, from ./CLPExample1CLP.h:15, from /home/matt/src/itk-js/test/CLPExample1/CLPExample1.cxx:1: /home/matt/src/jsoncpp/include/json/reader.h:37:63: note: declared here 37 | "Use CharReader and CharReaderBuilder instead.") JSON_API Reader { | ^~~~~~ In file included from /home/matt/src/itk-js/test/CLPExample1/CLPExample1.cxx:1: ./CLPExample1CLP.h:36:20: warning: ‘Json::Reader::Reader()’ is deprecated: Use CharReader and CharReaderBuilder instead [-Wdeprecated-declarations] 36 | Json::Reader reader; \ | ^~~~~~ ./CLPExample1CLP.h:715:62: note: in expansion of macro ‘GENERATE_DESERIALIZATION’ 715 | #define PARSE_ARGS GENERATE_LOGO;GENERATE_XML;GENERATE_TCLAP;GENERATE_DESERIALIZATION;GENERATE_ECHOARGS;GENERATE_ProcessInformationAddressDecoding;GENERATE_SERIALIZATION; | ^~~~~~~~~~~~~~~~~~~~~~~~ /home/matt/src/itk-js/test/CLPExample1/CLPExample1.cxx:5:3: note: in expansion of macro ‘PARSE_ARGS’ 5 | PARSE_ARGS; | ^~~~~~~~~~ In file included from /home/matt/src/jsoncpp/include/json/json.h:11, from /home/matt/src/SlicerExecutionModel/ModuleDescriptionParser/JsonSerializationUtilities.h:18, from ./CLPExample1CLP.h:15, from /home/matt/src/itk-js/test/CLPExample1/CLPExample1.cxx:1: /home/matt/src/jsoncpp/include/json/reader.h:56:3: note: declared here 56 | Reader(); | ^~~~~~ In file included from /home/matt/src/itk-js/test/CLPExample1/CLPExample1.cxx:1: ./CLPExample1CLP.h:89:32: warning: ‘StyledStreamWriter’ is deprecated: Use StreamWriterBuilder instead [-Wdeprecated-declarations] 89 | Json::StyledStreamWriter writer; \ | ^~~~~~ ./CLPExample1CLP.h:715:148: note: in expansion of macro ‘GENERATE_SERIALIZATION’ 715 | #define PARSE_ARGS GENERATE_LOGO;GENERATE_XML;GENERATE_TCLAP;GENERATE_DESERIALIZATION;GENERATE_ECHOARGS;GENERATE_ProcessInformationAddressDecoding;GENERATE_SERIALIZATION; | ^~~~~~~~~~~~~~~~~~~~~~ /home/matt/src/itk-js/test/CLPExample1/CLPExample1.cxx:5:3: note: in expansion of macro ‘PARSE_ARGS’ 5 | PARSE_ARGS; | ^~~~~~~~~~ In file included from /home/matt/src/jsoncpp/include/json/json.h:13, from /home/matt/src/SlicerExecutionModel/ModuleDescriptionParser/JsonSerializationUtilities.h:18, from ./CLPExample1CLP.h:15, from /home/matt/src/itk-js/test/CLPExample1/CLPExample1.cxx:1: /home/matt/src/jsoncpp/include/json/writer.h:298:5: note: declared here 298 | StyledStreamWriter { | ^~~~~~~~~~~~~~~~~~ --- GenerateCLP/GenerateCLP.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/GenerateCLP/GenerateCLP.cxx b/GenerateCLP/GenerateCLP.cxx index b492d43..413765c 100644 --- a/GenerateCLP/GenerateCLP.cxx +++ b/GenerateCLP/GenerateCLP.cxx @@ -520,8 +520,12 @@ void GenerateDeSerialization( std::ostream & sout, | " return EXIT_FAILURE;" | " }" | " Json::Value root;" - | " Json::Reader reader;" - | " reader.parse( fStream, root );" + | " Json::CharReaderBuilder builder;" + | " JSONCPP_STRING errs;" + | " if (!parseFromStream(builder, fStream, &root, &errs)) {" + | " std::cout << errs << std::endl;" + | " return EXIT_FAILURE;" + | " }" | " const Json::Value & parameters = root[\"Parameters\"];"; typedef std::vector ModuleParameterGroupsType; @@ -686,8 +690,9 @@ void GenerateSerialization( std::ostream & sout, | " std::cerr << \"Could not open file: \" << parametersSerializeArg.getValue() << \" for writing.\" << std::endl;" | " return EXIT_FAILURE;" | " }" - | " Json::StyledStreamWriter writer;" - | " writer.write( fStream, root );" + | " Json::StreamWriterBuilder builder;" + | " const std::unique_ptr writer(builder.newStreamWriter());" + | " writer->write( root, &fStream );" | " fStream.close();" | " }"; }