cmTryRunCommand.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmTryRunCommand_h
  14. #define cmTryRunCommand_h
  15. #include "cmCoreTryCompile.h"
  16. /** \class cmTryRunCommand
  17. * \brief Specifies where to install some files
  18. *
  19. * cmTryRunCommand is used to test if soucre code can be compiled
  20. */
  21. class cmTryRunCommand : public cmCoreTryCompile
  22. {
  23. public:
  24. /**
  25. * This is a virtual constructor for the command.
  26. */
  27. virtual cmCommand* Clone()
  28. {
  29. return new cmTryRunCommand;
  30. }
  31. /**
  32. * This is called when the command is first encountered in
  33. * the CMakeLists.txt file.
  34. */
  35. virtual bool InitialPass(std::vector<std::string> const& args);
  36. /**
  37. * The name of the command as specified in CMakeList.txt.
  38. */
  39. virtual const char* GetName() { return "TRY_RUN";}
  40. /**
  41. * Succinct documentation.
  42. */
  43. virtual const char* GetTerseDocumentation()
  44. {
  45. return "Try compiling and then running some code.";
  46. }
  47. /**
  48. * More documentation.
  49. */
  50. virtual const char* GetFullDocumentation()
  51. {
  52. return
  53. " TRY_RUN(RUN_RESULT_VAR COMPILE_RESULT_VAR\n"
  54. " bindir srcfile <CMAKE_FLAGS <Flags>>\n"
  55. " <COMPILE_DEFINITIONS <flags>>\n"
  56. " <OUTPUT_VARIABLE var>\n"
  57. " <ARGS <arg1> <arg2>...>)\n"
  58. "Try compiling a srcfile. Return the success or failure in "
  59. "COMPILE_RESULT_VAR. Then if the compile succeeded, run the "
  60. "executable and return the result in RUN_RESULT_VAR. "
  61. "If the executable was built, but failed to run for some"
  62. "reason, then RUN_RESULT_VAR will be set to FAILED_TO_RUN, and "
  63. "the output will be in the COMPILE_RESULT_VAR. OUTPUT_VARIABLE "
  64. "specifies the name of the variable to put all of the standard "
  65. "output and standard error into.";
  66. }
  67. cmTypeMacro(cmTryRunCommand, cmCoreTryCompile);
  68. };
  69. #endif