Commit 9b6797e7 authored by Daniel Pfeifer's avatar Daniel Pfeifer Committed by Cristian Adam
Browse files

PCH: add target_precompile_headers command

parent 0467a2f9
......@@ -656,6 +656,8 @@ set(SRCS
cmTargetLinkDirectoriesCommand.h
cmTargetLinkLibrariesCommand.cxx
cmTargetLinkLibrariesCommand.h
cmTargetPrecompileHeadersCommand.cxx
cmTargetPrecompileHeadersCommand.h
cmTargetPropCommandBase.cxx
cmTargetPropCommandBase.h
cmTargetSourcesCommand.cxx
......
......@@ -78,6 +78,7 @@
#include "cmTargetCompileOptionsCommand.h"
#include "cmTargetIncludeDirectoriesCommand.h"
#include "cmTargetLinkLibrariesCommand.h"
#include "cmTargetPrecompileHeadersCommand.h"
#include "cmTargetSourcesCommand.h"
#include "cmTryCompileCommand.h"
#include "cmTryRunCommand.h"
......@@ -277,6 +278,9 @@ void GetProjectCommands(cmState* state)
state->AddBuiltinCommand("try_compile",
cm::make_unique<cmTryCompileCommand>());
state->AddBuiltinCommand("try_run", cm::make_unique<cmTryRunCommand>());
state->AddBuiltinCommand(
"target_precompile_headers",
cm::make_unique<cmTargetPrecompileHeadersCommand>());
#if !defined(CMAKE_BOOTSTRAP)
state->AddBuiltinCommand("add_compile_definitions",
......
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetPrecompileHeadersCommand.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmStringAlgorithms.h"
#include "cmTarget.h"
bool cmTargetPrecompileHeadersCommand::InitialPass(
std::vector<std::string> const& args, cmExecutionStatus&)
{
return this->HandleArguments(args, "PRECOMPILE_HEADERS");
}
void cmTargetPrecompileHeadersCommand::HandleMissingTarget(
const std::string& name)
{
const std::string e =
cmStrCat("Cannot specify precompile headers for target \"", name,
"\" which is not built by this project.");
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e);
}
std::string cmTargetPrecompileHeadersCommand::Join(
const std::vector<std::string>& content)
{
return cmJoin(content, ";");
}
bool cmTargetPrecompileHeadersCommand::HandleDirectContent(
cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
{
tgt->AppendProperty("PRECOMPILE_HEADERS", this->Join(content).c_str());
return true;
}
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmTargetPrecompileHeadersCommand_h
#define cmTargetPrecompileHeadersCommand_h
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
#include "cmTargetPropCommandBase.h"
class cmExecutionStatus;
class cmTarget;
class cmTargetPrecompileHeadersCommand : public cmTargetPropCommandBase
{
public:
std::unique_ptr<cmCommand> Clone() override
{
return cm::make_unique<cmTargetPrecompileHeadersCommand>();
}
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
private:
void HandleMissingTarget(const std::string& name) override;
bool HandleDirectContent(cmTarget* tgt,
const std::vector<std::string>& content,
bool prepend, bool system) override;
std::string Join(const std::vector<std::string>& content) override;
};
#endif
......@@ -436,6 +436,7 @@ CMAKE_CXX_SOURCES="\
cmTargetCompileOptionsCommand \
cmTargetIncludeDirectoriesCommand \
cmTargetLinkLibrariesCommand \
cmTargetPrecompileHeadersCommand \
cmTargetPropCommandBase \
cmTargetPropertyComputer \
cmTargetSourcesCommand \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment