summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Jansen <mark.jansen@reactos.org>2020-09-25 20:13:45 (GMT)
committerBrad King <brad.king@kitware.com>2020-09-30 16:11:54 (GMT)
commit7bda9a7fc78cfe43fe7f0d98bea41158bf75433e (patch)
treece40e91f34cc34873d26244fd711e6498c22699c
parentd91c3e33cbf9592f90f65bd7d990a8b54ad140d1 (diff)
downloadCMake-7bda9a7fc78cfe43fe7f0d98bea41158bf75433e.zip
CMake-7bda9a7fc78cfe43fe7f0d98bea41158bf75433e.tar.gz
CMake-7bda9a7fc78cfe43fe7f0d98bea41158bf75433e.tar.bz2
VS: Make ImportLibary generation optional
Fixes: #21180
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx12
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx12
-rw-r--r--Tests/RunCMake/VS10Project/NoImpLib-check.cmake23
-rw-r--r--Tests/RunCMake/VS10Project/NoImpLib.cmake3
-rw-r--r--Tests/RunCMake/VS10Project/RunCMakeTest.cmake1
5 files changed, 41 insertions, 10 deletions
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 7795654..b54a83f 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1081,11 +1081,13 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
if (stackVal) {
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) {
fout << "\n\t\t\t\tLinkDLL=\"true\"";
}
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index a7b90b4..c025814 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -3791,12 +3791,14 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
std::string pdb = cmStrCat(this->GeneratorTarget->GetPDBDirectory(config),
'/', 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);
// A Windows Runtime component uses internal .NET metadata,
diff --git a/Tests/RunCMake/VS10Project/NoImpLib-check.cmake b/Tests/RunCMake/VS10Project/NoImpLib-check.cmake
new file mode 100644
index 0000000..50722b2
--- /dev/null
+++ b/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()
diff --git a/Tests/RunCMake/VS10Project/NoImpLib.cmake b/Tests/RunCMake/VS10Project/NoImpLib.cmake
new file mode 100644
index 0000000..2c11eac
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/NoImpLib.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+set(CMAKE_IMPORT_LIBRARY_SUFFIX "")
+add_library(foo SHARED empty.c)
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index 8e56e1b..133dacc 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -11,6 +11,7 @@ run_cmake(VsCsharpSourceGroup)
run_cmake(VsCSharpCompilerOpts)
run_cmake(ExplicitCMakeLists)
run_cmake(InterfaceLibSources)
+run_cmake(NoImpLib)
run_cmake(RuntimeLibrary)
run_cmake(SourceGroupCMakeLists)
run_cmake(SourceGroupTreeCMakeLists)