From 917005981bfcbc6cb10c647e810950fff37b9081 Mon Sep 17 00:00:00 2001 From: Christophe Palmann <christophe.palmann@c-s.fr> Date: Thu, 19 Mar 2015 09:58:36 +0100 Subject: [PATCH] COMP: fixed OTBSupervisedHeaderTest1 compilation when OTB_USE_LIBSVM and OTB_USE_OPENCV are turned off --- CMake/OTBModuleHeaderTest.cmake | 27 +++++++++++++++++++ .../otbMachineLearningModelFactory.txx | 6 ++++- Utilities/Maintenance/BuildHeaderTest.py | 5 ++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/CMake/OTBModuleHeaderTest.cmake b/CMake/OTBModuleHeaderTest.cmake index 17587f1d30..ab87de1195 100644 --- a/CMake/OTBModuleHeaderTest.cmake +++ b/CMake/OTBModuleHeaderTest.cmake @@ -19,6 +19,32 @@ add_custom_target( OTBHeaderTests ${CMAKE_COMMAND} --build ${OTB_BINARY_DIR} COMMENT "Regenerating and building the header tests." ) + + +SET(BANNED_HEADERS) +if(NOT OTB_USE_OPENCV) + string(CONCAT BANNED_HEADERS ${BANNED_HEADERS} "otbDecisionTreeMachineLearningModelFactory.h otbDecisionTreeMachineLearningModel.h otbKNearestNeighborsMachineLearningModelFactory.h otbKNearestNeighborsMachineLearningModel.h otbRandomForestsMachineLearningModelFactory.h otbRandomForestsMachineLearningModel.h otbSVMMachineLearningModelFactory.h otbSVMMachineLearningModel.h otbGradientBoostedTreeMachineLearningModelFactory.h otbGradientBoostedTreeMachineLearningModel.h otbBoostMachineLearningModelFactory.h otbBoostMachineLearningModel.h otbNeuralNetworkMachineLearningModelFactory.h otbNeuralNetworkMachineLearningModel.h otbNormalBayesMachineLearningModelFactory.h otbNormalBayesMachineLearningModel.h otbRequiresOpenCVCheck.h ") + string(STRIP ${BANNED_HEADERS} BANNED_HEADERS) + string(CONCAT BANNED_HEADERS ${BANNED_HEADERS} " ") +endif() + +if(NOT OTB_USE_LIBSVM) + string(CONCAT BANNED_HEADERS ${BANNED_HEADERS} "otbLibSVMMachineLearningModel.h otbLibSVMMachineLearningModelFactory.h") + string(STRIP ${BANNED_HEADERS} BANNED_HEADERS) + string(CONCAT BANNED_HEADERS ${BANNED_HEADERS} " ") +endif() + +# ************ ADD YOUR BANNED HEADERS HERE ************ +#if(CONDITION) +# string(CONCAT BANNED_HEADERS ${BANNED_HEADERS} "BANNED-HEADER1.h") +# string(STRIP ${BANNED_HEADERS} BANNED_HEADERS) +# string(CONCAT BANNED_HEADERS ${BANNED_HEADERS} " ") +#endif() + +string(STRIP ${BANNED_HEADERS} BANNED_HEADERS) + + + macro( otb_module_headertest _name ) if( NOT ${_name}_THIRD_PARTY AND EXISTS ${${_name}_SOURCE_DIR}/include @@ -83,6 +109,7 @@ macro( otb_module_headertest _name ) ${${_name}_BINARY_DIR} ${MAXIMUM_NUMBER_OF_HEADERS} ${_test_num} + ${BANNED_HEADERS} ) add_executable( ${_test_name} ${_header_test_src} ) target_link_libraries( ${_test_name} OTBCommon ) diff --git a/Modules/Learning/Supervised/include/otbMachineLearningModelFactory.txx b/Modules/Learning/Supervised/include/otbMachineLearningModelFactory.txx index 36372b8ab3..7fe0d4301e 100644 --- a/Modules/Learning/Supervised/include/otbMachineLearningModelFactory.txx +++ b/Modules/Learning/Supervised/include/otbMachineLearningModelFactory.txx @@ -28,7 +28,9 @@ #include "otbDecisionTreeMachineLearningModelFactory.h" #include "otbGradientBoostedTreeMachineLearningModelFactory.h" #endif +#ifdef OTB_USE_LIBSVM #include "otbLibSVMMachineLearningModelFactory.h" +#endif #include "itkMutexLockHolder.h" @@ -88,8 +90,10 @@ MachineLearningModelFactory<TInputValue,TOutputValue> ::RegisterBuiltInFactories() { itk::MutexLockHolder<itk::SimpleMutexLock> lockHolder(mutex); - + +#ifdef OTB_USE_LIBSVM RegisterFactory(LibSVMMachineLearningModelFactory<TInputValue,TOutputValue>::New()); +#endif #ifdef OTB_USE_OPENCV RegisterFactory(RandomForestsMachineLearningModelFactory<TInputValue,TOutputValue>::New()); diff --git a/Utilities/Maintenance/BuildHeaderTest.py b/Utilities/Maintenance/BuildHeaderTest.py index f98860681b..d98035598c 100644 --- a/Utilities/Maintenance/BuildHeaderTest.py +++ b/Utilities/Maintenance/BuildHeaderTest.py @@ -30,8 +30,8 @@ test is to make sure there are not missing module dependencies. It also tests for syntax and missing #include's. """ -# Headers to not test because of dependecy issues, etc. -BANNED_HEADERS = set(()) # No banned headers in OTB for now +# BANNED_HEADERS = Headers to not test because of dependecy issues, etc. + HEADER = """/*========================================================================= * @@ -81,6 +81,7 @@ def main(): module_binary_path = sys.argv[3] maximum_number_of_headers = int(sys.argv[4]) test_num = int(sys.argv[5]) + BANNED_HEADERS = sys.argv[6].split(' ') # Get all the header files. include_dir = os.path.join(module_source_path, 'include') -- GitLab