From 202911c2b800be42a53fc5fc0b3a0cae2465d599 Mon Sep 17 00:00:00 2001 From: Tristan Laurent <tristan.laurent@cs-soprasteria.com> Date: Tue, 4 Mar 2025 16:18:15 +0100 Subject: [PATCH 1/3] COMP: disable fftw when -DOTB_USE_FFTW=OFF, avoiding GNU GPL contamination --- Modules/Core/Convolution/CMakeLists.txt | 11 ++ Modules/Core/Convolution/test/CMakeLists.txt | 60 ++++---- Modules/ThirdParty/ITK/CMakeLists.txt | 8 +- SuperBuild/CMake/External_fftw.cmake | 141 ++++++++++--------- SuperBuild/CMake/External_itk.cmake | 32 +++-- SuperBuild/CMakeLists.txt | 10 ++ 6 files changed, 153 insertions(+), 109 deletions(-) diff --git a/Modules/Core/Convolution/CMakeLists.txt b/Modules/Core/Convolution/CMakeLists.txt index 4a79021d37..66dcee3474 100644 --- a/Modules/Core/Convolution/CMakeLists.txt +++ b/Modules/Core/Convolution/CMakeLists.txt @@ -19,4 +19,15 @@ # project(OTBConvolution) + +option(OTB_USE_FFTW "Download and compile FFTW third party (license change to GPLv2)" OFF) + +if (OTB_USE_FFTW) + message(NOTICE "/!\ /!\ /!\ You are actually compiling OTB with FFTW. As FFTW is distributed under GNU GPLv2, OTB is now provided with GNU GPLv2 license /!\ /!\ /!\ ") +else() + message(STATUS "Compiling with FFTW disabled, otbOverlapSaveConvolutionImageFilter will not be available") + add_compile_definitions(ITK_USE_FFTWD=0) + add_compile_definitions(ITK_USE_FFTWF=0) +endif() + otb_module_impl() diff --git a/Modules/Core/Convolution/test/CMakeLists.txt b/Modules/Core/Convolution/test/CMakeLists.txt index ebb6f84892..e76c0e59fa 100644 --- a/Modules/Core/Convolution/test/CMakeLists.txt +++ b/Modules/Core/Convolution/test/CMakeLists.txt @@ -23,11 +23,14 @@ otb_module_test() set(OTBConvolutionTests otbConvolutionTestDriver.cxx otbConvolutionImageFilter.cxx -otbOverlapSaveConvolutionImageFilter.cxx otbCompareOverlapSaveAndClassicalConvolutionWithGaborFilter.cxx otbGaborFilterGenerator.cxx ) +if (OTB_USE_FFTW) + list(APPEND OTBConvolutionTests otbOverlapSaveConvolutionImageFilter.cxx) +endif() + add_executable(otbConvolutionTestDriver ${OTBConvolutionTests}) target_link_libraries(otbConvolutionTestDriver ${OTBConvolution-Test_LIBRARIES}) otb_module_target_label(otbConvolutionTestDriver) @@ -43,35 +46,34 @@ otb_add_test(NAME bfTvConvolutionImageFilter COMMAND otbConvolutionTestDriver ${TEMP}/bfTvConvolutionImageFilter.tif ) -if(ITK_USE_FFTWD) - -if(MSVC AND (CMAKE_SIZEOF_VOID_P EQUAL "4")) - message(WARNING "Disable OverlapSaveConvolution tests") -else() -otb_add_test(NAME bfTvOverlapSaveConvolutionImageFilter COMMAND otbConvolutionTestDriver - --compare-image ${EPSILON_7} - ${BASELINE}/bfTvConvolutionImageFilter.tif - ${TEMP}/bfTvOverlapSaveConvolutionImageFilter.tif - otbOverlapSaveConvolutionImageFilter - ${INPUTDATA}/QB_Suburb.png - ${TEMP}/bfTvOverlapSaveConvolutionImageFilter.tif - ) +if(OTB_USE_FFTW) + if(MSVC AND (CMAKE_SIZEOF_VOID_P EQUAL "4")) + message(WARNING "Disable OverlapSaveConvolution tests") + else() + otb_add_test(NAME bfTvOverlapSaveConvolutionImageFilter COMMAND otbConvolutionTestDriver + --compare-image ${EPSILON_7} + ${BASELINE}/bfTvConvolutionImageFilter.tif + ${TEMP}/bfTvOverlapSaveConvolutionImageFilter.tif + otbOverlapSaveConvolutionImageFilter + ${INPUTDATA}/QB_Suburb.png + ${TEMP}/bfTvOverlapSaveConvolutionImageFilter.tif + ) -otb_add_test(NAME bfTvCompareOverlapSaveAndClassicalConvolutionWithGaborFilter COMMAND otbConvolutionTestDriver - --compare-image ${EPSILON_7} - ${TEMP}/bfTvCompareConvolutionOutput.tif - ${TEMP}/bfTvCompareOSConvolutionoutput.tif - otbCompareOverlapSaveAndClassicalConvolutionWithGaborFilter - ${INPUTDATA}/QB_PAN_ROI_1000_100.tif - ${TEMP}/bfTvCompareConvolutionOutput.tif - ${TEMP}/bfTvCompareOSConvolutionoutput.tif - 32 32 #Radius - 0.02 0.025 # a b - -45 # theta - 0.0125 0.0125 #u0 v0 - 0 - ) -endif() + otb_add_test(NAME bfTvCompareOverlapSaveAndClassicalConvolutionWithGaborFilter COMMAND otbConvolutionTestDriver + --compare-image ${EPSILON_7} + ${TEMP}/bfTvCompareConvolutionOutput.tif + ${TEMP}/bfTvCompareOSConvolutionoutput.tif + otbCompareOverlapSaveAndClassicalConvolutionWithGaborFilter + ${INPUTDATA}/QB_PAN_ROI_1000_100.tif + ${TEMP}/bfTvCompareConvolutionOutput.tif + ${TEMP}/bfTvCompareOSConvolutionoutput.tif + 32 32 #Radius + 0.02 0.025 # a b + -45 # theta + 0.0125 0.0125 #u0 v0 + 0 + ) + endif() endif() diff --git a/Modules/ThirdParty/ITK/CMakeLists.txt b/Modules/ThirdParty/ITK/CMakeLists.txt index 1efa7de0b4..c40641a5c3 100644 --- a/Modules/ThirdParty/ITK/CMakeLists.txt +++ b/Modules/ThirdParty/ITK/CMakeLists.txt @@ -23,7 +23,13 @@ project(OTBITK) set(OTBITK_SYSTEM_INCLUDE_DIRS ${ITK_INCLUDE_DIRS}) set(OTBITK_SYSTEM_LIBRARY_DIRS ${ITK_LIBRARY_DIRS}) list(REMOVE_DUPLICATES OTBITK_SYSTEM_LIBRARY_DIRS) -set(OTBITK_LIBRARIES "${ITK_LIBRARIES}" ${FFTWD_BASE_LIB} ${FFTWD_THREADS_LIB} ${FFTWF_BASE_LIB} ${FFTWF_THREADS_LIB}) + +if (OTB_USE_FFTW) + set(OTBITK_LIBRARIES "${ITK_LIBRARIES}" ${FFTWD_BASE_LIB} ${FFTWD_THREADS_LIB} ${FFTWF_BASE_LIB} ${FFTWF_THREADS_LIB}) +else() + set(OTBITK_LIBRARIES "${ITK_LIBRARIES}") +endif() + set(OTBITK_EXPORT_CODE_BUILD "find_package(ITK REQUIRED COMPONENTS ${OTBITK_ITK_REQUIRED_MODULE_LIST} HINTS ${ITK_DIR})") set(OTBITK_EXPORT_CODE_INSTALL ${OTBITK_EXPORT_CODE_BUILD}) diff --git a/SuperBuild/CMake/External_fftw.cmake b/SuperBuild/CMake/External_fftw.cmake index bcc242186a..f3a0c3f7de 100644 --- a/SuperBuild/CMake/External_fftw.cmake +++ b/SuperBuild/CMake/External_fftw.cmake @@ -18,78 +18,83 @@ # limitations under the License. # -INCLUDE_ONCE_MACRO(FFTW) +if (OTB_USE_FFTW) + INCLUDE_ONCE_MACRO(FFTW) -SETUP_SUPERBUILD(FFTW) + SETUP_SUPERBUILD(FFTW) + message(AUTHOR_WARNING "/!\\/!\\/!\\ You are actually compiling OTB with FFTW. As FFTW is distributed under GNU GPLv2, OTB is now provided with GNU GPLv2 license /!\\/!\\/!\\") -set(FFTWF_SB_SRC ${CMAKE_BINARY_DIR}/FFTW/src/FFTWF) -set(FFTWD_SB_SRC ${CMAKE_BINARY_DIR}/FFTW/src/FFTWD) -set(FFTWF_SB_BUILD ${CMAKE_BINARY_DIR}/FFTW/build/FFTWF) -set(FFTWD_SB_BUILD ${CMAKE_BINARY_DIR}/FFTW/build/FFTWD) + set(FFTWF_SB_SRC ${CMAKE_BINARY_DIR}/FFTW/src/FFTWF) + set(FFTWD_SB_SRC ${CMAKE_BINARY_DIR}/FFTW/src/FFTWD) + set(FFTWF_SB_BUILD ${CMAKE_BINARY_DIR}/FFTW/build/FFTWF) + set(FFTWD_SB_BUILD ${CMAKE_BINARY_DIR}/FFTW/build/FFTWD) -if(WIN32) - set(FFTW_SB_CONFIG -DWITH_COMBINED_THREADS:BOOL=ON) -else() - set(FFTW_SB_CONFIG -DWITH_COMBINED_THREADS:BOOL=OFF) -endif() + if(WIN32) + set(FFTW_SB_CONFIG -DWITH_COMBINED_THREADS:BOOL=ON) + else() + set(FFTW_SB_CONFIG -DWITH_COMBINED_THREADS:BOOL=OFF) + endif() -# Compile the float version of FFTW -ExternalProject_Add(FFTWF - PREFIX FFTW/FFTWF - URL "https://fftw.org/fftw-3.3.10.tar.gz" - URL_MD5 8ccbf6a5ea78a16dbc3e1306e234cc5c - SOURCE_DIR ${FFTWF_SB_SRC} - BINARY_DIR ${FFTWF_SB_BUILD} - INSTALL_DIR ${SB_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - CMAKE_CACHE_ARGS - ${SB_CMAKE_CACHE_ARGS} - -DCMAKE_INSTALL_LIBDIR:PATH=lib - -DBUILD_TESTS:BOOL=OFF - -DDISABLE_FORTRAN:BOOL=ON - -DENABLE_THREADS:BOOL=ON - -DENABLE_SSE2:BOOL=ON - -DENABLE_FLOAT:BOOL=ON - ${FFTW_SB_CONFIG} - DEPENDS ${FFTW_DEPENDENCIES} - LOG_DOWNLOAD 1 - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 - ) + # Compile the float version of FFTW + ExternalProject_Add(FFTWF + PREFIX FFTW/FFTWF + URL "https://fftw.org/fftw-3.3.10.tar.gz" + URL_MD5 8ccbf6a5ea78a16dbc3e1306e234cc5c + SOURCE_DIR ${FFTWF_SB_SRC} + BINARY_DIR ${FFTWF_SB_BUILD} + INSTALL_DIR ${SB_INSTALL_PREFIX} + DOWNLOAD_DIR ${DOWNLOAD_LOCATION} + CMAKE_CACHE_ARGS + ${SB_CMAKE_CACHE_ARGS} + -DCMAKE_INSTALL_LIBDIR:PATH=lib + -DBUILD_TESTS:BOOL=OFF + -DDISABLE_FORTRAN:BOOL=ON + -DENABLE_THREADS:BOOL=ON + -DENABLE_SSE2:BOOL=ON + -DENABLE_FLOAT:BOOL=ON + ${FFTW_SB_CONFIG} + DEPENDS ${FFTW_DEPENDENCIES} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 + ) -# Compile the double version of FFTW -ExternalProject_Add(FFTWD - PREFIX FFTW/FFTWD - URL "https://fftw.org/fftw-3.3.10.tar.gz" - URL_MD5 8ccbf6a5ea78a16dbc3e1306e234cc5c - SOURCE_DIR ${FFTWD_SB_SRC} - BINARY_DIR ${FFTWD_SB_BUILD} - INSTALL_DIR ${SB_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - CMAKE_CACHE_ARGS - ${SB_CMAKE_CACHE_ARGS} - -DCMAKE_INSTALL_LIBDIR:PATH=lib - -DBUILD_TESTS:BOOL=OFF - -DDISABLE_FORTRAN:BOOL=ON - -DENABLE_THREADS:BOOL=ON - -DENABLE_SSE2:BOOL=ON - -DENABLE_FLOAT:BOOL=OFF - ${FFTW_SB_CONFIG} - DEPENDS FFTWF - LOG_DOWNLOAD 1 - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 - ) + # Compile the double version of FFTW + ExternalProject_Add(FFTWD + PREFIX FFTW/FFTWD + URL "https://fftw.org/fftw-3.3.10.tar.gz" + URL_MD5 8ccbf6a5ea78a16dbc3e1306e234cc5c + SOURCE_DIR ${FFTWD_SB_SRC} + BINARY_DIR ${FFTWD_SB_BUILD} + INSTALL_DIR ${SB_INSTALL_PREFIX} + DOWNLOAD_DIR ${DOWNLOAD_LOCATION} + CMAKE_CACHE_ARGS + ${SB_CMAKE_CACHE_ARGS} + -DCMAKE_INSTALL_LIBDIR:PATH=lib + -DBUILD_TESTS:BOOL=OFF + -DDISABLE_FORTRAN:BOOL=ON + -DENABLE_THREADS:BOOL=ON + -DENABLE_SSE2:BOOL=ON + -DENABLE_FLOAT:BOOL=OFF + ${FFTW_SB_CONFIG} + DEPENDS FFTWF + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 + ) -ExternalProject_Add(FFTW - PREFIX FFTW - DOWNLOAD_COMMAND "" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - DEPENDS FFTWD - ) + ExternalProject_Add(FFTW + PREFIX FFTW + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + DEPENDS FFTWD + ) -set(_SB_FFTW_INCLUDE_PATH ${SB_INSTALL_PREFIX}/include) + set(_SB_FFTW_INCLUDE_PATH ${SB_INSTALL_PREFIX}/include) +else() + message(STATUS "Compiling with FFTW disabled, otbOverlapSaveConvolutionImageFilter will not be available") +endif() diff --git a/SuperBuild/CMake/External_itk.cmake b/SuperBuild/CMake/External_itk.cmake index 8357ad767e..a03dccb487 100644 --- a/SuperBuild/CMake/External_itk.cmake +++ b/SuperBuild/CMake/External_itk.cmake @@ -114,19 +114,29 @@ foreach(ITK_MODULE ${ITK_ENABLED_MODULES}) endforeach() # declare dependencies -ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(ITK ZLIB FFTW) +# by default we don't distribute otb with fftw as it implies a GPLv2 +# contamination +if (OTB_USE_FFTW) + ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(ITK ZLIB FFTW) +else() + ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(ITK ZLIB) + add_compile_definitions(ITK_USE_FFTWD=0) + add_compile_definitions(ITK_USE_FFTWF=0) +endif() ADD_SUPERBUILD_CMAKE_VAR(ITK ZLIB_INCLUDE_DIR) ADD_SUPERBUILD_CMAKE_VAR(ITK ZLIB_LIBRARY) -# These variables are used in ITK to initialize the value of the ITK_USE_FFTW_XXX options -list(APPEND ITK_SB_CONFIG - -DUSE_FFTWF:BOOL=ON - -DUSE_FFTWD:BOOL=ON - -DUSE_SYSTEM_FFTW:BOOL=ON - ) -ADD_SUPERBUILD_CMAKE_VAR(ITK FFTW_INCLUDE_PATH) -ADD_SUPERBUILD_CMAKE_VAR(ITK FFTW_LIBRARIES) -ADD_SUPERBUILD_CMAKE_VAR(ITK FFTWD_LIBRARIES) +if (OTB_USE_FFTW) + # These variables are used in ITK to initialize the value of the ITK_USE_FFTW_XXX options + list(APPEND ITK_SB_CONFIG + -DUSE_FFTWF:BOOL=ON + -DUSE_FFTWD:BOOL=ON + -DUSE_SYSTEM_FFTW:BOOL=ON + ) + ADD_SUPERBUILD_CMAKE_VAR(ITK FFTW_INCLUDE_PATH) + ADD_SUPERBUILD_CMAKE_VAR(ITK FFTW_LIBRARIES) + ADD_SUPERBUILD_CMAKE_VAR(ITK FFTWD_LIBRARIES) +endif() if (WIN32) list(APPEND ITK_SB_CONFIG @@ -169,4 +179,4 @@ ExternalProject_Add(ITK LOG_INSTALL 1 ) -SUPERBUILD_PATCH_SOURCE(ITK) \ No newline at end of file +SUPERBUILD_PATCH_SOURCE(ITK) diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index f1bcd99adb..579b767bbf 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -22,6 +22,15 @@ cmake_minimum_required(VERSION 3.10.2) project(OTB-SuperBuild) +if(POLICY CMP0135) + # avoid cmake warnings about missing DOWNLOAD_EXTRACT_TIMESTAMP + # when using ExternalProject_Add in External_<dep>.cmake files. + # As we also build on rhel and cmake version < 3.24 here, + # we need to use policy settings + cmake_policy(SET CMP0135 NEW) +endif() + + set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) @@ -276,6 +285,7 @@ option(OTB_USE_CURL "Enable module Curl in OTB" ON) option(OTB_USE_SIFTFAST "Enable module Siftfast in OTB" ON) option(OTB_USE_GSL "Enable module GSL in OTB" ON) option(OTB_USE_LIBKML "Enable module libKML in OTB" OFF) +option(OTB_USE_FFTW "Download and compile FFTW third party (license change to GPLv2)" OFF) #option() does not change the value in cache so we have to set the option via the set CACHE FORCE method if(OTB_BUILD_Learning MATCHES ON) set(OTB_USE_LIBSVM ON CACHE BOOL "Enable module LibSVM in OTB" FORCE) -- GitLab From b3b80528f84a4d629e241f574b970c7cd3d3b3ec Mon Sep 17 00:00:00 2001 From: Tristan Laurent <tristan.laurent@cs-soprasteria.com> Date: Wed, 12 Mar 2025 11:59:01 +0100 Subject: [PATCH 2/3] COMP: disable FFTW test by default but check them in CI --- .gitignore | 3 + .gitlab-ci.yml | 1 + CI/FFTW_tests.cmake | 96 +++++++++++++++++++ CI/ubuntu-22.04-fast.cmake | 1 + Modules/Core/Convolution/CMakeLists.txt | 5 +- .../otbOverlapSaveConvolutionImageFilter.hxx | 6 +- Modules/Core/Convolution/test/CMakeLists.txt | 6 +- .../test/otbConvolutionTestDriver.cxx | 3 +- .../test/otbFourierMellinImageFilter.cxx | 2 + SuperBuild/CMake/External_itk.cmake | 2 - 10 files changed, 114 insertions(+), 11 deletions(-) create mode 100644 CI/FFTW_tests.cmake diff --git a/.gitignore b/.gitignore index 17ea701d13..abe3eaa101 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ archives* CMakeLists.txt.user .directory* build_packages* +build +install +log diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d249b8c876..d430c3408b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -128,6 +128,7 @@ fast-build: - git checkout -f -q $CI_COMMIT_SHA script: - ctest -V -S CI/main_ci.cmake -DIMAGE_NAME:string=ubuntu-22.04-fast + - ctest -VV -S CI/FFTW_tests.cmake -DIMAGE_NAME:string=ubuntu-22.04-fast - ccache -s legal-check: diff --git a/CI/FFTW_tests.cmake b/CI/FFTW_tests.cmake new file mode 100644 index 0000000000..abdbada268 --- /dev/null +++ b/CI/FFTW_tests.cmake @@ -0,0 +1,96 @@ +# +# Copyright (C) 2005-2024 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +include( "${CMAKE_CURRENT_LIST_DIR}/macros.cmake" ) +get_filename_component(OTB_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) +set (ENV{LANG} "C") # Only ascii output + +# Build Configuration : Release, Debug.. +if(ci_build_type) + set (CTEST_BUILD_CONFIGURATION ${ci_build_type}) +else() + set (CTEST_BUILD_CONFIGURATION "Release") +endif() + +set (CTEST_CMAKE_GENERATOR "Ninja") + +# detect short sha +if(NOT DEFINED ENV{CI_COMMIT_SHORT_SHA}) + execute_process(COMMAND git log -1 --pretty=format:%h + WORKING_DIRECTORY ${OTB_SOURCE_DIR} + OUTPUT_VARIABLE ci_short_sha) +else() + set(ci_short_sha "$ENV{CI_COMMIT_SHORT_SHA}") +endif() + +# Find the build name and CI profile. Customize it with FFTW +set_dash_build_name() +set (CTEST_BUILD_NAME "FFTW Tests ${ci_ref_name} P-${ci_pipeline_id}") + +# Detect site +if(NOT DEFINED IMAGE_NAME) + if(DEFINED ENV{IMAGE_NAME}) + set(IMAGE_NAME $ENV{IMAGE_NAME}) + endif() +endif() +set (CTEST_SITE "${IMAGE_NAME}") + +# Directory variable +set (CTEST_SOURCE_DIRECTORY "${OTB_SOURCE_DIR}") +if(BUILD_DIR) + set (CTEST_BINARY_DIRECTORY "${BUILD_DIR}") +else() + set (CTEST_BINARY_DIRECTORY "${OTB_SOURCE_DIR}/build/") +endif() +set (CTEST_INSTALL_DIRECTORY "${OTB_SOURCE_DIR}/install/") +set (PROJECT_SOURCE_DIR "${OTB_SOURCE_DIR}") + +# Ctest command value +set (CMAKE_COMMAND "cmake") + +message(STATUS "CI profile : ${ci_profile}") + +# Sources are already checked out : do nothing for update +set(CTEST_GIT_UPDATE_CUSTOM "${CMAKE_COMMAND}" "-E" "echo" "No update") +# Look for a GIT command-line client. +find_program(CTEST_GIT_COMMAND NAMES git git.cmd) + + + +ctest_start (Experimental TRACK CI_Build) + +ctest_update() + +#Â Run only onverlapSave tests +ctest_test(PARALLEL_LEVEL 8 + RETURN_VALUE _test_rv + CAPTURE_CMAKE_ERROR _test_error + INCLUDE "OverlapSave" + ) + # Test log +file ( WRITE +"${OTB_SOURCE_DIR}/log/test_return_value_log.txt" "${_test_rv}") +file ( WRITE +"${OTB_SOURCE_DIR}/log/test_cmake_error_log.txt" "${_test_error}") + +if ( NOT _test_rv EQUAL 0 ) + message( SEND_ERROR "An error occurs during ctest_test.") +endif() + +ctest_submit() diff --git a/CI/ubuntu-22.04-fast.cmake b/CI/ubuntu-22.04-fast.cmake index 7ca25a3da3..78c2303422 100644 --- a/CI/ubuntu-22.04-fast.cmake +++ b/CI/ubuntu-22.04-fast.cmake @@ -26,6 +26,7 @@ CMAKE_CXX_COMPILER:STRING=g++ CMAKE_C_COMPILER_LAUNCHER:STRING=ccache CMAKE_CXX_COMPILER_LAUNCHER:STRING=ccache OTB_USE_SHARK:BOOL=OFF +OTB_USE_FFTW:BOOL=ON BUILD_EXAMPLES:BOOL=OFF") set(ci_skip_testing ON) diff --git a/Modules/Core/Convolution/CMakeLists.txt b/Modules/Core/Convolution/CMakeLists.txt index 66dcee3474..262a67e778 100644 --- a/Modules/Core/Convolution/CMakeLists.txt +++ b/Modules/Core/Convolution/CMakeLists.txt @@ -21,13 +21,10 @@ project(OTBConvolution) option(OTB_USE_FFTW "Download and compile FFTW third party (license change to GPLv2)" OFF) - if (OTB_USE_FFTW) - message(NOTICE "/!\ /!\ /!\ You are actually compiling OTB with FFTW. As FFTW is distributed under GNU GPLv2, OTB is now provided with GNU GPLv2 license /!\ /!\ /!\ ") + message(NOTICE "/!\\ /!\\ /!\\ You are actually compiling OTB with FFTW. As FFTW is distributed under GNU GPLv2, OTB is now provided with GNU GPLv2 license /!\\ /!\\ /!\\ ") else() message(STATUS "Compiling with FFTW disabled, otbOverlapSaveConvolutionImageFilter will not be available") - add_compile_definitions(ITK_USE_FFTWD=0) - add_compile_definitions(ITK_USE_FFTWF=0) endif() otb_module_impl() diff --git a/Modules/Core/Convolution/include/otbOverlapSaveConvolutionImageFilter.hxx b/Modules/Core/Convolution/include/otbOverlapSaveConvolutionImageFilter.hxx index df27d747d1..d09a2f3a48 100644 --- a/Modules/Core/Convolution/include/otbOverlapSaveConvolutionImageFilter.hxx +++ b/Modules/Core/Convolution/include/otbOverlapSaveConvolutionImageFilter.hxx @@ -35,7 +35,7 @@ #include "itkImageRegionIterator.h" #include "otbMath.h" -#ifdef ITK_USE_FFTWD +#ifdef OTB_USE_FFTW #include "itkFFTWCommon.h" #endif @@ -54,7 +54,7 @@ OverlapSaveConvolutionImageFilter<TInputImage, TOutputImage, TBoundaryCondition> template <class TInputImage, class TOutputImage, class TBoundaryCondition> void OverlapSaveConvolutionImageFilter<TInputImage, TOutputImage, TBoundaryCondition>::GenerateInputRequestedRegion() { -#if defined ITK_USE_FFTWD +#if defined OTB_USE_FFTW // call the superclass' implementation of this method Superclass::GenerateInputRequestedRegion(); @@ -108,7 +108,7 @@ void OverlapSaveConvolutionImageFilter<TInputImage, TOutputImage, TBoundaryCondi * ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) */ ::GenerateData() { -#if defined ITK_USE_FFTWD +#if defined OTB_USE_FFTW // Input/Output pointers typename OutputImageType::Pointer output = this->GetOutput(); typename InputImageType::ConstPointer input = this->GetInput(); diff --git a/Modules/Core/Convolution/test/CMakeLists.txt b/Modules/Core/Convolution/test/CMakeLists.txt index e76c0e59fa..b7826c0923 100644 --- a/Modules/Core/Convolution/test/CMakeLists.txt +++ b/Modules/Core/Convolution/test/CMakeLists.txt @@ -32,6 +32,11 @@ if (OTB_USE_FFTW) endif() add_executable(otbConvolutionTestDriver ${OTBConvolutionTests}) +# enable FFTW tests when using OTB_USE_FFTW option +if (OTB_USE_FFTW) + target_compile_definitions(otbConvolutionTestDriver PUBLIC "OTB_USE_FFTW=1") +endif() + target_link_libraries(otbConvolutionTestDriver ${OTBConvolution-Test_LIBRARIES}) otb_module_target_label(otbConvolutionTestDriver) @@ -74,7 +79,6 @@ if(OTB_USE_FFTW) 0 ) endif() - endif() otb_add_test(NAME bfTvGaborFilterGenerator COMMAND otbConvolutionTestDriver diff --git a/Modules/Core/Convolution/test/otbConvolutionTestDriver.cxx b/Modules/Core/Convolution/test/otbConvolutionTestDriver.cxx index 9e5a6dc2d2..f239f6d761 100644 --- a/Modules/Core/Convolution/test/otbConvolutionTestDriver.cxx +++ b/Modules/Core/Convolution/test/otbConvolutionTestDriver.cxx @@ -19,11 +19,12 @@ */ #include "otbTestMain.h" +#include <iostream> void RegisterTests() { REGISTER_TEST(otbConvolutionImageFilter); -#if defined(ITK_USE_FFTWD) +#if defined(OTB_USE_FFTW) REGISTER_TEST(otbOverlapSaveConvolutionImageFilter); REGISTER_TEST(otbCompareOverlapSaveAndClassicalConvolutionWithGaborFilter); #endif diff --git a/Modules/Core/Descriptors/test/otbFourierMellinImageFilter.cxx b/Modules/Core/Descriptors/test/otbFourierMellinImageFilter.cxx index 5fb2f52df6..827d8a15d8 100644 --- a/Modules/Core/Descriptors/test/otbFourierMellinImageFilter.cxx +++ b/Modules/Core/Descriptors/test/otbFourierMellinImageFilter.cxx @@ -87,6 +87,7 @@ int otbFourierMellinImageFilter(int itkNotUsed(argc), char* argv[]) imaginaryWriter->SetInput(imaginaryRescaler->GetOutput()); imaginaryWriter->Update(); // Hugly hack for cleaning fftw threads +#if defined(OTB_USE_FFTW) #if defined(ITK_USE_FFTWF) fftwf_cleanup_threads(); fftwf_cleanup(); @@ -94,6 +95,7 @@ int otbFourierMellinImageFilter(int itkNotUsed(argc), char* argv[]) #if defined(ITK_USE_FFTWD) fftw_cleanup_threads(); fftw_cleanup(); +#endif #endif return EXIT_SUCCESS; } diff --git a/SuperBuild/CMake/External_itk.cmake b/SuperBuild/CMake/External_itk.cmake index a03dccb487..1e69a8572e 100644 --- a/SuperBuild/CMake/External_itk.cmake +++ b/SuperBuild/CMake/External_itk.cmake @@ -120,8 +120,6 @@ if (OTB_USE_FFTW) ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(ITK ZLIB FFTW) else() ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(ITK ZLIB) - add_compile_definitions(ITK_USE_FFTWD=0) - add_compile_definitions(ITK_USE_FFTWF=0) endif() ADD_SUPERBUILD_CMAKE_VAR(ITK ZLIB_INCLUDE_DIR) ADD_SUPERBUILD_CMAKE_VAR(ITK ZLIB_LIBRARY) -- GitLab From e59234b5d8aec08e2fe2887aa685fe2972ad9b2b Mon Sep 17 00:00:00 2001 From: Tristan Laurent <tristan.laurent@cs-soprasteria.com> Date: Wed, 12 Mar 2025 16:03:00 +0100 Subject: [PATCH 3/3] TEST: get data only for convol test --- .gitlab-ci.yml | 5 +++++ Modules/Core/Convolution/test/otbConvolutionTestDriver.cxx | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d430c3408b..4070bc159b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -126,6 +126,11 @@ fast-build: before_script: - export GIT_LFS_SKIP_SMUDGE=1 - git checkout -f -q $CI_COMMIT_SHA + # pull data needed by the two convolution test + - | + git lfs pull --include Data/Baseline/OTB/Images/bfTvConvolutionImageFilter.tif + git lfs pull --include Data/Input/QB_Suburb.png + git lfs pull --include Data/Input/QB_PAN_ROI_1000_100.tif script: - ctest -V -S CI/main_ci.cmake -DIMAGE_NAME:string=ubuntu-22.04-fast - ctest -VV -S CI/FFTW_tests.cmake -DIMAGE_NAME:string=ubuntu-22.04-fast diff --git a/Modules/Core/Convolution/test/otbConvolutionTestDriver.cxx b/Modules/Core/Convolution/test/otbConvolutionTestDriver.cxx index f239f6d761..0bd5419a27 100644 --- a/Modules/Core/Convolution/test/otbConvolutionTestDriver.cxx +++ b/Modules/Core/Convolution/test/otbConvolutionTestDriver.cxx @@ -19,7 +19,6 @@ */ #include "otbTestMain.h" -#include <iostream> void RegisterTests() { -- GitLab