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
-- 

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