I am trying a very simple ExternalProject
usage against ITK
. This will allow my automated jenkins slave to retrieve ITK
directly instead of using a system installed library (thus I leave it as an option to use ExternalProject
or not).
So I wrote the following piece of code:
set(ITK_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/ITK")
set(ITK_INSTALL_PREFIX "${ITK_PREFIX}/install-$<CONFIG>")
ExternalProject_Add(ITK
URL http://sourceforge.net/projects/itk/files/itk/4.6/InsightToolkit-4.6.1.tar.xz
URL_MD5 d8dcab9193b55d4505afa94ab46de699
PREFIX ${ITK_PREFIX}
CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF -DBUILD_TESTING:BOOL=OFF -DModule_ITKReview:BOOL=ON -DITK_USE_SYSTEM_GDCM:BOOL=ON -DCMAKE_INSTALL_PREFIX=${ITK_INSTALL_PREFIX} -DGDCM_DIR:PATH=${GDCM_INSTALL_PREFIX}
BUILD_COMMAND "${CMAKE_COMMAND}" --build . --target install --config $<CONFIG>
)
# include directory:
include_directories(${ITK_INSTALL_PREFIX}/include/ITK-4.6)
# link directory:
#link_directories(${ITK_INSTALL_PREFIX}/lib/) # $ sign is escaped
link_directories(${ITK_PREFIX}/install-/lib)
But then I fail to understand how I can possibly populate the following variable: ITK_LIBRARIES
which I had been using throughout my codebase.
How should I write:
set(ITK_LIBRARIES
itksys-4.6
ITKCommon-4.6
ITKIOImageBase-4.6
ITKIOMeta-4.6
ITKIOGDCM-4.6
pthread
...? possibly others ? possibly different order ? ...
)
This feels like a hack, extremely hard to maintain, esp. considering that I need to link to static libraries (requirements for me).
Obviously the magical solution would be for me to run find_package(ITK)
and be done. But since ExternalProject
are done at build time and not configure time, I cannot make use of this (ref).
Because people feel it is duplicate, let me insist, on: "Yes I do understand that I cannot use find_package". My question is totally different, and is rather about the complex case of static linking.
So I should not be building the ordered list of static libraries in ITK_LIBRARIES
, this is too complex. Instead I should be using the logic from a call to find_package(ITK)
.
I need to change the way I build my project and switch to a SuperBuild type solution.