David
David

Reputation: 337

how to use wildcard in cmake install

I can install one specific file. When using wildcard in the same command, it complain the file does not exist.

This is the one that works

install(FILES  ${CMAKE_CURRENT_BINARY_DIR}/libproduction_rdict.pcm DESTINATION ${LIBRARY_OUTPUT_PATH})

This is the one not working

install(FILES  ${CMAKE_CURRENT_BINARY_DIR}/*_rdict.pcm DESTINATION ${LIBRARY_OUTPUT_PATH})

The error message is:

-- Install configuration: ""
CMake Error at Source/cmake_install.cmake:49 (file):
  file INSTALL cannot find
  "/home/wxie/AI/CUDA/cuda_exmaple/example_2/Build/Source/*_rdict.pcm".
Call Stack (most recent call first):
  cmake_install.cmake:42 (include)

Upvotes: 7

Views: 8483

Answers (2)

David
David

Reputation: 337

OK. Here is what I end up doing:

add_custom_target(move_pcmfile
COMMAND mv ${BUILD_DIR}/Source/*.pcm  ${LIBRARY_OUTPUT_PATH})

After "make", I just do "make move_pcmfile". This seems to be the most convenient way of solving my problem.

Upvotes: 1

Tsyvarev
Tsyvarev

Reputation: 66089

Command flow install(FILES) requires all files to be listed explicitly.

For install several files by pattern, use install(DIRECTORY) and its PATTERN option:

install(DIRECTORY  ${CMAKE_CURRENT_BINARY_DIR} DESTINATION ${LIBRARY_OUTPUT_PATH}
    FILES_MATCHING PATTERN "*_rdict.pcm")

More information about install(DIRECTORY) and patterns can be found in documentation.

Upvotes: 12

Related Questions