소스 검색

Merge topic 'msvc_implib'

7bda9a7fc7 VS: Make ImportLibary generation optional

Acked-by: Kitware Robot <[email protected]>
Merge-request: !5282
Brad King 5 년 전
부모
커밋
b1e1cb2d0d

+ 7 - 5
Source/cmLocalVisualStudio7Generator.cxx

@@ -1081,11 +1081,13 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
       if (stackVal) {
       if (stackVal) {
         fout << "\t\t\t\tStackReserveSize=\"" << *stackVal << "\"\n";
         fout << "\t\t\t\tStackReserveSize=\"" << *stackVal << "\"\n";
       }
       }
-      temp = cmStrCat(
-        target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact),
-        '/', targetNames.ImportLibrary);
-      fout << "\t\t\t\tImportLibrary=\""
-           << this->ConvertToXMLOutputPathSingle(temp) << "\"";
+      if (!targetNames.ImportLibrary.empty()) {
+        temp = cmStrCat(target->GetDirectory(
+                          configName, cmStateEnums::ImportLibraryArtifact),
+                        '/', targetNames.ImportLibrary);
+        fout << "\t\t\t\tImportLibrary=\""
+             << this->ConvertToXMLOutputPathSingle(temp) << "\"";
+      }
       if (this->FortranProject) {
       if (this->FortranProject) {
         fout << "\n\t\t\t\tLinkDLL=\"true\"";
         fout << "\n\t\t\t\tLinkDLL=\"true\"";
       }
       }

+ 7 - 5
Source/cmVisualStudio10TargetGenerator.cxx

@@ -3791,12 +3791,14 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
 
 
     std::string pdb = cmStrCat(this->GeneratorTarget->GetPDBDirectory(config),
     std::string pdb = cmStrCat(this->GeneratorTarget->GetPDBDirectory(config),
                                '/', targetNames.PDB);
                                '/', targetNames.PDB);
-    std::string imLib =
-      cmStrCat(this->GeneratorTarget->GetDirectory(
-                 config, cmStateEnums::ImportLibraryArtifact),
-               '/', targetNames.ImportLibrary);
+    if (!targetNames.ImportLibrary.empty()) {
+      std::string imLib =
+        cmStrCat(this->GeneratorTarget->GetDirectory(
+                   config, cmStateEnums::ImportLibraryArtifact),
+                 '/', targetNames.ImportLibrary);
 
 
-    linkOptions.AddFlag("ImportLibrary", imLib);
+      linkOptions.AddFlag("ImportLibrary", imLib);
+    }
     linkOptions.AddFlag("ProgramDataBaseFile", pdb);
     linkOptions.AddFlag("ProgramDataBaseFile", pdb);
 
 
     // A Windows Runtime component uses internal .NET metadata,
     // A Windows Runtime component uses internal .NET metadata,

+ 23 - 0
Tests/RunCMake/VS10Project/NoImpLib-check.cmake

@@ -0,0 +1,23 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+  set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+  return()
+endif()
+
+set(found_ImportLibrary 0)
+set(found_TargetExt_dll 0)
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+  if(line MATCHES "<ImportLibrary>")
+    set(found_ImportLibrary 1)
+  endif()
+  if(line MATCHES "<TargetExt[^\n]*\\.dll")
+    set(found_TargetExt_dll 1)
+  endif()
+endforeach()
+if(found_ImportLibrary)
+  string(APPEND RunCMake_TEST_FAILED "ImportLibrary incorrectly found in\n  ${vcProjectFile}\n")
+endif()
+if(NOT found_TargetExt_dll)
+  string(APPEND RunCMake_TEST_FAILED "TargetExt not found in\n  ${vcProjectFile}\n")
+endif()

+ 3 - 0
Tests/RunCMake/VS10Project/NoImpLib.cmake

@@ -0,0 +1,3 @@
+enable_language(C)
+set(CMAKE_IMPORT_LIBRARY_SUFFIX  "")
+add_library(foo SHARED empty.c)

+ 1 - 0
Tests/RunCMake/VS10Project/RunCMakeTest.cmake

@@ -11,6 +11,7 @@ run_cmake(VsCsharpSourceGroup)
 run_cmake(VsCSharpCompilerOpts)
 run_cmake(VsCSharpCompilerOpts)
 run_cmake(ExplicitCMakeLists)
 run_cmake(ExplicitCMakeLists)
 run_cmake(InterfaceLibSources)
 run_cmake(InterfaceLibSources)
+run_cmake(NoImpLib)
 run_cmake(RuntimeLibrary)
 run_cmake(RuntimeLibrary)
 run_cmake(SourceGroupCMakeLists)
 run_cmake(SourceGroupCMakeLists)
 run_cmake(SourceGroupTreeCMakeLists)
 run_cmake(SourceGroupTreeCMakeLists)