cmTargetCompileOptionsCommand.cxx 1.45 KB
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
3 4
#include "cmTargetCompileOptionsCommand.h"

5 6
#include <sstream>

7
#include "cmAlgorithms.h"
8 9 10 11 12 13
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmTarget.h"
#include "cmake.h"

class cmExecutionStatus;
14

15 16
bool cmTargetCompileOptionsCommand::InitialPass(
  std::vector<std::string> const& args, cmExecutionStatus&)
17 18 19 20
{
  return this->HandleArguments(args, "COMPILE_OPTIONS", PROCESS_BEFORE);
}

21 22
void cmTargetCompileOptionsCommand::HandleImportedTarget(
  const std::string& tgt)
23
{
24
  std::ostringstream e;
25
  e << "Cannot specify compile options for imported target \"" << tgt << "\".";
26 27 28
  this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
}

29 30
void cmTargetCompileOptionsCommand::HandleMissingTarget(
  const std::string& name)
31
{
32
  std::ostringstream e;
33 34
  e << "Cannot specify compile options for target \"" << name
    << "\" "
35 36 37 38
       "which is not built by this project.";
  this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
}

39 40
std::string cmTargetCompileOptionsCommand::Join(
  const std::vector<std::string>& content)
41
{
42
  return cmJoin(content, ";");
43 44
}

45 46
bool cmTargetCompileOptionsCommand::HandleDirectContent(
  cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
47
{
48
  cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
49
  tgt->InsertCompileOption(this->Join(content), lfbt);
50
  return true;
51
}