mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 21:00:01 -05:00
Ninja Multi-Config: Fix bug with MacOS frameworks
This commit is contained in:
@@ -58,12 +58,14 @@ std::unique_ptr<cmNinjaTargetGenerator> cmNinjaTargetGenerator::New(
|
|||||||
|
|
||||||
cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target)
|
cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target)
|
||||||
: cmCommonTargetGenerator(target)
|
: cmCommonTargetGenerator(target)
|
||||||
, MacOSXContentGenerator(nullptr)
|
|
||||||
, OSXBundleGenerator(nullptr)
|
, OSXBundleGenerator(nullptr)
|
||||||
, LocalGenerator(
|
, LocalGenerator(
|
||||||
static_cast<cmLocalNinjaGenerator*>(target->GetLocalGenerator()))
|
static_cast<cmLocalNinjaGenerator*>(target->GetLocalGenerator()))
|
||||||
{
|
{
|
||||||
MacOSXContentGenerator = cm::make_unique<MacOSXContentGeneratorType>(this);
|
for (auto const& fileConfig : target->Makefile->GetGeneratorConfigs()) {
|
||||||
|
this->Configs[fileConfig].MacOSXContentGenerator =
|
||||||
|
cm::make_unique<MacOSXContentGeneratorType>(this, fileConfig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmNinjaTargetGenerator::~cmNinjaTargetGenerator() = default;
|
cmNinjaTargetGenerator::~cmNinjaTargetGenerator() = default;
|
||||||
@@ -837,13 +839,15 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
|
|||||||
std::vector<cmSourceFile const*> headerSources;
|
std::vector<cmSourceFile const*> headerSources;
|
||||||
this->GeneratorTarget->GetHeaderSources(headerSources, config);
|
this->GeneratorTarget->GetHeaderSources(headerSources, config);
|
||||||
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
|
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
|
||||||
headerSources, this->MacOSXContentGenerator.get(), config);
|
headerSources, this->Configs[fileConfig].MacOSXContentGenerator.get(),
|
||||||
|
config);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::vector<cmSourceFile const*> extraSources;
|
std::vector<cmSourceFile const*> extraSources;
|
||||||
this->GeneratorTarget->GetExtraSources(extraSources, config);
|
this->GeneratorTarget->GetExtraSources(extraSources, config);
|
||||||
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
|
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
|
||||||
extraSources, this->MacOSXContentGenerator.get(), config);
|
extraSources, this->Configs[fileConfig].MacOSXContentGenerator.get(),
|
||||||
|
config);
|
||||||
}
|
}
|
||||||
if (firstForConfig) {
|
if (firstForConfig) {
|
||||||
const char* pchExtension =
|
const char* pchExtension =
|
||||||
@@ -1452,6 +1456,16 @@ void cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
|
|||||||
this->Generator->OSXBundleGenerator->InitMacOSXContentDirectory(pkgloc,
|
this->Generator->OSXBundleGenerator->InitMacOSXContentDirectory(pkgloc,
|
||||||
config);
|
config);
|
||||||
|
|
||||||
|
// Reject files that collide with files from the Ninja file's native config.
|
||||||
|
if (config != this->FileConfig) {
|
||||||
|
std::string nativeMacdir =
|
||||||
|
this->Generator->OSXBundleGenerator->InitMacOSXContentDirectory(
|
||||||
|
pkgloc, this->FileConfig);
|
||||||
|
if (macdir == nativeMacdir) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get the input file location.
|
// Get the input file location.
|
||||||
std::string input = source.GetFullPath();
|
std::string input = source.GetFullPath();
|
||||||
input = this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(input);
|
input = this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(input);
|
||||||
@@ -1462,8 +1476,8 @@ void cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
|
|||||||
output = this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(output);
|
output = this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(output);
|
||||||
|
|
||||||
// Write a build statement to copy the content into the bundle.
|
// Write a build statement to copy the content into the bundle.
|
||||||
this->Generator->GetGlobalGenerator()->WriteMacOSXContentBuild(input, output,
|
this->Generator->GetGlobalGenerator()->WriteMacOSXContentBuild(
|
||||||
config);
|
input, output, this->FileConfig);
|
||||||
|
|
||||||
// Add as a dependency to the target so that it gets called.
|
// Add as a dependency to the target so that it gets called.
|
||||||
this->Generator->Configs[config].ExtraFiles.push_back(std::move(output));
|
this->Generator->Configs[config].ExtraFiles.push_back(std::move(output));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "cm_jsoncpp_value.h"
|
#include "cm_jsoncpp_value.h"
|
||||||
@@ -173,8 +174,10 @@ protected:
|
|||||||
struct MacOSXContentGeneratorType
|
struct MacOSXContentGeneratorType
|
||||||
: cmOSXBundleGenerator::MacOSXContentGeneratorType
|
: cmOSXBundleGenerator::MacOSXContentGeneratorType
|
||||||
{
|
{
|
||||||
MacOSXContentGeneratorType(cmNinjaTargetGenerator* g)
|
MacOSXContentGeneratorType(cmNinjaTargetGenerator* g,
|
||||||
|
std::string fileConfig)
|
||||||
: Generator(g)
|
: Generator(g)
|
||||||
|
, FileConfig(std::move(fileConfig))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,10 +186,10 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
cmNinjaTargetGenerator* Generator;
|
cmNinjaTargetGenerator* Generator;
|
||||||
|
std::string FileConfig;
|
||||||
};
|
};
|
||||||
friend struct MacOSXContentGeneratorType;
|
friend struct MacOSXContentGeneratorType;
|
||||||
|
|
||||||
std::unique_ptr<MacOSXContentGeneratorType> MacOSXContentGenerator;
|
|
||||||
// Properly initialized by sub-classes.
|
// Properly initialized by sub-classes.
|
||||||
std::unique_ptr<cmOSXBundleGenerator> OSXBundleGenerator;
|
std::unique_ptr<cmOSXBundleGenerator> OSXBundleGenerator;
|
||||||
std::set<std::string> MacContentFolders;
|
std::set<std::string> MacContentFolders;
|
||||||
@@ -209,6 +212,7 @@ private:
|
|||||||
Json::Value SwiftOutputMap;
|
Json::Value SwiftOutputMap;
|
||||||
std::vector<cmCustomCommand const*> CustomCommands;
|
std::vector<cmCustomCommand const*> CustomCommands;
|
||||||
cmNinjaDeps ExtraFiles;
|
cmNinjaDeps ExtraFiles;
|
||||||
|
std::unique_ptr<MacOSXContentGeneratorType> MacOSXContentGenerator;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<std::string, ByConfig> Configs;
|
std::map<std::string, ByConfig> Configs;
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
enable_language(C)
|
||||||
|
|
||||||
|
set(header "${CMAKE_CURRENT_BINARY_DIR}/header.h")
|
||||||
|
file(GENERATE
|
||||||
|
OUTPUT "${header}"
|
||||||
|
CONTENT "/* foo */"
|
||||||
|
CONDITION "$<CONFIG:Release>"
|
||||||
|
)
|
||||||
|
add_library(framework SHARED "${header}" empty.c)
|
||||||
|
|
||||||
|
set_property(TARGET framework PROPERTY FRAMEWORK ON)
|
||||||
|
set_property(TARGET framework APPEND PROPERTY PUBLIC_HEADER ${header})
|
||||||
|
|
||||||
|
set_target_properties(framework PROPERTIES
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY "lib"
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY_DEBUG "lib"
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY_RELEASE "lib"
|
||||||
|
DEBUG_POSTFIX "_debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake)
|
||||||
|
generate_output_files(framework)
|
||||||
@@ -142,6 +142,13 @@ run_ninja(SimpleCrossConfigs clean-all-in-release-graph build-Release.ninja clea
|
|||||||
run_cmake_build(SimpleCrossConfigs all-all-in-release-graph Release all:all)
|
run_cmake_build(SimpleCrossConfigs all-all-in-release-graph Release all:all)
|
||||||
run_cmake_build(SimpleCrossConfigs all-relwithdebinfo-in-release-graph Release all:RelWithDebInfo)
|
run_cmake_build(SimpleCrossConfigs all-relwithdebinfo-in-release-graph Release all:RelWithDebInfo)
|
||||||
|
|
||||||
|
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Framework-build)
|
||||||
|
set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE=ON")
|
||||||
|
run_cmake_configure(Framework)
|
||||||
|
unset(RunCMake_TEST_OPTIONS)
|
||||||
|
include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake)
|
||||||
|
run_cmake_build(Framework framework Debug all)
|
||||||
|
|
||||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CustomCommandGenerator-build)
|
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CustomCommandGenerator-build)
|
||||||
set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE=ON")
|
set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE=ON")
|
||||||
run_cmake_configure(CustomCommandGenerator)
|
run_cmake_configure(CustomCommandGenerator)
|
||||||
|
|||||||
Reference in New Issue
Block a user