[CMake] dependency in custom command?

Clinton Stimpson clinton at elemtech.com
Mon Aug 31 10:59:22 EDT 2009


On 08/30/2009 11:08 PM, King, Steven R wrote:
>> 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}
>>      
> Thanks Clint and Tyler and others for your patient help.  The consolidated binary directory didn't work.
>
> I now put all my binaries and libraries in ${CMAKE_BINARY_DIR}/bin as Clint suggested.  This caused ctest to fail for lack of knowing where the test binary went.  I made this adjustment:
>
> add_test    (
>              test_my_module
>              ${CMAKE_BINARY_DIR}/bin/test_my_module
>              )
>
> which allowed ctest to find the executable.  However, the executable still can't find the dll, since ctest runs the test from ${CMAKE_CURRENT_BINARY_DIR} which is apparently not equal to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}.  As we've just belabored, putting the dll in ${CMAKE_CURRENT_BINARY_DIR} is neither easy nor well advised.
>
> OK, now I'm actually getting worried.  Any other ideas, please?
>    

How about this:

add_test (test_my_module test_my_module ${CMAKE_BINARY_DIR}/bin)

Then in your main(int, char*[]), you can use argv[1] as the path to load 
the shared/dynamic library from.

Clint



More information about the CMake mailing list