diff --git a/Help/policy/CMP0033.rst b/Help/policy/CMP0033.rst index 4a6cc591d7..7f84dc015a 100644 --- a/Help/policy/CMP0033.rst +++ b/Help/policy/CMP0033.rst @@ -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 ``_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 diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 5dbbbe9825..d00ca98b04 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -588,8 +588,6 @@ add_library( cmExperimental.h cmExportCommand.cxx cmExportCommand.h - cmExportLibraryDependenciesCommand.cxx - cmExportLibraryDependenciesCommand.h cmFLTKWrapUICommand.cxx cmFLTKWrapUICommand.h cmFileCommand.cxx diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index c54c2f5e90..06e692e3b9 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.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( diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx deleted file mode 100644 index 02d044424a..0000000000 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ /dev/null @@ -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 -#include -#include - -#include - -#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 foutPtr; - if (append) { - const auto openmodeApp = std::ios::app; - foutPtr = cm::make_unique(filename.c_str(), openmodeApp); - } else { - std::unique_ptr 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 libDepsOld; - std::map libDepsNew; - std::map 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 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; -} diff --git a/Source/cmExportLibraryDependenciesCommand.h b/Source/cmExportLibraryDependenciesCommand.h deleted file mode 100644 index 1834bfa239..0000000000 --- a/Source/cmExportLibraryDependenciesCommand.h +++ /dev/null @@ -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 -#include - -class cmExecutionStatus; - -bool cmExportLibraryDependenciesCommand(std::vector const& args, - cmExecutionStatus& status); diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 9a1aa5fe45..d4f6df439c 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -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, \ diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index f20c3b2b78..94ebddc1b7 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -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) diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index be490745bb..5bbbdb24c6 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -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) diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-NEW-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0033-NEW-stderr.txt index 8d210aa689..69e043964f 100644 --- a/Tests/RunCMake/DisallowedCommands/CMP0033-NEW-stderr.txt +++ b/Tests/RunCMake/DisallowedCommands/CMP0033-NEW-stderr.txt @@ -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\) diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-NEW.cmake b/Tests/RunCMake/DisallowedCommands/CMP0033-NEW.cmake index 6f90f29e80..f897dddf51 100644 --- a/Tests/RunCMake/DisallowedCommands/CMP0033-NEW.cmake +++ b/Tests/RunCMake/DisallowedCommands/CMP0033-NEW.cmake @@ -1,2 +1 @@ -cmake_policy(SET CMP0033 NEW) export_library_dependencies() diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-OLD-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0033-OLD-result.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/Tests/RunCMake/DisallowedCommands/CMP0033-OLD-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-OLD-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0033-OLD-stderr.txt deleted file mode 100644 index e5dd2dd79b..0000000000 --- a/Tests/RunCMake/DisallowedCommands/CMP0033-OLD-stderr.txt +++ /dev/null @@ -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\) diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-OLD.cmake b/Tests/RunCMake/DisallowedCommands/CMP0033-OLD.cmake deleted file mode 100644 index a3504b67d3..0000000000 --- a/Tests/RunCMake/DisallowedCommands/CMP0033-OLD.cmake +++ /dev/null @@ -1,2 +0,0 @@ -cmake_policy(SET CMP0033 OLD) -export_library_dependencies() diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-WARN-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0033-WARN-result.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/Tests/RunCMake/DisallowedCommands/CMP0033-WARN-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-WARN-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0033-WARN-stderr.txt deleted file mode 100644 index e561dacafe..0000000000 --- a/Tests/RunCMake/DisallowedCommands/CMP0033-WARN-stderr.txt +++ /dev/null @@ -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\) diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-WARN.cmake b/Tests/RunCMake/DisallowedCommands/CMP0033-WARN.cmake deleted file mode 100644 index f897dddf51..0000000000 --- a/Tests/RunCMake/DisallowedCommands/CMP0033-WARN.cmake +++ /dev/null @@ -1 +0,0 @@ -export_library_dependencies() diff --git a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake index 06296c12e1..b925fb8a22 100644 --- a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake +++ b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake @@ -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