> Wrap your custom_command with a custom_target. See the CMake FAQ for
> some recipes.


OK, my CMakeLists.txt is growing rapidly.  :^(
All I've managed to do is cause the module to be copied every time.
Again, my goal is to copy the dll to the directory of the corresponding test 
program
if the dll has been rebuilt.

Any pointers are very much appreciated.  There must be some newb problems here.
My new approach with the add_custom_target:


add_dependencies          (
                          test_my_module
                          my_module
                          test_my_module_copy
                          )

target_link_libraries     (
                          test_my_module
                          dl
                          )

get_target_property       (
                          SO_LOCATION
                          my_module        # .so library target
                          LOCATION
                          )

get_target_property       (
                          SO_NAME
                          my_module        # .so library target
                          OUTPUT_NAME
                          )
                          
# 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        (
                          OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SO_NAME}
                          COMMAND ${CMAKE_COMMAND} -E copy ${SO_LOCATION} 
${CMAKE_CURRENT_BINARY_DIR}
                          DEPENDS my_module
                          COMMENT "CUSTOM COMMAND: Copy ${SO_NAME} to build 
directory"
                          )

add_custom_target         (
                          test_my_module_copy
                          DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${SO_NAME}
                          DEPENDS my_module
                          )

_______________________________________________
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