ITK
ITK copied to clipboard
Failure to configure module externally
Description
Since 5b09d546666f6110250aa7edbb59d4469791b944, configuring a module separately fails.
Steps to Reproduce
Compile ITK with default modules, then configure a module with cmake.
Expected behavior
The module is configured
Actual behavior
Tested with RTK, cmake
gives
CMake Error at /home/srit/src/itk/itk/CMake/ITKModuleAPI.cmake:78 (message):
No such module: "RTK"
Call Stack (most recent call first):
/home/srit/src/itk/itk/CMake/ITKModuleAPI.cmake:7 (itk_module_load)
/home/srit/src/itk/itk/CMake/ITKModuleAPI.cmake:153 (_itk_module_use_recurse)
/home/srit/src/itk/itk/CMake/ITKModuleMacros.cmake:324 (itk_module_use)
test/CMakeLists.txt:43 (itk_module_test)
and scifio-image, cmake
gives
CMake Error at src/CMakeLists.txt:118 (install):
install DIRECTORY given no DESTINATION!
Reverting 5b09d546666f6110250aa7edbb59d4469791b944 removes the errors.
Reproducibility
100%
Versions
master
Environment
Linux, cmake 3.20.4.
Additional Information
cc @hjmjohnson
I think I start to understand the issue. Before 5b09d546666f6110250aa7edbb59d4469791b944, the default CMAKE_INSTALL_LIBDIR
was overwritten with lib
, see here. This is no longer the case after the commit. To make it work for RTK, I had to
- rebuild ITK from scratch to use the default
CMAKE_INSTALL_LIBDIR
, i.e.lib64
on my machine, - mimick the same thing on RTK side with SimonRit/RTK@bce50cd48ea658732f8866267c8fbe4387e7b01f.
That would solve the issue (to be confirmed) but one still has to force CMAKE_INSTALL_LIBDIR to be the same as ITK's in an externally built module.
The problem has been solved in RTK since SimonRit/RTK#510 has been merged. However, I have the feeling that there is a general issue for other modules. For example, if I compile ITKSplitComponent
separately (first compile ITK, then Split component), the SplitComponent info and targets are put in cmake/ITK-5.3/Modules/SplitComponents.cmake
and cmake/ITK-5.3/Modules/Targets/SplitComponentsTargets.cmake
instead of lib/cmake/ITK-5.3/Modules/SplitComponents.cmake
and lib/cmake/ITK-5.3/Modules/Targets/SplitComponentsTargets.cmake
. Therefore, if a project uses ITK with
find_package(ITK REQUIRED COMPONENTS SplitComponent)
it won't find SplitComponent and say
CMake Error at /home/srit/src/itk/itk/CMake/ITKModuleAPI.cmake:78 (message):
No such module: "SplitComponent"
What do you think @tbirdso (since you work on SplitComponent)?
@SimonRit @tbirdso @hjmjohnson , should we add
if(NOT CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR lib)
endif()
Here: https://github.com/InsightSoftwareConsortium/ITK/blob/8e34f1078e13b4ae39d8aaa600ff936a9a3050bb/CMake/ITKModuleExternal.cmake#L74-L77
Similar to: https://github.com/SimonRit/RTK/commit/bce50cd48ea658732f8866267c8fbe4387e7b01f
?
Yes, it fixes the problem for me. Thanks!