ENH: Split CMAKE_STANDARD_LIBRARIES into per-language variables CMAKE_<lang>_STANDARD_LIBRARIES. This is needed to get programmable language support working with Visual Studio generators. It makes sense anyway.
This commit is contained in:
parent
e380bad5f6
commit
08289893b8
|
@ -53,6 +53,12 @@ IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
|
|||
"Flags used by the compiler during Release with Debug Info builds.")
|
||||
ENDIF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
|
||||
|
||||
IF(CMAKE_C_STANDARD_LIBRARIES_INIT)
|
||||
SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES_INIT}"
|
||||
CACHE STRING "Libraries linked by defalut with all C applications.")
|
||||
MARK_AS_ADVANCED(CMAKE_C_STANDARD_LIBRARIES)
|
||||
ENDIF(CMAKE_C_STANDARD_LIBRARIES_INIT)
|
||||
|
||||
INCLUDE(CMakeCommonLanguageInclude)
|
||||
|
||||
# now define the following rule variables
|
||||
|
|
|
@ -104,6 +104,11 @@ IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
|
|||
|
||||
ENDIF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
|
||||
|
||||
IF(CMAKE_CXX_STANDARD_LIBRARIES_INIT)
|
||||
SET(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES_INIT}"
|
||||
CACHE STRING "Libraries linked by defalut with all C++ applications.")
|
||||
MARK_AS_ADVANCED(CMAKE_CXX_STANDARD_LIBRARIES)
|
||||
ENDIF(CMAKE_CXX_STANDARD_LIBRARIES_INIT)
|
||||
|
||||
INCLUDE(CMakeCommonLanguageInclude)
|
||||
|
||||
|
|
|
@ -129,6 +129,11 @@ IF(NOT CMAKE_Fortran_LINK_EXECUTABLE)
|
|||
"<CMAKE_Fortran_COMPILER> <CMAKE_Fortran_LINK_FLAGS> <LINK_FLAGS> <FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
ENDIF(NOT CMAKE_Fortran_LINK_EXECUTABLE)
|
||||
|
||||
IF(CMAKE_Fortran_STANDARD_LIBRARIES_INIT)
|
||||
SET(CMAKE_Fortran_STANDARD_LIBRARIES "${CMAKE_Fortran_STANDARD_LIBRARIES_INIT}"
|
||||
CACHE STRING "Libraries linked by defalut with all Fortran applications.")
|
||||
MARK_AS_ADVANCED(CMAKE_Fortran_STANDARD_LIBRARIES)
|
||||
ENDIF(CMAKE_Fortran_STANDARD_LIBRARIES_INIT)
|
||||
|
||||
IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
|
||||
SET (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG_INIT}" CACHE STRING
|
||||
|
|
|
@ -95,9 +95,5 @@ SET (CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_SHARED_LINKER_FLAGS_INIT})
|
|||
SET (CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT})
|
||||
SET (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT})
|
||||
|
||||
|
||||
SET (CMAKE_STANDARD_LIBRARIES "import32.lib" CACHE STRING
|
||||
"Libraries linked by defalut with all applications.")
|
||||
|
||||
MARK_AS_ADVANCED(CMAKE_STANDARD_LIBRARIES)
|
||||
|
||||
SET (CMAKE_C_STANDARD_LIBRARIES_INIT "import32.lib")
|
||||
SET (CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}")
|
||||
|
|
|
@ -211,8 +211,7 @@ IF(MSVC80)
|
|||
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG")
|
||||
SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG")
|
||||
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG")
|
||||
SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib " CACHE STRING
|
||||
"Libraries linked by defalut with all applications.")
|
||||
SET (CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib ")
|
||||
ELSE(MSVC80)
|
||||
IF(CMAKE_USING_VC_FREE_TOOLS)
|
||||
MESSAGE(STATUS "Using FREE VC TOOLS, NO DEBUG available")
|
||||
|
@ -227,10 +226,7 @@ ELSE(MSVC80)
|
|||
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1")
|
||||
SET (CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2")
|
||||
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1")
|
||||
SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib advapi32.lib rpcrt4.lib" CACHE STRING
|
||||
"Libraries linked by defalut with all applications.")
|
||||
SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib advapi32.lib rpcrt4.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib" CACHE STRING
|
||||
"Libraries linked by defalut with all applications.")
|
||||
SET (CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib advapi32.lib rpcrt4.lib")
|
||||
ELSE(CMAKE_USING_VC_FREE_TOOLS)
|
||||
SET(CMAKE_BUILD_TYPE_INIT Debug)
|
||||
SET (CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /GX /GR")
|
||||
|
@ -243,15 +239,11 @@ ELSE(MSVC80)
|
|||
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG")
|
||||
SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG")
|
||||
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG")
|
||||
SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" CACHE STRING
|
||||
"Libraries linked by defalut with all applications.")
|
||||
SET (CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib")
|
||||
ENDIF(CMAKE_USING_VC_FREE_TOOLS)
|
||||
ENDIF(MSVC80)
|
||||
|
||||
|
||||
MARK_AS_ADVANCED(CMAKE_STANDARD_LIBRARIES)
|
||||
|
||||
|
||||
SET(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}")
|
||||
|
||||
# executable linker flags
|
||||
SET (CMAKE_LINK_DEF_FILE_FLAG "/DEF:")
|
||||
|
|
|
@ -60,9 +60,8 @@ SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2")
|
|||
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2")
|
||||
|
||||
|
||||
SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib" CACHE STRING
|
||||
"Libraries linked by defalut with all applications.")
|
||||
MARK_AS_ADVANCED(CMAKE_STANDARD_LIBRARIES)
|
||||
SET(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib")
|
||||
SET(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}")
|
||||
|
||||
# executable linker flags
|
||||
SET (CMAKE_LINK_DEF_FILE_FLAG "/DEF:")
|
||||
|
|
|
@ -43,13 +43,8 @@ SET (CMAKE_Fortran_FLAGS_DEBUG_INIT "/debug:full")
|
|||
SET (CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "/O2 /D NDEBUG")
|
||||
SET (CMAKE_Fortran_FLAGS_RELEASE_INIT "/MD /O1 /D NDEBUG")
|
||||
SET (CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "/O1 /debug:full /D NDEBUG")
|
||||
SET (CMAKE_STANDARD_LIBRARIES "user32.lib" CACHE STRING
|
||||
"Libraries linked by defalut with all applications.")
|
||||
|
||||
|
||||
MARK_AS_ADVANCED(CMAKE_STANDARD_LIBRARIES)
|
||||
|
||||
|
||||
SET (CMAKE_Fortran_STANDARD_LIBRARIES_INIT "user32.lib")
|
||||
|
||||
# executable linker flags
|
||||
SET (CMAKE_LINK_DEF_FILE_FLAG "/DEF:")
|
||||
|
|
|
@ -22,8 +22,8 @@ SET (CMAKE_C_FLAGS_DEBUG_INIT "-br -bm -od")
|
|||
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-br -bm -os -dNDEBUG")
|
||||
SET (CMAKE_C_FLAGS_RELEASE_INIT "-br -bm -ot -dNDEBUG")
|
||||
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-br -bm -ot -dNDEBUG")
|
||||
SET (CMAKE_STANDARD_LIBRARIES "library clbrdll.lib library plbrdll.lib library kernel32.lib library user32.lib library gdi32.lib library winspool.lib library comdlg32.lib library advapi32.lib library shell32.lib library ole32.lib library oleaut32.lib library uuid.lib library odbc32.lib library odbccp32.lib" CACHE STRING
|
||||
"Libraries linked by defalut with all applications.")
|
||||
SET (CMAKE_C_STANDARD_LIBRARIES_INIT "library clbrdll.lib library plbrdll.lib library kernel32.lib library user32.lib library gdi32.lib library winspool.lib library comdlg32.lib library advapi32.lib library shell32.lib library ole32.lib library oleaut32.lib library uuid.lib library odbc32.lib library odbccp32.lib")
|
||||
SET (CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}")
|
||||
|
||||
SET(CMAKE_C_LINK_EXECUTABLE
|
||||
"wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
|
||||
|
|
|
@ -1349,9 +1349,15 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
|
|||
}
|
||||
fout << " ";
|
||||
}
|
||||
if(this->Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES"))
|
||||
|
||||
// Add standard libraries for this language.
|
||||
std::string standardLibsVar = "CMAKE_";
|
||||
standardLibsVar += linkLanguage;
|
||||
standardLibsVar += "_STANDARD_LIBRARIES";
|
||||
if(const char* stdLibs =
|
||||
this->Makefile->GetDefinition(standardLibsVar.c_str()))
|
||||
{
|
||||
fout << this->Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES") << " ";
|
||||
fout << stdLibs << " ";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1059,7 +1059,27 @@ void cmLocalVisualStudio6Generator
|
|||
libMultiLineOptionsForDebug += extraLinkOptions;
|
||||
libMultiLineOptionsForDebug += " \n";
|
||||
}
|
||||
if(const char* stdLibs = this->Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES"))
|
||||
if(target.GetType() >= cmTarget::EXECUTABLE &&
|
||||
target.GetType() <= cmTarget::MODULE_LIBRARY)
|
||||
{
|
||||
// Get the language to use for linking.
|
||||
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
|
||||
if(!linkLanguage)
|
||||
{
|
||||
cmSystemTools::Error("CMake can not determine linker language for target:",
|
||||
target.GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute the variable name to lookup standard libraries for this
|
||||
// language.
|
||||
std::string standardLibsVar = "CMAKE_";
|
||||
standardLibsVar += linkLanguage;
|
||||
standardLibsVar += "_STANDARD_LIBRARIES";
|
||||
|
||||
// Add standard libraries.
|
||||
if(const char* stdLibs =
|
||||
this->Makefile->GetDefinition(standardLibsVar.c_str()))
|
||||
{
|
||||
libOptions += " ";
|
||||
libOptions += stdLibs;
|
||||
|
@ -1071,6 +1091,7 @@ void cmLocalVisualStudio6Generator
|
|||
libMultiLineOptionsForDebug += stdLibs;
|
||||
libMultiLineOptionsForDebug += " \n";
|
||||
}
|
||||
}
|
||||
if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"))
|
||||
{
|
||||
libOptions += " ";
|
||||
|
|
|
@ -667,6 +667,21 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
std::vector<cmStdString> linkDirs;
|
||||
this->ComputeLinkInformation(target, configName, linkLibs, linkDirs);
|
||||
|
||||
// Get the language to use for linking.
|
||||
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
|
||||
if(!linkLanguage)
|
||||
{
|
||||
cmSystemTools::Error("CMake can not determine linker language for target:",
|
||||
target.GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute the variable name to lookup standard libraries for this
|
||||
// language.
|
||||
std::string standardLibsVar = "CMAKE_";
|
||||
standardLibsVar += linkLanguage;
|
||||
standardLibsVar += "_STANDARD_LIBRARIES";
|
||||
|
||||
fout << "\t\t\t<Tool\n"
|
||||
<< "\t\t\t\tName=\"VCLinkerTool\"\n"
|
||||
<< "\t\t\t\tAdditionalOptions=\"/MACHINE:I386";
|
||||
|
@ -679,7 +694,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
// libraries which may be set by the user to something bad.
|
||||
fout << "\"\n"
|
||||
<< "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
|
||||
<< this->Makefile->GetRequiredDefinition("CMAKE_STANDARD_LIBRARIES")
|
||||
<< this->Makefile->GetSafeDefinition(standardLibsVar.c_str())
|
||||
<< " ";
|
||||
this->OutputLibraries(fout, linkLibs);
|
||||
fout << "\"\n";
|
||||
|
@ -709,13 +724,6 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
{
|
||||
fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
|
||||
}
|
||||
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
|
||||
if(!linkLanguage)
|
||||
{
|
||||
cmSystemTools::Error("CMake can not determine linker language for target:",
|
||||
target.GetName());
|
||||
return;
|
||||
}
|
||||
std::string stackVar = "CMAKE_";
|
||||
stackVar += linkLanguage;
|
||||
stackVar += "_STACK_SIZE";
|
||||
|
@ -739,6 +747,21 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
std::vector<cmStdString> linkDirs;
|
||||
this->ComputeLinkInformation(target, configName, linkLibs, linkDirs);
|
||||
|
||||
// Get the language to use for linking.
|
||||
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
|
||||
if(!linkLanguage)
|
||||
{
|
||||
cmSystemTools::Error("CMake can not determine linker language for target:",
|
||||
target.GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute the variable name to lookup standard libraries for this
|
||||
// language.
|
||||
std::string standardLibsVar = "CMAKE_";
|
||||
standardLibsVar += linkLanguage;
|
||||
standardLibsVar += "_STANDARD_LIBRARIES";
|
||||
|
||||
fout << "\t\t\t<Tool\n"
|
||||
<< "\t\t\t\tName=\"VCLinkerTool\"\n"
|
||||
<< "\t\t\t\tAdditionalOptions=\"/MACHINE:I386";
|
||||
|
@ -751,7 +774,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
// libraries which may be set by the user to something bad.
|
||||
fout << "\"\n"
|
||||
<< "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
|
||||
<< this->Makefile->GetRequiredDefinition("CMAKE_STANDARD_LIBRARIES")
|
||||
<< this->Makefile->GetSafeDefinition(standardLibsVar.c_str())
|
||||
<< " ";
|
||||
this->OutputLibraries(fout, linkLibs);
|
||||
fout << "\"\n";
|
||||
|
@ -783,13 +806,6 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
{
|
||||
fout << "\t\t\t\tSubSystem=\"1\"\n";
|
||||
}
|
||||
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
|
||||
if(!linkLanguage)
|
||||
{
|
||||
cmSystemTools::Error("CMake can not determine linker language for target:",
|
||||
target.GetName());
|
||||
return;
|
||||
}
|
||||
std::string stackVar = "CMAKE_";
|
||||
stackVar += linkLanguage;
|
||||
stackVar += "_STACK_SIZE";
|
||||
|
|
Loading…
Reference in New Issue