cmTryRunCommand.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmTryRunCommand_h
  4. #define cmTryRunCommand_h
  5. #include "cmCoreTryCompile.h"
  6. /** \class cmTryRunCommand
  7. * \brief Specifies where to install some files
  8. *
  9. * cmTryRunCommand is used to test if soucre code can be compiled
  10. */
  11. class cmTryRunCommand : public cmCoreTryCompile
  12. {
  13. public:
  14. /**
  15. * This is a virtual constructor for the command.
  16. */
  17. cmCommand* Clone() CM_OVERRIDE { return new cmTryRunCommand; }
  18. /**
  19. * This is called when the command is first encountered in
  20. * the CMakeLists.txt file.
  21. */
  22. bool InitialPass(std::vector<std::string> const& args,
  23. cmExecutionStatus& status) CM_OVERRIDE;
  24. /**
  25. * The name of the command as specified in CMakeList.txt.
  26. */
  27. std::string GetName() const CM_OVERRIDE { return "try_run"; }
  28. cmTypeMacro(cmTryRunCommand, cmCoreTryCompile);
  29. private:
  30. void RunExecutable(const std::string& runArgs,
  31. std::string* runOutputContents);
  32. void DoNotRunExecutable(const std::string& runArgs,
  33. const std::string& srcFile,
  34. std::string* runOutputContents);
  35. std::string CompileResultVariable;
  36. std::string RunResultVariable;
  37. std::string OutputVariable;
  38. std::string RunOutputVariable;
  39. std::string CompileOutputVariable;
  40. };
  41. #endif