Fwd: Re: [CMake] Copying matching files

Brad King brad.king at kitware.com
Tue Oct 3 12:45:32 EDT 2006


Hugo Costelha wrote:
> On Tuesday 03 October 2006 16:07, you wrote:
>> You can add a custom target that runs
>>
>> cmake -P myscript.cmake
>>
>> and then put the glob/copy code in the script.  In the script use
>> EXECUTE_PROCESS to call cmake -E copy in a FOREACH on the result of the
>> glob.
> 
> Thanks for the quick reply. However, I still have a problem. Running the
> script, it has no knowledge of  ${LIBRARY_OUTPUT_PATH}, which has been
> defined previously. Can I pass some arguments, or something?

You can pass arguments:

  cmake -DMYVAR=myval -P myscript.cmake

The -D options have to come before the -P option.

Since you might have to set several values it may be simpler to use
CONFIGURE_FILE to configure the script with the proper values already in
place:

# myscript.cmake.in
SET(LIBRARY_OUTPUT_PATH "@LIBRARY_OUTPUT_PATH@")
...

# CMakeLists.txt
CONFIGURE_FILE(
  ${CMAKE_CURRENT_SOURCE_DIR}/myscript.cmake.in
  ${CMAKE_CURRENT_BINARY_DIR}/myscript.cmake
  @ONLY IMMEDIATE
  )

What are you copying that needs LIBRARY_OUTPUT_PATH?  There may be
another way to accomplish your goal.

-Brad


More information about the CMake mailing list