diff options
author | Brad King <brad.king@kitware.com> | 2006-04-11 20:55:49 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-04-11 20:55:49 (GMT) |
commit | 08289893b8590be41d0541af7644e737035aee54 (patch) | |
tree | 8ad52af77e4837c0f7fd936b6c52ca083f66c0c0 | |
parent | e380bad5f6fbe37048e3f06e125e2938da9ffc68 (diff) | |
download | CMake-08289893b8590be41d0541af7644e737035aee54.zip CMake-08289893b8590be41d0541af7644e737035aee54.tar.gz CMake-08289893b8590be41d0541af7644e737035aee54.tar.bz2 |
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.
-rw-r--r-- | Modules/CMakeCInformation.cmake | 6 | ||||
-rw-r--r-- | Modules/CMakeCXXInformation.cmake | 5 | ||||
-rw-r--r-- | Modules/CMakeFortranInformation.cmake | 5 | ||||
-rw-r--r-- | Modules/Platform/Windows-bcc32.cmake | 8 | ||||
-rw-r--r-- | Modules/Platform/Windows-cl.cmake | 16 | ||||
-rw-r--r-- | Modules/Platform/Windows-icl.cmake | 5 | ||||
-rw-r--r-- | Modules/Platform/Windows-ifort.cmake | 7 | ||||
-rw-r--r-- | Modules/Platform/Windows-wcl386.cmake | 4 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 10 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 41 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 48 |
11 files changed, 98 insertions, 57 deletions
diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index 242d796..230d49e 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -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 diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 6e16e4a..8d05933 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -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) diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index 9dd0649..80a8e7a 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -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 diff --git a/Modules/Platform/Windows-bcc32.cmake b/Modules/Platform/Windows-bcc32.cmake index 2f334e0..3bc4f01 100644 --- a/Modules/Platform/Windows-bcc32.cmake +++ b/Modules/Platform/Windows-bcc32.cmake @@ -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}") diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake index fceb68a..1021f78 100644 --- a/Modules/Platform/Windows-cl.cmake +++ b/Modules/Platform/Windows-cl.cmake @@ -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:") diff --git a/Modules/Platform/Windows-icl.cmake b/Modules/Platform/Windows-icl.cmake index bad8949..d09eb1c 100644 --- a/Modules/Platform/Windows-icl.cmake +++ b/Modules/Platform/Windows-icl.cmake @@ -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:") diff --git a/Modules/Platform/Windows-ifort.cmake b/Modules/Platform/Windows-ifort.cmake index a152864..1b3459d 100644 --- a/Modules/Platform/Windows-ifort.cmake +++ b/Modules/Platform/Windows-ifort.cmake @@ -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:") diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index afc32dd..89c2697 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -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}") diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6952338..e802066 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -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 << " "; } } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index b6fd4f8..6fa2a9a 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1059,17 +1059,38 @@ 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) { - libOptions += " "; - libOptions += stdLibs; - libOptions += " "; - libMultiLineOptions += "# ADD LINK32 "; - libMultiLineOptions += stdLibs; - libMultiLineOptions += " \n"; - libMultiLineOptionsForDebug += "# ADD LINK32 "; - libMultiLineOptionsForDebug += stdLibs; - libMultiLineOptionsForDebug += " \n"; + // 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; + libOptions += " "; + libMultiLineOptions += "# ADD LINK32 "; + libMultiLineOptions += stdLibs; + libMultiLineOptions += " \n"; + libMultiLineOptionsForDebug += "# ADD LINK32 "; + libMultiLineOptionsForDebug += stdLibs; + libMultiLineOptionsForDebug += " \n"; + } } if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS")) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index c619660..dd47fa2 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -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"; |