Mano-Wii
Mano-Wii

Reputation: 592

How to use multiple directories of a variable for PATTERN in install?

I created a GLOBAL property with the command:

set_property(GLOBAL PROPERTY ADDON_CPYTHON_SOURCES "")

With this property, I add an indefinite number of directories through the command:

set_property(GLOBAL APPEND_STRING PROPERTY ADDON_CPYTHON_SOURCES "${_exclude_dir};")

My intention is to EXCLUDE all these directories in the install command:

  get_property(_exclude_dirs GLOBAL PROPERTY ADDON_CPYTHON_SOURCES)

  install(
    DIRECTORY ${CMAKE_SOURCE_DIR}
    DESTINATION ${TARGETDIR_VER}
    PATTERN ${_exclude_dirs} EXCLUDE
  )

But it doesn't work. For example, if I add these two directories:

"addons/example/src; addons/example1/src"

The error message is:

install DIRECTORY given unknown argument "addons/example1/src".

How can I workaround this problem?

Upvotes: 0

Views: 46

Answers (1)

Mano-Wii
Mano-Wii

Reputation: 592

I found that you can add args directly to a list:

set(PATTERN_SOURCES_EXCLUDE)

foreach(subdir ${subdir_list})
  list(APPEND PATTERN_SOURCES_EXCLUDE PATTERN "${subdir}" EXCLUDE)
endforeach()

install(
  DIRECTORY ${CMAKE_SOURCE_DIR}
  DESTINATION ${TARGETDIR_VER}
  ${PATTERN_SOURCES_EXCLUDE}
)

Upvotes: 1

Related Questions