mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 19:08:07 +08:00
PCH: add target_precompile_headers command
This commit is contained in:

committed by
Cristian Adam

parent
0467a2f91b
commit
9b6797e71d
@@ -656,6 +656,8 @@ set(SRCS
|
|||||||
cmTargetLinkDirectoriesCommand.h
|
cmTargetLinkDirectoriesCommand.h
|
||||||
cmTargetLinkLibrariesCommand.cxx
|
cmTargetLinkLibrariesCommand.cxx
|
||||||
cmTargetLinkLibrariesCommand.h
|
cmTargetLinkLibrariesCommand.h
|
||||||
|
cmTargetPrecompileHeadersCommand.cxx
|
||||||
|
cmTargetPrecompileHeadersCommand.h
|
||||||
cmTargetPropCommandBase.cxx
|
cmTargetPropCommandBase.cxx
|
||||||
cmTargetPropCommandBase.h
|
cmTargetPropCommandBase.h
|
||||||
cmTargetSourcesCommand.cxx
|
cmTargetSourcesCommand.cxx
|
||||||
|
@@ -78,6 +78,7 @@
|
|||||||
#include "cmTargetCompileOptionsCommand.h"
|
#include "cmTargetCompileOptionsCommand.h"
|
||||||
#include "cmTargetIncludeDirectoriesCommand.h"
|
#include "cmTargetIncludeDirectoriesCommand.h"
|
||||||
#include "cmTargetLinkLibrariesCommand.h"
|
#include "cmTargetLinkLibrariesCommand.h"
|
||||||
|
#include "cmTargetPrecompileHeadersCommand.h"
|
||||||
#include "cmTargetSourcesCommand.h"
|
#include "cmTargetSourcesCommand.h"
|
||||||
#include "cmTryCompileCommand.h"
|
#include "cmTryCompileCommand.h"
|
||||||
#include "cmTryRunCommand.h"
|
#include "cmTryRunCommand.h"
|
||||||
@@ -277,6 +278,9 @@ void GetProjectCommands(cmState* state)
|
|||||||
state->AddBuiltinCommand("try_compile",
|
state->AddBuiltinCommand("try_compile",
|
||||||
cm::make_unique<cmTryCompileCommand>());
|
cm::make_unique<cmTryCompileCommand>());
|
||||||
state->AddBuiltinCommand("try_run", cm::make_unique<cmTryRunCommand>());
|
state->AddBuiltinCommand("try_run", cm::make_unique<cmTryRunCommand>());
|
||||||
|
state->AddBuiltinCommand(
|
||||||
|
"target_precompile_headers",
|
||||||
|
cm::make_unique<cmTargetPrecompileHeadersCommand>());
|
||||||
|
|
||||||
#if !defined(CMAKE_BOOTSTRAP)
|
#if !defined(CMAKE_BOOTSTRAP)
|
||||||
state->AddBuiltinCommand("add_compile_definitions",
|
state->AddBuiltinCommand("add_compile_definitions",
|
||||||
|
36
Source/cmTargetPrecompileHeadersCommand.cxx
Normal file
36
Source/cmTargetPrecompileHeadersCommand.cxx
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/* 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;
|
||||||
|
}
|
41
Source/cmTargetPrecompileHeadersCommand.h
Normal file
41
Source/cmTargetPrecompileHeadersCommand.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/* 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 \
|
cmTargetCompileOptionsCommand \
|
||||||
cmTargetIncludeDirectoriesCommand \
|
cmTargetIncludeDirectoriesCommand \
|
||||||
cmTargetLinkLibrariesCommand \
|
cmTargetLinkLibrariesCommand \
|
||||||
|
cmTargetPrecompileHeadersCommand \
|
||||||
cmTargetPropCommandBase \
|
cmTargetPropCommandBase \
|
||||||
cmTargetPropertyComputer \
|
cmTargetPropertyComputer \
|
||||||
cmTargetSourcesCommand \
|
cmTargetSourcesCommand \
|
||||||
|
Reference in New Issue
Block a user