The following issue has been SUBMITTED. ====================================================================== http://cmake.org/Bug/view.php?id=14099 ====================================================================== Reported By: Andrey Kamaev Assigned To: ====================================================================== Project: CMake Issue ID: 14099 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2013-04-19 15:05 MSD Last Modified: 2013-04-19 15:05 MSD ====================================================================== Summary: Ninja: CMAKE_${LANG}_FLAGS passed to linker come from incorrect scope Description: Library/module linker is always called with same compiler flags. CMake embeds CMAKE_${LANG}_FLAGS from the scope of the first library met by generator into the generic link rule and uses it for all targets of the same type. But CMAKE_${LANG}_FLAGS variables are directory scoped and should be different.
Looking into the CMake code I found that any platform having <LANGUAGE_COMPILE_FLAGS> in link command is affected. Steps to Reproduce: The minimal reproducer is attached. In short: CMakeLists.txt from the topmost directory: cmake_minimum_required(VERSION 2.8.8) project(level0) set(CMAKE_CXX_FLAGS -msse2 ) # flag itself does not matter add_library(lelve0 SHARED level0.cpp) add_subdirectory(l1) CMakeLists.txt from sub-directory: project(level1) set(CMAKE_CXX_FLAGS -mno-sse2 ) add_library(lelve1 SHARED level1.cpp) Resulting link commands from Ninja: /usr/bin/c++ -fPIC -msse2 -shared -Wl,-soname,liblelve0.so -o liblelve0.so CMakeFiles/lelve0.dir/level0.cpp.o /usr/bin/c++ -fPIC -msse2 -shared -Wl,-soname,liblelve1.so -o l1/liblelve1.so l1/CMakeFiles/lelve1.dir/level1.cpp.o Link commands used by make: /usr/bin/c++ -fPIC -msse2 -shared -Wl,-soname,liblelve0.so -o liblelve0.so CMakeFiles/lelve0.dir/level0.cpp.o /usr/bin/c++ -fPIC -mno-sse2 -shared -Wl,-soname,liblelve1.so -o liblelve1.so CMakeFiles/lelve1.dir/level1.cpp.o ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2013-04-19 15:05 Andrey Kamaev New Issue 2013-04-19 15:05 Andrey Kamaev File Added: repro.tar.bz2 ====================================================================== -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
