InsightSoftwareConsortium / ITKTotalVariation

External Module for Total Variation Algorithms, providing wrap for https://github.com/albarji/proxTV
Apache License 2.0
10 stars 10 forks source link

COMP: Ensure proxTV dependencies are found when building against ITK build tree #29

Closed jcfr closed 4 years ago

jcfr commented 4 years ago

This issue was discovered in the following context:

Error reported was the following:

  CMake Error at /path/to/project-build/SlicerExecutionModel-build/CMake/SEMMacroBuildCLI.cmake:159 (add_executable):
    Target "AwesomeModule" links to target "OpenMP::OpenMP_CXX" but the
    target was not found.  Perhaps a find_package() call is missing for an
    IMPORTED target, or an ALIAS target is missing?
  Call Stack (most recent call first):
    Modules/AwesomeModule/CMakeLists.txt:46 (SEMMacroBuildCLI)
jcfr commented 4 years ago

Clean build is failing with the following configuration error:

CMake Error at /home/vsts/work/1/build/_deps/proxtv_fetch-build/proxTVConfig.cmake:11 (message):
  File or directory
  /home/vsts/work/1/build/_deps/proxtv_fetch-build/proxTVTargets.cmake
  referenced by variable proxTV_TARGETS does not exist !
Call Stack (most recent call first):
  /home/vsts/work/1/build/_deps/proxtv_fetch-build/proxTVConfig.cmake:17 (set_and_check)
  /home/vsts/work/1/ITK-build/lib/cmake/ITK-5.0/Modules/TotalVariation.cmake:20 (find_package)
  /home/vsts/work/1/ITK/CMake/ITKModuleAPI.cmake:76 (include)
  /home/vsts/work/1/ITK/CMake/ITKModuleAPI.cmake:7 (itk_module_load)
  /home/vsts/work/1/ITK/CMake/ITKModuleAPI.cmake:153 (_itk_module_use_recurse)
  /home/vsts/work/1/ITK/CMake/ITKModuleMacros.cmake:327 (itk_module_use)
  test/CMakeLists.txt:1 (itk_module_test)

Note that when I tested, I used an already configured ITK tree with an existing build of ProxTV

phcerdan commented 4 years ago

Nice, thanks @jcfr.

About the new error: could you paste the content of /home/vsts/work/1/build/_deps/proxtv_fetch-build/proxTVConfig.cmake? The set_and_check line there (17), seems brittle.

set_and_check(proxTV_TARGETS "${CMAKE_CURRENT_LIST_DIR}/proxTVTargets.cmake")

Not sure what is the most reliable way to point to the xTargets,cmake file in xConfig.cmake, I assumed that both files are always in the same dir. But seems failing...

phcerdan commented 4 years ago

I have no problems when building a project using a build tree of ITK when this module is built externally, i.e without Module_TotalVariation:BOOL=ON.

The in-source build has problems when not using SYSTEM_EIGEN too, but that not might be a problem if you are doing a superbuild. See #21

phcerdan commented 4 years ago

Merging, as the _EXPORT_CODE_BUILD of this PR looks good.