Why, then, don't you simply list the libraries in the correct order in the target_link_libraries command? The add_dependencies command only has an effect on targets, not external libraries. If indeed, they are targets (which doesn't become clear from your code) you should do:

target_link_libraries( dlib_httpclient dlib )

target_link_libraries( ${PROJECT_NAME} dlib_httpclient )


Although, the libraries are static, CMake the remembers that dlib_httpclient depends on dlib and in the last link-command you only have to specify the dlib_httpclient library and CMake will do the rest for you.

HTH

Michael

On 25. Feb, 2009, at 15:22, Steven Van Ingelgem wrote:

Yes, it has to do something with it...
Because at least when linking under Linux, if I added dlib BEFORE
dlib_httpclient (as is now the case), dlib_httpclient will complain about
undefined symbols.

That's where the add_dependencies would come into play in my honest opinion. CMake should calculate the order in which to place the libraries to link with to honour all the calls made in the project. So in my case, place dlib
behind dlib_httpclient.

What you are refering to is not a dependency in linkage, but a dependency in
compilation. This is fine of course, but is not enough when compiling
libraries.


Greetings,
Steven


2009/2/25 Michael Wild <[email protected]>

I think you misunderstand add_dependencies. The command adds a dependency of dlib_httpclient on dlib, i.e. dlib_httplclient DEPENDS ON dlib. It has nothing to do with the order the libraries appear on the command line when
you link ${PROJECT_NAME}.

HTH

Michael


On 25. Feb, 2009, at 14:15, Steven Van Ingelgem wrote:

I have:
add_dependencies(dlib_httpclient dlib)

But in my cmakelists I have:
TARGET_LINK_LIBRARIES(${PROJECT_NAME} dlib dlib_httpclient)

Conclusion: it will change itself to "bin/libdlib.a
bin/libdlib_httpclient.a"
instead I would expect "bin/libdlib_httpclient.a bin/libdlib.a" as I told
it
to add the dependency.


Greetings,
Steven
_______________________________________________
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