CMP0033: Remove support for OLD export_library_dependencies command
This commit is contained in:
parent
ff6d55f8c5
commit
76702e36e3
@ -1,6 +1,9 @@
|
||||
CMP0033
|
||||
-------
|
||||
|
||||
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
|
||||
.. include:: REMOVED_PROLOGUE.txt
|
||||
|
||||
The :command:`export_library_dependencies` command should not be called.
|
||||
|
||||
This command was added in January 2003 to export ``<tgt>_LIB_DEPENDS``
|
||||
@ -11,6 +14,4 @@ The functionality has been superseded by the :command:`export` and
|
||||
:command:`install(EXPORT)` commands.
|
||||
|
||||
.. |disallowed_version| replace:: 3.0
|
||||
.. include:: DISALLOWED_COMMAND.txt
|
||||
|
||||
.. include:: DEPRECATED.txt
|
||||
.. include:: REMOVED_COMMAND.txt
|
||||
|
@ -588,8 +588,6 @@ add_library(
|
||||
cmExperimental.h
|
||||
cmExportCommand.cxx
|
||||
cmExportCommand.h
|
||||
cmExportLibraryDependenciesCommand.cxx
|
||||
cmExportLibraryDependenciesCommand.h
|
||||
cmFLTKWrapUICommand.cxx
|
||||
cmFLTKWrapUICommand.h
|
||||
cmFileCommand.cxx
|
||||
|
@ -97,7 +97,6 @@
|
||||
# include "cmCMakeHostSystemInformationCommand.h"
|
||||
# include "cmCMakePkgConfigCommand.h"
|
||||
# include "cmExportCommand.h"
|
||||
# include "cmExportLibraryDependenciesCommand.h"
|
||||
# include "cmFLTKWrapUICommand.h"
|
||||
# include "cmFileAPICommand.h"
|
||||
# include "cmIncludeExternalMSProjectCommand.h"
|
||||
@ -300,11 +299,9 @@ void GetProjectCommands(cmState* state)
|
||||
state->AddBuiltinCommand("cmake_file_api", cmFileAPICommand);
|
||||
state->AddBuiltinCommand("cmake_instrumentation", cmInstrumentationCommand);
|
||||
|
||||
state->AddDisallowedCommand(
|
||||
"export_library_dependencies", cmExportLibraryDependenciesCommand,
|
||||
cmPolicies::CMP0033,
|
||||
"The export_library_dependencies command should not be called; "
|
||||
"see CMP0033.");
|
||||
state->AddRemovedCommand(
|
||||
"export_library_dependencies",
|
||||
"The export_library_dependencies command has been removed; see CMP0033.");
|
||||
state->AddRemovedCommand(
|
||||
"load_command", "The load_command command has been removed; see CMP0031.");
|
||||
state->AddRemovedCommand(
|
||||
|
@ -1,164 +0,0 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmExportLibraryDependenciesCommand.h"
|
||||
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include <cm/memory>
|
||||
|
||||
#include "cmsys/FStream.hxx"
|
||||
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmTargetLinkLibraryType.h"
|
||||
#include "cmValue.h"
|
||||
#include "cmake.h"
|
||||
|
||||
class cmListFileBacktrace;
|
||||
|
||||
static void FinalAction(cmMakefile& makefile, std::string const& filename,
|
||||
bool append)
|
||||
{
|
||||
// Use copy-if-different if not appending.
|
||||
std::unique_ptr<cmsys::ofstream> foutPtr;
|
||||
if (append) {
|
||||
const auto openmodeApp = std::ios::app;
|
||||
foutPtr = cm::make_unique<cmsys::ofstream>(filename.c_str(), openmodeApp);
|
||||
} else {
|
||||
std::unique_ptr<cmGeneratedFileStream> ap(
|
||||
new cmGeneratedFileStream(filename, true));
|
||||
ap->SetCopyIfDifferent(true);
|
||||
foutPtr = std::move(ap);
|
||||
}
|
||||
std::ostream& fout = *foutPtr;
|
||||
|
||||
if (!fout) {
|
||||
cmSystemTools::Error("Error Writing " + filename);
|
||||
cmSystemTools::ReportLastSystemError("");
|
||||
return;
|
||||
}
|
||||
|
||||
// Collect dependency information about all library targets built in
|
||||
// the project.
|
||||
cmake* cm = makefile.GetCMakeInstance();
|
||||
cmGlobalGenerator* global = cm->GetGlobalGenerator();
|
||||
const auto& locals = global->GetMakefiles();
|
||||
std::map<std::string, std::string> libDepsOld;
|
||||
std::map<std::string, std::string> libDepsNew;
|
||||
std::map<std::string, std::string> libTypes;
|
||||
for (const auto& local : locals) {
|
||||
for (auto const& tgt : local->GetTargets()) {
|
||||
// Get the current target.
|
||||
cmTarget const& target = tgt.second;
|
||||
|
||||
// Skip non-library targets.
|
||||
if (target.GetType() < cmStateEnums::STATIC_LIBRARY ||
|
||||
target.GetType() > cmStateEnums::MODULE_LIBRARY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Construct the dependency variable name.
|
||||
std::string targetEntry = cmStrCat(target.GetName(), "_LIB_DEPENDS");
|
||||
|
||||
// Construct the dependency variable value with the direct link
|
||||
// dependencies.
|
||||
std::string valueOld;
|
||||
std::string valueNew;
|
||||
cmTarget::LinkLibraryVectorType const& libs =
|
||||
target.GetOriginalLinkLibraries();
|
||||
for (cmTarget::LibraryID const& li : libs) {
|
||||
std::string ltVar = cmStrCat(li.first, "_LINK_TYPE");
|
||||
std::string ltValue;
|
||||
switch (li.second) {
|
||||
case GENERAL_LibraryType:
|
||||
valueNew += "general;";
|
||||
ltValue = "general";
|
||||
break;
|
||||
case DEBUG_LibraryType:
|
||||
valueNew += "debug;";
|
||||
ltValue = "debug";
|
||||
break;
|
||||
case OPTIMIZED_LibraryType:
|
||||
valueNew += "optimized;";
|
||||
ltValue = "optimized";
|
||||
break;
|
||||
}
|
||||
std::string lib = li.first;
|
||||
if (cmTarget* libtgt = global->FindTarget(lib)) {
|
||||
// Handle simple output name changes. This command is
|
||||
// deprecated so we do not support full target name
|
||||
// translation (which requires per-configuration info).
|
||||
if (cmValue outname = libtgt->GetProperty("OUTPUT_NAME")) {
|
||||
lib = *outname;
|
||||
}
|
||||
}
|
||||
valueOld += lib;
|
||||
valueOld += ";";
|
||||
valueNew += lib;
|
||||
valueNew += ";";
|
||||
|
||||
std::string& ltEntry = libTypes[ltVar];
|
||||
if (ltEntry.empty()) {
|
||||
ltEntry = ltValue;
|
||||
} else if (ltEntry != ltValue) {
|
||||
ltEntry = "general";
|
||||
}
|
||||
}
|
||||
libDepsNew[targetEntry] = valueNew;
|
||||
libDepsOld[targetEntry] = valueOld;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate dependency information for both old and new style CMake
|
||||
// versions.
|
||||
const char* vertest =
|
||||
"\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" GREATER 2.4";
|
||||
fout << "# Generated by CMake\n\n";
|
||||
fout << "if(" << vertest << ")\n";
|
||||
fout << " # Information for CMake 2.6 and above.\n";
|
||||
for (auto const& i : libDepsNew) {
|
||||
if (!i.second.empty()) {
|
||||
fout << " set(\"" << i.first << "\" \"" << i.second << "\")\n";
|
||||
}
|
||||
}
|
||||
fout << "else()\n";
|
||||
fout << " # Information for CMake 2.4 and lower.\n";
|
||||
for (auto const& i : libDepsOld) {
|
||||
if (!i.second.empty()) {
|
||||
fout << " set(\"" << i.first << "\" \"" << i.second << "\")\n";
|
||||
}
|
||||
}
|
||||
for (auto const& i : libTypes) {
|
||||
if (i.second != "general") {
|
||||
fout << " set(\"" << i.first << "\" \"" << i.second << "\")\n";
|
||||
}
|
||||
}
|
||||
fout << "endif()\n";
|
||||
}
|
||||
|
||||
bool cmExportLibraryDependenciesCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
if (args.empty()) {
|
||||
status.SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string const& filename = args[0];
|
||||
bool const append = args.size() > 1 && args[1] == "APPEND";
|
||||
status.GetMakefile().AddGeneratorAction(
|
||||
[filename, append](cmLocalGenerator& lg, const cmListFileBacktrace&) {
|
||||
FinalAction(*lg.GetMakefile(), filename, append);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#pragma once
|
||||
|
||||
#include "cmConfigure.h" // IWYU pragma: keep
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
bool cmExportLibraryDependenciesCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status);
|
@ -107,7 +107,7 @@ class cmMakefile;
|
||||
NEW) \
|
||||
SELECT(POLICY, CMP0033, \
|
||||
"The export_library_dependencies command should not be called.", 3, \
|
||||
0, 0, WARN) \
|
||||
0, 0, NEW) \
|
||||
SELECT(POLICY, CMP0034, "The utility_source command should not be called.", \
|
||||
3, 0, 0, WARN) \
|
||||
SELECT(POLICY, CMP0035, \
|
||||
|
@ -22,7 +22,6 @@ message("message")
|
||||
# It is not recommended to set a policy to OLD, but this test
|
||||
# covers the OLD behavior of some policies.
|
||||
foreach(p
|
||||
CMP0033
|
||||
CMP0034
|
||||
CMP0043
|
||||
CMP0050
|
||||
@ -437,5 +436,3 @@ endif()
|
||||
#
|
||||
add_subdirectory(Library)
|
||||
add_subdirectory(Executable)
|
||||
export_library_dependencies(${Complex_BINARY_DIR}/ComplexLibraryDepends.cmake)
|
||||
include(${Complex_BINARY_DIR}/ComplexLibraryDepends.cmake OPTIONAL)
|
||||
|
@ -15,7 +15,6 @@ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL " -DCOMPLEX_NDEBUG")
|
||||
# It is not recommended to set a policy to OLD, but this test
|
||||
# covers the OLD behavior of some policies.
|
||||
foreach(p
|
||||
CMP0033
|
||||
CMP0034
|
||||
CMP0043
|
||||
CMP0050
|
||||
@ -394,5 +393,3 @@ endif()
|
||||
#
|
||||
add_subdirectory(Library)
|
||||
add_subdirectory(Executable)
|
||||
export_library_dependencies(${Complex_BINARY_DIR}/ComplexLibraryDepends.cmake)
|
||||
include(${Complex_BINARY_DIR}/ComplexLibraryDepends.cmake OPTIONAL)
|
||||
|
@ -1,4 +1,4 @@
|
||||
CMake Error at CMP0033-NEW.cmake:2 \(export_library_dependencies\):
|
||||
The export_library_dependencies command should not be called; see CMP0033.
|
||||
CMake Error at CMP0033-NEW.cmake:1 \(export_library_dependencies\):
|
||||
The export_library_dependencies command has been removed; see CMP0033.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
@ -1,2 +1 @@
|
||||
cmake_policy(SET CMP0033 NEW)
|
||||
export_library_dependencies()
|
||||
|
@ -1 +0,0 @@
|
||||
1
|
@ -1,4 +0,0 @@
|
||||
CMake Error at CMP0033-OLD.cmake:2 \(export_library_dependencies\):
|
||||
export_library_dependencies called with incorrect number of arguments
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
@ -1,2 +0,0 @@
|
||||
cmake_policy(SET CMP0033 OLD)
|
||||
export_library_dependencies()
|
@ -1 +0,0 @@
|
||||
1
|
@ -1,12 +0,0 @@
|
||||
CMake Warning \(dev\) at CMP0033-WARN.cmake:1 \(export_library_dependencies\):
|
||||
Policy CMP0033 is not set: The export_library_dependencies command should
|
||||
not be called. Run "cmake --help-policy CMP0033" for policy details. Use
|
||||
the cmake_policy command to set the policy and suppress this warning.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
|
||||
CMake Error at CMP0033-WARN.cmake:1 \(export_library_dependencies\):
|
||||
export_library_dependencies called with incorrect number of arguments
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
@ -1 +0,0 @@
|
||||
export_library_dependencies()
|
@ -5,6 +5,7 @@ foreach(p
|
||||
CMP0030
|
||||
CMP0031
|
||||
CMP0032
|
||||
CMP0033
|
||||
)
|
||||
run_cmake(${p}-NEW)
|
||||
endforeach()
|
||||
@ -12,7 +13,6 @@ endforeach()
|
||||
return()
|
||||
|
||||
foreach(p
|
||||
CMP0033
|
||||
CMP0034
|
||||
CMP0035
|
||||
CMP0036
|
||||
|
Loading…
Reference in New Issue
Block a user