View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014099CMakeCMakepublic2013-04-19 07:052014-10-06 10:33
ReporterAndrey Kamaev 
Assigned ToPeter Kuemmel 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformLinuxOSOS Version
Product VersionCMake 2.8.10.2 
Target VersionFixed in VersionCMake 3.0 
Summary0014099: Ninja: CMAKE_${LANG}_FLAGS passed to linker come from incorrect scope
DescriptionLibrary/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 ReproduceThe 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
TagsNo tags attached.
Attached Filesbz2 file icon repro.tar.bz2 [^] (469 bytes) 2013-04-19 07:05

 Relationships

  Notes
(0035684)
Peter Kuemmel (developer)
2014-04-13 08:50

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=77b7f1be4074843abf5156c9ff6aed5b91456afb [^]

BTW, there is also the CMAKE_SHARED_LINKER_FLAGS variable.
(0036969)
Robert Maynard (manager)
2014-10-06 10:33

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2013-04-19 07:05 Andrey Kamaev New Issue
2013-04-19 07:05 Andrey Kamaev File Added: repro.tar.bz2
2014-04-13 05:00 Peter Kuemmel Severity minor => major
2014-04-13 08:49 Peter Kuemmel Assigned To => Peter Kuemmel
2014-04-13 08:49 Peter Kuemmel Status new => assigned
2014-04-13 08:50 Peter Kuemmel Note Added: 0035684
2014-04-13 08:50 Peter Kuemmel Status assigned => resolved
2014-04-13 08:50 Peter Kuemmel Fixed in Version => CMake 3.0
2014-04-13 08:50 Peter Kuemmel Resolution open => fixed
2014-10-06 10:33 Robert Maynard Note Added: 0036969
2014-10-06 10:33 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team