Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / cmTryCompileCommand.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef cmTryCompileCommand_h
13 #define cmTryCompileCommand_h
14
15 #include "cmCoreTryCompile.h"
16
17 /** \class cmTryCompileCommand
18  * \brief Specifies where to install some files
19  *
20  * cmTryCompileCommand is used to test if soucre code can be compiled
21  */
22 class cmTryCompileCommand : public cmCoreTryCompile
23 {
24 public:
25   /**
26    * This is a virtual constructor for the command.
27    */
28   virtual cmCommand* Clone()
29     {
30     return new cmTryCompileCommand;
31     }
32
33   /**
34    * This is called when the command is first encountered in
35    * the CMakeLists.txt file.
36    */
37   virtual bool InitialPass(std::vector<std::string> const& args,
38                            cmExecutionStatus &status);
39
40   /**
41    * The name of the command as specified in CMakeList.txt.
42    */
43   virtual const char* GetName() const { return "try_compile";}
44
45   /**
46    * Succinct documentation.
47    */
48   virtual const char* GetTerseDocumentation() const
49     {
50     return "Try building some code.";
51     }
52
53   /**
54    * More documentation.  */
55   virtual const char* GetFullDocumentation() const
56     {
57     return
58       "  try_compile(RESULT_VAR <bindir> <srcdir>\n"
59       "              <projectName> [targetName] [CMAKE_FLAGS flags...]\n"
60       "              [OUTPUT_VARIABLE <var>])\n"
61       "Try building a project.  In this form, srcdir should contain a "
62       "complete CMake project with a CMakeLists.txt file and all sources. "
63       "The bindir and srcdir will not be deleted after this command is run. "
64       "Specify targetName to build a specific target instead of the 'all' or "
65       "'ALL_BUILD' target."
66       "\n"
67       "  try_compile(RESULT_VAR <bindir> <srcfile>\n"
68       "              [CMAKE_FLAGS flags...]\n"
69       "              [COMPILE_DEFINITIONS flags...]\n"
70       "              [OUTPUT_VARIABLE <var>]\n"
71       "              [COPY_FILE <fileName>])\n"
72       "Try building a source file into an executable.  "
73       "In this form the user need only supply a source file that defines "
74       "a 'main'.  "
75       "CMake will create a CMakeLists.txt file to build the source "
76       "as an executable.  "
77       "Specify COPY_FILE to get a copy of the linked executable at the "
78       "given fileName."
79       "\n"
80       "In this version all files in bindir/CMakeFiles/CMakeTmp "
81       "will be cleaned automatically. For debugging, --debug-trycompile can "
82       "be passed to cmake to avoid this clean. However, multiple sequential "
83       "try_compile operations reuse this single output directory. If you "
84       "use --debug-trycompile, you can only debug one try_compile call at a "
85       "time. The recommended procedure is to configure with cmake all the "
86       "way through once, then delete the cache entry associated with "
87       "the try_compile call of interest, and then re-run cmake again with "
88       "--debug-trycompile."
89       "\n"
90       "Some extra flags that can be included are,  "
91       "INCLUDE_DIRECTORIES, LINK_DIRECTORIES, and LINK_LIBRARIES.  "
92       "COMPILE_DEFINITIONS are -Ddefinition that will be passed to the "
93       "compile line.  "
94       "try_compile creates a CMakeList.txt "
95       "file on the fly that looks like this:\n"
96       "  add_definitions( <expanded COMPILE_DEFINITIONS from calling "
97       "cmake>)\n"
98       "  include_directories(${INCLUDE_DIRECTORIES})\n"
99       "  link_directories(${LINK_DIRECTORIES})\n"
100       "  add_executable(cmTryCompileExec sources)\n"
101       "  target_link_libraries(cmTryCompileExec ${LINK_LIBRARIES})\n"
102       "In both versions of the command, "
103       "if OUTPUT_VARIABLE is specified, then the "
104       "output from the build process is stored in the given variable. "
105       "The success or failure of the try_compile, i.e. TRUE or FALSE "
106       "respectively, is returned in "
107       "RESULT_VAR. CMAKE_FLAGS can be used to pass -DVAR:TYPE=VALUE flags "
108       "to the cmake that is run during the build. "
109       "Set variable CMAKE_TRY_COMPILE_CONFIGURATION to choose a build "
110       "configuration."
111       ;
112     }
113
114   cmTypeMacro(cmTryCompileCommand, cmCoreTryCompile);
115
116 };
117
118
119 #endif