[CMake] dependency in custom command?

clinton at elemtech.com clinton at elemtech.com
Fri Aug 28 22:32:01 EDT 2009


>> You don't have to do the copying yourself. Just tell CMake in which
>> directory it should create the module by either setting the
>> LIBRARY_OUTPUT_DIRECTORY target property or the
>> CMAKE_LIBRARY_OUTPUT_DIRECTORY variable.
>> 
>> AFAIK the LOCATION property is only present for compatibility with
>> CMake 2.4, and shouldn't be used in new code.

> Hi Mike -- I don't know from which directory my module test will run when 
> using ctest.  So, my test program does not have an easy way to know the 
> relative path to LIBRARY_OUTPUT_DIRECTORY when making the dlopen() call.
> Allowing my test program to assume the dll is in its local directory 
> seemed to be the easiest solution.

Can't you put all executables and shared libraries in one directory, so they are all local to each other?
In the top level CMakeLists.txt file just add
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

The executables you specify in ADD_TEST() will have a working directory that is ${CMAKE_CURRENT_BINARY_DIR}

Clint


More information about the CMake mailing list