[CMake] Interface Libraries allow include directories but not link directories.. Why?

Robert Maynard robert.maynard at kitware.com
Tue Aug 22 09:01:16 EDT 2017


Usage of link_directories is discouraged, and was part of the reason
why a target based option was not added. As the documentation for
link_directories states "Note that this command is rarely necessary.
Library locations returned by find_package() and find_library() are
absolute paths. Pass these absolute library file paths directly to the
target_link_libraries() command. CMake will ensure the linker finds
them."

On Mon, Aug 21, 2017 at 8:17 PM, Brian Davis <bitminer at gmail.com> wrote:
> Why does:
>
> Interface Libraries
> https://cmake.org/cmake/help/latest/command/add_library.html?highlight=add_library#id3
>
> allow include directories via
>
> target_include_directories(INTERFACE)
>
> but not link_directories
>
> https://cmake.org/cmake/help/latest/prop_dir/LINK_DIRECTORIES.html?highlight=link_directories
>
> which if we look at property scope:
>
> https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html
>
> Why is include_directories at target resolution while link_directories is at
> directory resolution.
>
> link_directories is a property on a directory which if I recalled correctly
> I complained about many many moons ago (circa 2009) when I first realized
> this.  I did not understand this logic then and don't understand this logic
> now.  Someone what to give me the recipe for the CMake cool-aid so I can mix
> that up, drink it down, and re-read the doc and finally come to terms with
> this.  Or could the powers that be redesign CMake to make sense.  At the
> time I wrapped this nonsense in a macro and pretended it did not happen ...
> now I am rewriting my project for "new" CMake and still don't get this.
>
>
>
>
> --
>
> 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


More information about the CMake mailing list