1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
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
15 #include "cmCoreTryCompile.h"
17 /** \class cmTryCompileCommand
18 * \brief Specifies where to install some files
20 * cmTryCompileCommand is used to test if soucre code can be compiled
22 class cmTryCompileCommand : public cmCoreTryCompile
26 * This is a virtual constructor for the command.
28 virtual cmCommand* Clone()
30 return new cmTryCompileCommand;
34 * This is called when the command is first encountered in
35 * the CMakeLists.txt file.
37 virtual bool InitialPass(std::vector<std::string> const& args,
38 cmExecutionStatus &status);
41 * The name of the command as specified in CMakeList.txt.
43 virtual const char* GetName() const { return "try_compile";}
46 * Succinct documentation.
48 virtual const char* GetTerseDocumentation() const
50 return "Try building some code.";
54 * More documentation. */
55 virtual const char* GetFullDocumentation() const
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 "
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 "
75 "CMake will create a CMakeLists.txt file to build the source "
77 "Specify COPY_FILE to get a copy of the linked executable at the "
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 "
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 "
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 "
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 "
114 cmTypeMacro(cmTryCompileCommand, cmCoreTryCompile);