On 11/28/2010 3:19 AM, Sebastian Schaetz wrote:
Michael Hertling<mhertl...@...>  writes:

1) In the top-level CMakeLists.txt, you might say

SET_SOURCE_FILES_PROPERTIES(
     main.cpp PROPERTIES OBJECT_DEPENDS
     ${CMAKE_CURRENT_BINARY_DIR}/kernels/libkernel_executable.a
)

When libkernel_executable.a has changed, this results in recompiling
main.cpp - a penalty - and the desired relinking of main_target. If
main.cpp's recompilation is expensive you may possibly add an empty
cpp file to main_target's sources and impose the property on that.


Wow, those suggestions all sound great and I'm completely unfamiliar with them
(so I think there's a good chance they will work). I will try them as soon as
possible! Thanks a lot for the suggestions.


No need for all the complication...

If you already know where the library is going to be:

 ${CMAKE_CURRENT_BINARY_DIR}/kernels/libkernel_executable.a

Then link directly to the full path:

target_link_libraries(main_target
 ${CMAKE_CURRENT_BINARY_DIR}/kernels/libkernel_executable.a)

Now the makefiles will depend on that file and it will relink when that .a changes. This is why link_directories/*link_libraries without a full path to the library is almost always a bad idea...

-Bill


_______________________________________________
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