mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 16:32:14 -06:00
Makefiles: support shortened object filenames
This commit is contained in:
@@ -8,3 +8,6 @@ short-object-names
|
||||
is supported for the following generators:
|
||||
|
||||
- :ref:`Ninja Generators`
|
||||
- :ref:`Makefile Generators`
|
||||
|
||||
Note that the strategy implementation may differ between generators.
|
||||
|
||||
@@ -80,6 +80,11 @@ cmGlobalBorlandMakefileGenerator::GenerateBuildCommand(
|
||||
cmake::NO_BUILD_PARALLEL_LEVEL, verbose, buildOptions, makeOptions);
|
||||
}
|
||||
|
||||
std::string cmGlobalBorlandMakefileGenerator::GetShortBinaryOutputDir() const
|
||||
{
|
||||
return "_o";
|
||||
}
|
||||
|
||||
void cmGlobalBorlandMakefileGenerator::PrintBuildCommandAdvice(
|
||||
std::ostream& os, int jobs) const
|
||||
{
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
|
||||
bool IsGNUMakeJobServerAware() const override { return false; }
|
||||
|
||||
std::string GetShortBinaryOutputDir() const override;
|
||||
|
||||
protected:
|
||||
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
|
||||
std::string const& makeProgram, std::string const& projectName,
|
||||
|
||||
@@ -77,6 +77,11 @@ cmDocumentationEntry cmGlobalUnixMakefileGenerator3::GetDocumentation()
|
||||
"Generates standard UNIX makefiles." };
|
||||
}
|
||||
|
||||
bool cmGlobalUnixMakefileGenerator3::SupportsShortObjectNames() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void cmGlobalUnixMakefileGenerator3::ComputeTargetObjectDirectory(
|
||||
cmGeneratorTarget* gt) const
|
||||
{
|
||||
|
||||
@@ -195,6 +195,7 @@ public:
|
||||
|
||||
bool IsIPOSupported() const override { return true; }
|
||||
|
||||
bool SupportsShortObjectNames() const override;
|
||||
void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
|
||||
|
||||
std::string IncludeDirective;
|
||||
|
||||
@@ -75,6 +75,11 @@ cmGlobalWatcomWMakeGenerator::GenerateBuildCommand(
|
||||
cmake::NO_BUILD_PARALLEL_LEVEL, verbose, buildOptions, makeOptions);
|
||||
}
|
||||
|
||||
std::string cmGlobalWatcomWMakeGenerator::GetShortBinaryOutputDir() const
|
||||
{
|
||||
return "_o";
|
||||
}
|
||||
|
||||
void cmGlobalWatcomWMakeGenerator::PrintBuildCommandAdvice(std::ostream& os,
|
||||
int jobs) const
|
||||
{
|
||||
|
||||
@@ -55,6 +55,8 @@ public:
|
||||
|
||||
bool IsGNUMakeJobServerAware() const override { return false; }
|
||||
|
||||
std::string GetShortBinaryOutputDir() const override;
|
||||
|
||||
protected:
|
||||
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
|
||||
std::string const& makeProgram, std::string const& projectName,
|
||||
|
||||
@@ -201,6 +201,15 @@ void cmLocalUnixMakefileGenerator3::Generate()
|
||||
this->WriteDirectoryInformationFile();
|
||||
}
|
||||
|
||||
std::string cmLocalUnixMakefileGenerator3::GetObjectOutputRoot() const
|
||||
{
|
||||
if (this->UseShortObjectNames()) {
|
||||
return cmStrCat(this->GetCurrentBinaryDirectory(), '/',
|
||||
this->GetGlobalGenerator()->GetShortBinaryOutputDir());
|
||||
}
|
||||
return cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles");
|
||||
}
|
||||
|
||||
void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath()
|
||||
{
|
||||
// Compute the path to use when referencing the current output
|
||||
|
||||
@@ -43,6 +43,8 @@ public:
|
||||
*/
|
||||
void Generate() override;
|
||||
|
||||
std::string GetObjectOutputRoot() const override;
|
||||
|
||||
// this returns the relative path between the HomeOutputDirectory and this
|
||||
// local generators StartOutputDirectory
|
||||
std::string const& GetHomeRelativeOutputPath();
|
||||
|
||||
@@ -39,6 +39,29 @@ function(run_VerboseBuild)
|
||||
endfunction()
|
||||
run_VerboseBuild()
|
||||
|
||||
function(run_VerboseBuildShort)
|
||||
run_cmake(VerboseBuildShort)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/VerboseBuildShort-build)
|
||||
if(RunCMake_GENERATOR STREQUAL "Watcom WMake")
|
||||
# wmake does not actually show the verbose output.
|
||||
set(RunCMake-stdout-file VerboseBuildShort-build-watcom-stdout.txt)
|
||||
endif()
|
||||
run_cmake_command(VerboseBuildShort-build ${CMAKE_COMMAND} --build . -v --clean-first)
|
||||
unset(RunCMake-stdout-file)
|
||||
set(_backup_lang "$ENV{LANG}")
|
||||
set(_backup_lc_Messages "$ENV{LC_MESSAGES}")
|
||||
if(MAKE_IS_GNU)
|
||||
set(RunCMake-stdout-file VerboseBuildShort-nowork-gnu-stdout.txt)
|
||||
set(ENV{LANG} "C")
|
||||
set(ENV{LC_MESSAGES} "C")
|
||||
endif()
|
||||
run_cmake_command(VerboseBuildShort-nowork ${CMAKE_COMMAND} --build . --verbose)
|
||||
set(ENV{LANG} "${_backup_lang}")
|
||||
set(ENV{LC_MESSAGES} "${_backup_lc_messages}")
|
||||
endfunction()
|
||||
run_VerboseBuildShort()
|
||||
|
||||
run_cmake(IncludeRegexSubdir)
|
||||
|
||||
function(run_MakefileConflict)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
set(CMAKE_INTERMEDIATE_DIR_STRATEGY FULL CACHE STRING "" FORCE)
|
||||
|
||||
enable_language(C)
|
||||
|
||||
# Make sure compile command is not hidden in a temp file.
|
||||
|
||||
1
Tests/RunCMake/Make/VerboseBuildShort-build-stdout.txt
Normal file
1
Tests/RunCMake/Make/VerboseBuildShort-build-stdout.txt
Normal file
@@ -0,0 +1 @@
|
||||
DEFINE_FOR_VERBOSE_DETECTION.*.o[\\/]75d5d702[\\/]4efa03e1
|
||||
@@ -0,0 +1 @@
|
||||
Building C object _o/75d5d702/4efa03e1.obj
|
||||
@@ -0,0 +1 @@
|
||||
.*Nothing to be done for.*hello.*
|
||||
10
Tests/RunCMake/Make/VerboseBuildShort.cmake
Normal file
10
Tests/RunCMake/Make/VerboseBuildShort.cmake
Normal file
@@ -0,0 +1,10 @@
|
||||
set(CMAKE_INTERMEDIATE_DIR_STRATEGY SHORT CACHE STRING "" FORCE)
|
||||
|
||||
enable_language(C)
|
||||
|
||||
# Make sure compile command is not hidden in a temp file.
|
||||
string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
|
||||
string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
|
||||
|
||||
add_executable(hello hello.c)
|
||||
target_compile_definitions(hello PRIVATE "DEFINE_FOR_VERBOSE_DETECTION")
|
||||
@@ -91,6 +91,6 @@ function(run_Dependencies suffix)
|
||||
endfunction()
|
||||
|
||||
run_Dependencies("")
|
||||
if (CMAKE_GENERATOR MATCHES "Ninja")
|
||||
if (CMAKE_GENERATOR MATCHES "(Ninja|Makefiles)")
|
||||
run_Dependencies(Short)
|
||||
endif ()
|
||||
|
||||
@@ -18,7 +18,7 @@ endfunction()
|
||||
run_cmake(DisabledPch)
|
||||
run_cmake(PchDebugGenex)
|
||||
run_test(PchInterface)
|
||||
if (CMAKE_GENERATOR MATCHES "Ninja")
|
||||
if (CMAKE_GENERATOR MATCHES "(Ninja|Makefiles)")
|
||||
run_test(PchInterfaceShort)
|
||||
endif ()
|
||||
run_test(PchInterfaceUnity)
|
||||
|
||||
@@ -72,6 +72,6 @@ endfunction()
|
||||
run_test(unitybuild_runtest)
|
||||
run_test(unitybuild_object_library)
|
||||
|
||||
if (CMAKE_GENERATOR MATCHES "Ninja")
|
||||
if (CMAKE_GENERATOR MATCHES "(Ninja|Makefiles)")
|
||||
run_build(unitybuild_cxx_short)
|
||||
endif ()
|
||||
|
||||
Reference in New Issue
Block a user