1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmAddTestCommand.h,v $
6 Date: $Date: 2009-08-11 13:54:55 $
7 Version: $Revision: 1.18 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmAddTestCommand_h
18 #define cmAddTestCommand_h
20 #include "cmCommand.h"
22 /** \class cmAddTestCommand
23 * \brief Add a test to the lists of tests to run.
25 * cmAddTestCommand adds a test to the list of tests to run .
27 class cmAddTestCommand
: public cmCommand
31 * This is a virtual constructor for the command.
33 virtual cmCommand
* Clone()
35 return new cmAddTestCommand
;
39 * This is called when the command is first encountered in
40 * the CMakeLists.txt file.
42 virtual bool InitialPass(std::vector
<std::string
> const& args
,
43 cmExecutionStatus
&status
);
46 * The name of the command as specified in CMakeList.txt.
48 virtual const char* GetName() { return "add_test";}
51 * Succinct documentation.
53 virtual const char* GetTerseDocumentation()
55 return "Add a test to the project with the specified arguments.";
61 virtual const char* GetFullDocumentation()
64 " add_test(testname Exename arg1 arg2 ...)\n"
65 "If the ENABLE_TESTING command has been run, this command adds a "
66 "test target to the current directory. If ENABLE_TESTING has not "
67 "been run, this command does nothing. "
68 "The tests are run by the testing subsystem by executing Exename "
69 "with the specified arguments. Exename can be either an executable "
70 "built by this project or an arbitrary executable on the "
71 "system (like tclsh). The test will be run with the current working "
72 "directory set to the CMakeList.txt files corresponding directory "
75 " add_test(NAME <name> [CONFIGURATIONS [Debug|Release|...]]\n"
76 " COMMAND <command> [arg1 [arg2 ...]])\n"
77 "If COMMAND specifies an executable target (created by "
78 "add_executable) it will automatically be replaced by the location "
79 "of the executable created at build time. "
80 "If a CONFIGURATIONS option is given then the test will be executed "
81 "only when testing under one of the named configurations."
83 "Arguments after COMMAND may use \"generator expressions\" with the "
85 "These expressions are evaluted during build system generation and "
86 "produce information specific to each generated build configuration. "
87 "Valid expressions are:\n"
88 " $<CONFIGURATION> = configuration name\n"
89 " $<TARGET_FILE:tgt> = main file (.exe, .so.1.2, .a)\n"
90 " $<TARGET_LINKER_FILE:tgt> = file used to link (.a, .lib, .so)\n"
91 " $<TARGET_SONAME_FILE:tgt> = file with soname (.so.3)\n"
92 "where \"tgt\" is the name of a target. "
93 "Target file expressions produce a full path, but _DIR and _NAME "
94 "versions can produce the directory and file name components:\n"
95 " $<TARGET_FILE_DIR:tgt>/$<TARGET_FILE_NAME:tgt>\n"
96 " $<TARGET_LINKER_FILE_DIR:tgt>/$<TARGET_LINKER_FILE_NAME:tgt>\n"
97 " $<TARGET_SONAME_FILE_DIR:tgt>/$<TARGET_SONAME_FILE_NAME:tgt>\n"
99 " add_test(NAME mytest\n"
100 " COMMAND testDriver --config $<CONFIGURATION>\n"
101 " --exe $<TARGET_FILE:myexe>)\n"
102 "This creates a test \"mytest\" whose command runs a testDriver "
103 "tool passing the configuration name and the full path to the "
104 "executable file produced by target \"myexe\"."
108 cmTypeMacro(cmAddTestCommand
, cmCommand
);
110 bool HandleNameMode(std::vector
<std::string
> const& args
);