cmCoreTryCompile.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 cmCoreTryCompile_h
  4. #define cmCoreTryCompile_h
  5. #include "cmCommand.h"
  6. /** \class cmCoreTryCompile
  7. * \brief Base class for cmTryCompileCommand and cmTryRunCommand
  8. *
  9. * cmCoreTryCompile implements the functionality to build a program.
  10. * It is the base class for cmTryCompileCommand and cmTryRunCommand.
  11. */
  12. class cmCoreTryCompile : public cmCommand
  13. {
  14. public:
  15. protected:
  16. /**
  17. * This is the core code for try compile. It is here so that other
  18. * commands, such as TryRun can access the same logic without
  19. * duplication.
  20. */
  21. int TryCompileCode(std::vector<std::string> const& argv, bool isTryRun);
  22. /**
  23. * This deletes all the files created by TryCompileCode.
  24. * This way we do not have to rely on the timing and
  25. * dependencies of makefiles.
  26. */
  27. void CleanupFiles(const char* binDir);
  28. /**
  29. * This tries to find the (executable) file created by
  30. TryCompileCode. The result is stored in OutputFile. If nothing is found,
  31. the error message is stored in FindErrorMessage.
  32. */
  33. void FindOutputFile(const std::string& targetName,
  34. cmStateEnums::TargetType targetType);
  35. cmTypeMacro(cmCoreTryCompile, cmCommand);
  36. std::string BinaryDirectory;
  37. std::string OutputFile;
  38. std::string FindErrorMessage;
  39. bool SrcFileSignature;
  40. };
  41. #endif