[Cmake-commits] [cmake-commits] king committed cmDocumentVariables.cxx 1.38 1.39 cmTarget.cxx 1.265 1.266
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Jul 30 10:59:39 EDT 2009
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv5900/Source
Modified Files:
cmDocumentVariables.cxx cmTarget.cxx
Log Message:
Do not always propagate linker language preference
The commit "Consider link dependencies for link language" taught CMake
to propagate linker language preference from languages compiled into
libraries linked by a target. It turns out this should only be done for
some languages, such as C++, because normally the language of the
program entry point (main) should be used.
We introduce variable CMAKE_<LANG>_LINKER_PREFERENCE_PROPAGATES to tell
CMake whether a language should propagate its linker preference across
targets. Currently it is true only for C++.
Index: cmDocumentVariables.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentVariables.cxx,v
retrieving revision 1.38
retrieving revision 1.39
diff -C 2 -d -r1.38 -r1.39
*** cmDocumentVariables.cxx 23 Jul 2009 14:07:24 -0000 1.38
--- cmDocumentVariables.cxx 30 Jul 2009 14:59:37 -0000 1.39
***************
*** 1203,1211 ****
cm->DefineProperty
("CMAKE_<LANG>_LINKER_PREFERENCE", cmProperty::VARIABLE,
! "Determine if a language should be used for linking.",
! "If this is \"Preferred\" then if there is a mixed "
! "language shared library or executable, then this "
! "languages linker command will be used.",false,
"Variables for Languages");
--- 1203,1224 ----
cm->DefineProperty
+ ("CMAKE_<LANG>_LINKER_PREFERENCE_PROPAGATES", cmProperty::VARIABLE,
+ "True if CMAKE_<LANG>_LINKER_PREFERENCE propagates across targets.",
+ "This is used when CMake selects a linker language for a target. "
+ "Languages compiled directly into the target are always considered. "
+ "A language compiled into static libraries linked by the target is "
+ "considered if this variable is true.", false,
+ "Variables for Languages");
+
+ cm->DefineProperty
("CMAKE_<LANG>_LINKER_PREFERENCE", cmProperty::VARIABLE,
! "Preference value for linker language selection.",
! "The \"linker language\" for executable, shared library, and module "
! "targets is the language whose compiler will invoke the linker. "
! "The LINKER_LANGUAGE target property sets the language explicitly. "
! "Otherwise, the linker language is that whose linker preference value "
! "is highest among languages compiled and linked into the target. "
! "See also the CMAKE_<LANG>_LINKER_PREFERENCE_PROPAGATES variable.",
! false,
"Variables for Languages");
Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.265
retrieving revision 1.266
diff -C 2 -d -r1.265 -r1.266
*** cmTarget.cxx 30 Jul 2009 14:59:25 -0000 1.265
--- cmTarget.cxx 30 Jul 2009 14:59:37 -0000 1.266
***************
*** 442,457 ****
cm->DefineProperty
("LINKER_LANGUAGE", cmProperty::TARGET,
! "Specifies language whose link tool should be used (obselete).",
"For executables, shared libraries, and modules, this sets the "
! "language whose link tool is used to link the target "
"(such as \"C\" or \"CXX\"). "
! "CMake 2.6 and below select a linker language automatically "
! "based on the languages compiled into the target. "
! "This property overrides the default in case one of the "
! "linked libraries uses another language. "
! "A typical example is a C executable linking to a static archive "
! "containing C++ object files. "
! "CMake 2.8 and above account for languages in linked targets "
! "automatically, making this property unnecessary.");
cm->DefineProperty
--- 442,454 ----
cm->DefineProperty
("LINKER_LANGUAGE", cmProperty::TARGET,
! "Specifies language whose compiler will invoke the linker.",
"For executables, shared libraries, and modules, this sets the "
! "language whose compiler is used to link the target "
"(such as \"C\" or \"CXX\"). "
! "A typical value for an executable is the language of the source "
! "file providing the program entry point (main). "
! "If not set, the language with the highest linker preference "
! "value is the default. "
! "See documentation of CMAKE_<LANG>_LINKER_PREFERENCE variables.");
cm->DefineProperty
***************
*** 2507,2515 ****
// Find the language with the highest preference value.
cmTargetSelectLinker tsl(this);
for(std::set<cmStdString>::const_iterator sit = languages.begin();
sit != languages.end(); ++sit)
{
! tsl.Consider(sit->c_str());
}
lc.LinkerLanguage = tsl.Choose();
}
--- 2504,2526 ----
// Find the language with the highest preference value.
cmTargetSelectLinker tsl(this);
+
+ // First select from the languages compiled directly in this target.
+ for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
+ li != impl->Languages.end(); ++li)
+ {
+ tsl.Consider(li->c_str());
+ }
+
+ // Now consider languages that propagate from linked targets.
for(std::set<cmStdString>::const_iterator sit = languages.begin();
sit != languages.end(); ++sit)
{
! std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES";
! if(this->Makefile->IsOn(propagates.c_str()))
! {
! tsl.Consider(sit->c_str());
! }
}
+
lc.LinkerLanguage = tsl.Choose();
}
More information about the Cmake-commits
mailing list