[CMake] CFLAGS disables link directories?

Alexander Shashkevych alex at stunpix.com
Thu Aug 28 12:21:27 EDT 2014


Hi all,

I did't found info how cmake internally handles CFLAGS environment
variable, but I know that cmake picks it up from environment and seems this
removes link directories from linking flags added by link_directories()
command.

For example. I'm using custom sysroot, to build my app and I run cmake with
following command:

   export CFLAGS="--sysroot=/sysroot/"
   cmake ..

My cmake file is:

   # GStreamer_LIBRARY_DIRS is set by pkg_check_modules()
   link_directories(${GStreamer_LIBRARY_DIRS})

   get_directory_property(LINK_DIRS LINK_DIRECTORIES)
   message("LINK_DIRS: ${LINK_DIRS}")

   add_executable(myapp main.c)
   target_link_libraries(myapp ${GStreamer_LIBRARIES})

When CFLAGS isn't specified, then file src/CMakeFiles/myapp.dir/link.txt
contains -L/sysroot/usr/lib and -Wl,-rpath,/sysroot/usr/lib flags as
expected, but when I add CFLAGS to environment, then -L and -Wl,-rpath are
disappearing from linker options.

Could someone to confirm, is this expected behavior?

PS: Regardless of CFLAGS specified in command line or not, message() always
prints: LINK_DIRS: /sysroot/usr/lib, so internally cmake sets this property.

Thanks!

Alexander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140828/92c1d064/attachment.html>


More information about the CMake mailing list