1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 file Copyright.txt or https://cmake.org/licensing for details. */ 3 #pragma once 4 5 #include "cmConfigure.h" // IWYU pragma: keep 6 7 #include <string> 8 #include <vector> 9 10 #include <cm/memory> 11 12 #include "cmCommand.h" 13 #include "cmCoreTryCompile.h" 14 15 class cmExecutionStatus; 16 17 /** \class cmTryRunCommand 18 * \brief Specifies where to install some files 19 * 20 * cmTryRunCommand is used to test if source code can be compiled 21 */ 22 class cmTryRunCommand : public cmCoreTryCompile 23 { 24 public: 25 /** 26 * This is a virtual constructor for the command. 27 */ Clone()28 std::unique_ptr<cmCommand> Clone() override 29 { 30 return cm::make_unique<cmTryRunCommand>(); 31 } 32 33 /** 34 * This is called when the command is first encountered in 35 * the CMakeLists.txt file. 36 */ 37 bool InitialPass(std::vector<std::string> const& args, 38 cmExecutionStatus& status) override; 39 40 private: 41 void RunExecutable(const std::string& runArgs, 42 std::string* runOutputContents); 43 void DoNotRunExecutable(const std::string& runArgs, 44 const std::string& srcFile, 45 std::string* runOutputContents); 46 47 std::string CompileResultVariable; 48 std::string RunResultVariable; 49 std::string OutputVariable; 50 std::string RunOutputVariable; 51 std::string CompileOutputVariable; 52 std::string WorkingDirectory; 53 }; 54