When I define my targets (custom, library, executable), does the order
of their declaration matter when it comes to using those targets in
dependencies? It's difficult to explain, so I'll show an example:


add_executable(foo main1.cpp)
target_link_libraries(foo abc)

add_library(abc main2.cpp)

In the example above, the add_library() happens after
target_link_libraries() for the executable. I've seen this work, but I
was using static libraries. Would this work for shared libraries too?
Does CMake do a multi-pass parse so that all targets are known prior
to them being referenced?

The target_link_libraries() [1] documentation states:

"The named target must be created by add_library() within the project
or as an IMPORTED library. If it is created within the project an
ordering dependency will automatically be added in the build system to
make sure the named library target is up-to-date before the <target>
links."

I'm not sure what "up-to-date" here means, or if this specific
documentation is talking about compile-time dependencies or cmake
dependencies.

[1]: https://cmake.org/cmake/help/latest/command/target_link_libraries.html
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to