Hi,
In SlicerConfig.cmake.in
there is a macro called slicer_config_set_ep
.
Current implementation assumes that the variable is represented as a STRING
.
And if the variable is a LIST
then cmake configure may fail. For example in my case I have some libs that I link as I dependencies:
slicer_config_set_ep(
SOME_LIB_DEPS
"/home/lib_0.so;/home/lib_1.so;/home/lib_2.so"
CACHE STRING "Path to project build directory or file" FORCE)
Then when I try to configure and build some external module I need to find_package(Slicer REQUIRED)
.
Configuring my module for the first time works fine, but when I try to reconfigure then I get error yelding that unknown property… In brief cmake tries to retrieve REALPATH
property from that "/home/lib_0.so;/home/lib_1.so;/home/lib_2.so"
To avoid that I propose to modify this macro in the following manner:
macro(slicer_config_set_ep var values)
if(NOT "${values}" STREQUAL "")
if(DEFINED ${var})
get_filename_component(var_realpath "${${var}}" REALPATH)
foreach(value ${values})
get_filename_component(val_realpath ${value} REALPATH)
if (NOT ${val_realpath} IN_LIST var_realpath)
message(FATAL_ERROR "Variable ${var} defined prior calling 'find_package(Slicer)' does NOT "
"match value used to configure Slicer. It probably means that a different "
"${var} has been used to configure this project and Slicer.\n"
"${var}=${${var}}\n"
"Slicer_${var}=${value}")
endif()
endforeach()
endif()
set(${var} "${values}" ${ARGN})
endif()
endmacro()
Thus I assume that the variable is a LIST
and I check if list contains some each path.
How do you think?
I tested this modified version and for me it works