# Proposition to modify \`slicer\_config\_set\_ep\` macro to work with \`LIST\` vars

**URL:** <https://discourse.slicer.org/t/proposition-to-modify-slicer-config-set-ep-macro-to-work-with-list-vars/20042>\
**Category:** Development\
**Created:** [October 6, 2021, 11:43pm UTC](https://discourse.slicer.org/t/proposition-to-modify-slicer-config-set-ep-macro-to-work-with-list-vars/20042 "2021-10-06T23:43:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [October 6, 2021, 11:43pm UTC](https://discourse.slicer.org/t/proposition-to-modify-slicer-config-set-ep-macro-to-work-with-list-vars/20042/1 "2021-10-06T23:43:12Z")

</div>

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:

```auto
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:

```auto
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

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 7, 2021, 5:51am UTC](https://discourse.slicer.org/t/proposition-to-modify-slicer-config-set-ep-macro-to-work-with-list-vars/20042/2 "2021-10-07T05:51:46Z")

</div>

I could not really follow what your problem and solution was, but [CMake does not have a `LIST` type](https://cmake.org/cmake/help/latest/command/set.html#command:set) for cache entries, so we use a the `EP_LIST_SEPARATOR` (this special string: `^^`) to separate list items in a string.

---

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [October 7, 2021, 1:10pm UTC](https://discourse.slicer.org/t/proposition-to-modify-slicer-config-set-ep-macro-to-work-with-list-vars/20042/3 "2021-10-07T13:10:50Z")

</div>

> [@lassoan](#):
>
> [CMake does not have a `LIST` type](https://cmake.org/cmake/help/latest/command/set.html#command:set) for cache entries

I think that is the truth but we can consider `STRING` with semicolon delimited values as a `LIST` I think.  
`EP_LIST_SEPARATOR` I didn’t tested it but from `ExternalProjectDependency.cmake` I can see that it works only with `_COMMAND` options:

```bash
#.rst:
# .. cmake:variable:: EP_LIST_SEPARATOR
#
# This variable is used to separate list items when passed in various external project
# ``..._COMMAND`` options.
#
# If defaults to ``^^``.
if(NOT DEFINED EP_LIST_SEPARATOR)
  set(EP_LIST_SEPARATOR "^^")
endif()

```

I’ve recorded a small video where I’m trying to explain the problem and uploaded it on [google drive](https://drive.google.com/file/d/1IVME8_qk06iwrBKNw3o5o2flIEOvAmv1/view?usp=sharing). Please take a look

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 7, 2021, 1:15pm UTC](https://discourse.slicer.org/t/proposition-to-modify-slicer-config-set-ep-macro-to-work-with-list-vars/20042/4 "2021-10-07T13:15:31Z")

</div>

@jcfr what do you think?
