[CMake] Get linker flags / include directories for a library target
Bo Zhou
bo.schwarzstein at gmail.com
Mon Dec 24 21:04:13 EST 2018
All the flags/options in the CMake they could be considered as a list.
So it's much more easier to handle it as this
set(WIN_DEFINITIONS -DNOMINMAX)
Remember the list is the object, so we could construct the new list for the
specific target.
Then to the specific target, just use the 3 commands.
target_compile_options()
target_include_directories()
target_link_libraries()
We use this method to organize the cross-platform with library and
executable without any problem, and super easy to control and manage.
Thanks.
On Fri, Dec 21, 2018 at 7:19 AM Unknown <ax487 at gmx.de> wrote:
> Dear community,
>
> I have been wondering on multiple occasions about how to get the
> linker flags (i.e. all -llib -Ldir) and include flags (-Idir)
> for a library (i.e. a target added to the project using
> add_library) within a cmake.
>
> There are many cases in which the flags are required, noticeably
> generating a suitable pkg-config file or creating a wrappers around
> C/C++ libraries.
>
> I think that it should be possible to derive the flags from
> some of the target properties of the library, but I don't
> know exactly how.
>
> Could you give me a hand?
>
> ax487
>
> --
>
> 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:
> https://cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181225/7b1b5cf7/attachment.html>
More information about the CMake
mailing list