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.

HTH

Michael


On 28. Aug, 2009, at 20:28, King, Steven R wrote:

Hello List,
I'm new to cmake and liking it a lot.  I'm using cmake 2.6.3 on Linux.

I'm building a dynamically loadable module and an executable to test it. Each lives in a different directory. My test program needs to know the location of the dll when calling dlopen(). To solve this, I created a custom command to copy the dll to the binary directory of the test program. This works, but I have an annoying dependency problem. Specifically, if the dll gets rebuilt, the copy command does not execute. The copy command only executes if the test program gets rebuilt. I do not understand how to make this copy depend on the dll being rebuilt. I want all test programs to "pull" the rebuilt dll as needed. I do not want the CMakeLists.txt for the dll to have any knowledge of the test programs.

In CMakeLists.txt for the test program:


add_executable            (
                         test_my_module
                         test_main.cpp
                         )

add_dependencies          (
                         test_my_module
                         my_module              # not needed?
                         )

# Loadable modules are never listed at link time.
target_link_libraries     (
                         test_my_module
                         dl
                         )

# Put the location of the .so library we need in the SO_LOCATION variable.
# We then use this location in the copy command below.
get_target_property       (
                         SO_LOCATION
                         my_module        # .so library target
                         LOCATION
                         )

# Create a custom build step to copy the dynamically loaded .so file
# into the this directory so our test executable can find it.
add_custom_command        (
                         TARGET test_my_module
                         POST_BUILD
                         DEPENDS my_module  # no effect?
COMMAND ${CMAKE_COMMAND} -E copy $ {SO_LOCATION} ${CMAKE_CURRENT_BINARY_DIR} COMMENT "CUSTOM COMMAND: Copy my_module to build directory"
                         )


What should I do make the copy happen if the dll is rebuilt?

Thanks for any advice,
-steve
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to