1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
4 #include "cmCommands.h"
8 #include "cmAddCompileDefinitionsCommand.h"
9 #include "cmAddCustomCommandCommand.h"
10 #include "cmAddCustomTargetCommand.h"
11 #include "cmAddDefinitionsCommand.h"
12 #include "cmAddDependenciesCommand.h"
13 #include "cmAddExecutableCommand.h"
14 #include "cmAddLibraryCommand.h"
15 #include "cmAddSubDirectoryCommand.h"
16 #include "cmAddTestCommand.h"
17 #include "cmBlockCommand.h"
18 #include "cmBreakCommand.h"
19 #include "cmBuildCommand.h"
20 #include "cmCMakeLanguageCommand.h"
21 #include "cmCMakeMinimumRequired.h"
22 #include "cmCMakePathCommand.h"
23 #include "cmCMakePolicyCommand.h"
24 #include "cmConfigureFileCommand.h"
25 #include "cmContinueCommand.h"
26 #include "cmCreateTestSourceList.h"
27 #include "cmDefinePropertyCommand.h"
28 #include "cmEnableLanguageCommand.h"
29 #include "cmEnableTestingCommand.h"
30 #include "cmExecProgramCommand.h"
31 #include "cmExecuteProcessCommand.h"
32 #include "cmFileCommand.h"
33 #include "cmFindFileCommand.h"
34 #include "cmFindLibraryCommand.h"
35 #include "cmFindPackageCommand.h"
36 #include "cmFindPathCommand.h"
37 #include "cmFindProgramCommand.h"
38 #include "cmForEachCommand.h"
39 #include "cmFunctionCommand.h"
40 #include "cmGetCMakePropertyCommand.h"
41 #include "cmGetDirectoryPropertyCommand.h"
42 #include "cmGetFilenameComponentCommand.h"
43 #include "cmGetPropertyCommand.h"
44 #include "cmGetSourceFilePropertyCommand.h"
45 #include "cmGetTargetPropertyCommand.h"
46 #include "cmGetTestPropertyCommand.h"
47 #include "cmIfCommand.h"
48 #include "cmIncludeCommand.h"
49 #include "cmIncludeDirectoryCommand.h"
50 #include "cmIncludeGuardCommand.h"
51 #include "cmIncludeRegularExpressionCommand.h"
52 #include "cmInstallCommand.h"
53 #include "cmInstallFilesCommand.h"
54 #include "cmInstallTargetsCommand.h"
55 #include "cmLinkDirectoriesCommand.h"
56 #include "cmListCommand.h"
57 #include "cmMacroCommand.h"
58 #include "cmMakeDirectoryCommand.h"
59 #include "cmMarkAsAdvancedCommand.h"
60 #include "cmMathCommand.h"
61 #include "cmMessageCommand.h"
62 #include "cmOptionCommand.h"
63 #include "cmParseArgumentsCommand.h"
64 #include "cmPolicies.h"
65 #include "cmProjectCommand.h"
66 #include "cmReturnCommand.h"
67 #include "cmSeparateArgumentsCommand.h"
68 #include "cmSetCommand.h"
69 #include "cmSetDirectoryPropertiesCommand.h"
70 #include "cmSetPropertyCommand.h"
71 #include "cmSetSourceFilesPropertiesCommand.h"
72 #include "cmSetTargetPropertiesCommand.h"
73 #include "cmSetTestsPropertiesCommand.h"
74 #include "cmSiteNameCommand.h"
76 #include "cmStringCommand.h"
77 #include "cmSubdirCommand.h"
78 #include "cmTargetCompileDefinitionsCommand.h"
79 #include "cmTargetCompileFeaturesCommand.h"
80 #include "cmTargetCompileOptionsCommand.h"
81 #include "cmTargetIncludeDirectoriesCommand.h"
82 #include "cmTargetLinkLibrariesCommand.h"
83 #include "cmTargetLinkOptionsCommand.h"
84 #include "cmTargetPrecompileHeadersCommand.h"
85 #include "cmTargetSourcesCommand.h"
86 #include "cmTryCompileCommand.h"
87 #include "cmTryRunCommand.h"
88 #include "cmUnsetCommand.h"
89 #include "cmWhileCommand.h"
91 #if !defined(CMAKE_BOOTSTRAP)
92 # include "cmAddCompileOptionsCommand.h"
93 # include "cmAddLinkOptionsCommand.h"
94 # include "cmAuxSourceDirectoryCommand.h"
95 # include "cmBuildNameCommand.h"
96 # include "cmCMakeHostSystemInformationCommand.h"
97 # include "cmExportCommand.h"
98 # include "cmExportLibraryDependenciesCommand.h"
99 # include "cmFLTKWrapUICommand.h"
100 # include "cmIncludeExternalMSProjectCommand.h"
101 # include "cmInstallProgramsCommand.h"
102 # include "cmLinkLibrariesCommand.h"
103 # include "cmLoadCacheCommand.h"
104 # include "cmLoadCommandCommand.h"
105 # include "cmOutputRequiredFilesCommand.h"
106 # include "cmQTWrapCPPCommand.h"
107 # include "cmQTWrapUICommand.h"
108 # include "cmRemoveCommand.h"
109 # include "cmRemoveDefinitionsCommand.h"
110 # include "cmSourceGroupCommand.h"
111 # include "cmSubdirDependsCommand.h"
112 # include "cmTargetLinkDirectoriesCommand.h"
113 # include "cmUseMangledMesaCommand.h"
114 # include "cmUtilitySourceCommand.h"
115 # include "cmVariableRequiresCommand.h"
116 # include "cmVariableWatchCommand.h"
117 # include "cmWriteFileCommand.h"
120 void GetScriptingCommands(cmState* state)
122 state->AddFlowControlCommand("break", cmBreakCommand);
123 state->AddFlowControlCommand("continue", cmContinueCommand);
124 state->AddFlowControlCommand("foreach", cmForEachCommand);
125 state->AddFlowControlCommand("function", cmFunctionCommand);
126 state->AddFlowControlCommand("if", cmIfCommand);
127 state->AddFlowControlCommand("macro", cmMacroCommand);
128 state->AddFlowControlCommand("return", cmReturnCommand);
129 state->AddFlowControlCommand("while", cmWhileCommand);
130 state->AddFlowControlCommand("block", cmBlockCommand);
132 state->AddBuiltinCommand("cmake_language", cmCMakeLanguageCommand);
133 state->AddBuiltinCommand("cmake_minimum_required", cmCMakeMinimumRequired);
134 state->AddBuiltinCommand("cmake_path", cmCMakePathCommand);
135 state->AddBuiltinCommand("cmake_policy", cmCMakePolicyCommand);
136 state->AddBuiltinCommand("configure_file", cmConfigureFileCommand);
137 state->AddBuiltinCommand("exec_program", cmExecProgramCommand);
138 state->AddBuiltinCommand("execute_process", cmExecuteProcessCommand);
139 state->AddBuiltinCommand("file", cmFileCommand);
140 state->AddBuiltinCommand("find_file", cmFindFile);
141 state->AddBuiltinCommand("find_library", cmFindLibrary);
142 state->AddBuiltinCommand("find_package", cmFindPackage);
143 state->AddBuiltinCommand("find_path", cmFindPath);
144 state->AddBuiltinCommand("find_program", cmFindProgram);
145 state->AddBuiltinCommand("get_cmake_property", cmGetCMakePropertyCommand);
146 state->AddBuiltinCommand("get_directory_property",
147 cmGetDirectoryPropertyCommand);
148 state->AddBuiltinCommand("get_filename_component",
149 cmGetFilenameComponentCommand);
150 state->AddBuiltinCommand("get_property", cmGetPropertyCommand);
151 state->AddBuiltinCommand("include", cmIncludeCommand);
152 state->AddBuiltinCommand("include_guard", cmIncludeGuardCommand);
153 state->AddBuiltinCommand("list", cmListCommand);
154 state->AddBuiltinCommand("make_directory", cmMakeDirectoryCommand);
155 state->AddBuiltinCommand("mark_as_advanced", cmMarkAsAdvancedCommand);
156 state->AddBuiltinCommand("math", cmMathCommand);
157 state->AddBuiltinCommand("message", cmMessageCommand);
158 state->AddBuiltinCommand("option", cmOptionCommand);
159 state->AddBuiltinCommand("cmake_parse_arguments", cmParseArgumentsCommand);
160 state->AddBuiltinCommand("separate_arguments", cmSeparateArgumentsCommand);
161 state->AddBuiltinCommand("set", cmSetCommand);
162 state->AddBuiltinCommand("set_directory_properties",
163 cmSetDirectoryPropertiesCommand);
164 state->AddBuiltinCommand("set_property", cmSetPropertyCommand);
165 state->AddBuiltinCommand("site_name", cmSiteNameCommand);
166 state->AddBuiltinCommand("string", cmStringCommand);
167 state->AddBuiltinCommand("unset", cmUnsetCommand);
169 state->AddUnexpectedFlowControlCommand(
171 "An ELSE command was found outside of a proper "
172 "IF ENDIF structure. Or its arguments did not match "
173 "the opening IF command.");
174 state->AddUnexpectedFlowControlCommand(
176 "An ELSEIF command was found outside of a proper "
177 "IF ENDIF structure.");
178 state->AddUnexpectedFlowControlCommand(
180 "An ENDFOREACH command was found outside of a proper "
181 "FOREACH ENDFOREACH structure. Or its arguments did "
182 "not match the opening FOREACH command.");
183 state->AddUnexpectedFlowControlCommand(
185 "An ENDFUNCTION command was found outside of a proper "
186 "FUNCTION ENDFUNCTION structure. Or its arguments did not "
187 "match the opening FUNCTION command.");
188 state->AddUnexpectedFlowControlCommand(
190 "An ENDIF command was found outside of a proper "
191 "IF ENDIF structure. Or its arguments did not match "
192 "the opening IF command.");
193 state->AddUnexpectedFlowControlCommand(
195 "An ENDMACRO command was found outside of a proper "
196 "MACRO ENDMACRO structure. Or its arguments did not "
197 "match the opening MACRO command.");
198 state->AddUnexpectedFlowControlCommand(
200 "An ENDWHILE command was found outside of a proper "
201 "WHILE ENDWHILE structure. Or its arguments did not "
202 "match the opening WHILE command.");
203 state->AddUnexpectedFlowControlCommand(
205 "An ENDBLOCK command was found outside of a proper "
206 "BLOCK ENDBLOCK structure.");
208 #if !defined(CMAKE_BOOTSTRAP)
209 state->AddBuiltinCommand("cmake_host_system_information",
210 cmCMakeHostSystemInformationCommand);
211 state->AddBuiltinCommand("load_cache", cmLoadCacheCommand);
212 state->AddBuiltinCommand("remove", cmRemoveCommand);
213 state->AddBuiltinCommand("variable_watch", cmVariableWatchCommand);
214 state->AddBuiltinCommand("write_file", cmWriteFileCommand);
216 state->AddDisallowedCommand(
217 "build_name", cmBuildNameCommand, cmPolicies::CMP0036,
218 "The build_name command should not be called; see CMP0036.");
219 state->AddDisallowedCommand(
220 "use_mangled_mesa", cmUseMangledMesaCommand, cmPolicies::CMP0030,
221 "The use_mangled_mesa command should not be called; see CMP0030.");
226 void GetProjectCommands(cmState* state)
228 state->AddBuiltinCommand("add_compile_definitions",
229 cmAddCompileDefinitionsCommand);
230 state->AddBuiltinCommand("add_custom_command", cmAddCustomCommandCommand);
231 state->AddBuiltinCommand("add_custom_target", cmAddCustomTargetCommand);
232 state->AddBuiltinCommand("add_definitions", cmAddDefinitionsCommand);
233 state->AddBuiltinCommand("add_dependencies", cmAddDependenciesCommand);
234 state->AddBuiltinCommand("add_executable", cmAddExecutableCommand);
235 state->AddBuiltinCommand("add_library", cmAddLibraryCommand);
236 state->AddBuiltinCommand("add_subdirectory", cmAddSubDirectoryCommand);
237 state->AddBuiltinCommand("add_test", cmAddTestCommand);
238 state->AddBuiltinCommand("build_command", cmBuildCommand);
239 state->AddBuiltinCommand("create_test_sourcelist", cmCreateTestSourceList);
240 state->AddBuiltinCommand("define_property", cmDefinePropertyCommand);
241 state->AddBuiltinCommand("enable_language", cmEnableLanguageCommand);
242 state->AddBuiltinCommand("enable_testing", cmEnableTestingCommand);
243 state->AddBuiltinCommand("get_source_file_property",
244 cmGetSourceFilePropertyCommand);
245 state->AddBuiltinCommand("get_target_property", cmGetTargetPropertyCommand);
246 state->AddBuiltinCommand("get_test_property", cmGetTestPropertyCommand);
247 state->AddBuiltinCommand("include_directories", cmIncludeDirectoryCommand);
248 state->AddBuiltinCommand("include_regular_expression",
249 cmIncludeRegularExpressionCommand);
250 state->AddBuiltinCommand("install", cmInstallCommand);
251 state->AddBuiltinCommand("install_files", cmInstallFilesCommand);
252 state->AddBuiltinCommand("install_targets", cmInstallTargetsCommand);
253 state->AddBuiltinCommand("link_directories", cmLinkDirectoriesCommand);
254 state->AddBuiltinCommand("project", cmProjectCommand);
255 state->AddBuiltinCommand("set_source_files_properties",
256 cmSetSourceFilesPropertiesCommand);
257 state->AddBuiltinCommand("set_target_properties",
258 cmSetTargetPropertiesCommand);
259 state->AddBuiltinCommand("set_tests_properties",
260 cmSetTestsPropertiesCommand);
261 state->AddBuiltinCommand("subdirs", cmSubdirCommand);
262 state->AddBuiltinCommand("target_compile_definitions",
263 cmTargetCompileDefinitionsCommand);
264 state->AddBuiltinCommand("target_compile_features",
265 cmTargetCompileFeaturesCommand);
266 state->AddBuiltinCommand("target_compile_options",
267 cmTargetCompileOptionsCommand);
268 state->AddBuiltinCommand("target_include_directories",
269 cmTargetIncludeDirectoriesCommand);
270 state->AddBuiltinCommand("target_link_libraries",
271 cmTargetLinkLibrariesCommand);
272 state->AddBuiltinCommand("target_link_options", cmTargetLinkOptionsCommand);
273 state->AddBuiltinCommand("target_sources", cmTargetSourcesCommand);
274 state->AddBuiltinCommand("try_compile", cmTryCompileCommand);
275 state->AddBuiltinCommand("try_run", cmTryRunCommand);
276 state->AddBuiltinCommand("target_precompile_headers",
277 cmTargetPrecompileHeadersCommand);
279 #if !defined(CMAKE_BOOTSTRAP)
280 state->AddBuiltinCommand("add_compile_options", cmAddCompileOptionsCommand);
281 state->AddBuiltinCommand("aux_source_directory",
282 cmAuxSourceDirectoryCommand);
283 state->AddBuiltinCommand("export", cmExportCommand);
284 state->AddBuiltinCommand("fltk_wrap_ui", cmFLTKWrapUICommand);
285 state->AddBuiltinCommand("include_external_msproject",
286 cmIncludeExternalMSProjectCommand);
287 state->AddBuiltinCommand("install_programs", cmInstallProgramsCommand);
288 state->AddBuiltinCommand("add_link_options", cmAddLinkOptionsCommand);
289 state->AddBuiltinCommand("link_libraries", cmLinkLibrariesCommand);
290 state->AddBuiltinCommand("target_link_directories",
291 cmTargetLinkDirectoriesCommand);
292 state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand);
293 state->AddBuiltinCommand("qt_wrap_ui", cmQTWrapUICommand);
294 state->AddBuiltinCommand("remove_definitions", cmRemoveDefinitionsCommand);
295 state->AddBuiltinCommand("source_group", cmSourceGroupCommand);
297 state->AddDisallowedCommand(
298 "export_library_dependencies", cmExportLibraryDependenciesCommand,
300 "The export_library_dependencies command should not be called; "
302 state->AddDisallowedCommand(
303 "load_command", cmLoadCommandCommand, cmPolicies::CMP0031,
304 "The load_command command should not be called; see CMP0031.");
305 state->AddDisallowedCommand(
306 "output_required_files", cmOutputRequiredFilesCommand, cmPolicies::CMP0032,
307 "The output_required_files command should not be called; see CMP0032.");
308 state->AddDisallowedCommand(
309 "subdir_depends", cmSubdirDependsCommand, cmPolicies::CMP0029,
310 "The subdir_depends command should not be called; see CMP0029.");
311 state->AddDisallowedCommand(
312 "utility_source", cmUtilitySourceCommand, cmPolicies::CMP0034,
313 "The utility_source command should not be called; see CMP0034.");
314 state->AddDisallowedCommand(
315 "variable_requires", cmVariableRequiresCommand, cmPolicies::CMP0035,
316 "The variable_requires command should not be called; see CMP0035.");
320 void GetProjectCommandsInScriptMode(cmState* state)
322 #define CM_UNEXPECTED_PROJECT_COMMAND(NAME) \
323 state->AddUnexpectedCommand(NAME, "command is not scriptable")
325 CM_UNEXPECTED_PROJECT_COMMAND("add_compile_options");
326 CM_UNEXPECTED_PROJECT_COMMAND("add_custom_command");
327 CM_UNEXPECTED_PROJECT_COMMAND("add_custom_target");
328 CM_UNEXPECTED_PROJECT_COMMAND("add_definitions");
329 CM_UNEXPECTED_PROJECT_COMMAND("add_dependencies");
330 CM_UNEXPECTED_PROJECT_COMMAND("add_executable");
331 CM_UNEXPECTED_PROJECT_COMMAND("add_library");
332 CM_UNEXPECTED_PROJECT_COMMAND("add_subdirectory");
333 CM_UNEXPECTED_PROJECT_COMMAND("add_test");
334 CM_UNEXPECTED_PROJECT_COMMAND("aux_source_directory");
335 CM_UNEXPECTED_PROJECT_COMMAND("build_command");
336 CM_UNEXPECTED_PROJECT_COMMAND("create_test_sourcelist");
337 CM_UNEXPECTED_PROJECT_COMMAND("define_property");
338 CM_UNEXPECTED_PROJECT_COMMAND("enable_language");
339 CM_UNEXPECTED_PROJECT_COMMAND("enable_testing");
340 CM_UNEXPECTED_PROJECT_COMMAND("export");
341 CM_UNEXPECTED_PROJECT_COMMAND("fltk_wrap_ui");
342 CM_UNEXPECTED_PROJECT_COMMAND("get_source_file_property");
343 CM_UNEXPECTED_PROJECT_COMMAND("get_target_property");
344 CM_UNEXPECTED_PROJECT_COMMAND("get_test_property");
345 CM_UNEXPECTED_PROJECT_COMMAND("include_directories");
346 CM_UNEXPECTED_PROJECT_COMMAND("include_external_msproject");
347 CM_UNEXPECTED_PROJECT_COMMAND("include_regular_expression");
348 CM_UNEXPECTED_PROJECT_COMMAND("install");
349 CM_UNEXPECTED_PROJECT_COMMAND("link_directories");
350 CM_UNEXPECTED_PROJECT_COMMAND("link_libraries");
351 CM_UNEXPECTED_PROJECT_COMMAND("project");
352 CM_UNEXPECTED_PROJECT_COMMAND("qt_wrap_cpp");
353 CM_UNEXPECTED_PROJECT_COMMAND("qt_wrap_ui");
354 CM_UNEXPECTED_PROJECT_COMMAND("remove_definitions");
355 CM_UNEXPECTED_PROJECT_COMMAND("set_source_files_properties");
356 CM_UNEXPECTED_PROJECT_COMMAND("set_target_properties");
357 CM_UNEXPECTED_PROJECT_COMMAND("set_tests_properties");
358 CM_UNEXPECTED_PROJECT_COMMAND("source_group");
359 CM_UNEXPECTED_PROJECT_COMMAND("target_compile_definitions");
360 CM_UNEXPECTED_PROJECT_COMMAND("target_compile_features");
361 CM_UNEXPECTED_PROJECT_COMMAND("target_compile_options");
362 CM_UNEXPECTED_PROJECT_COMMAND("target_include_directories");
363 CM_UNEXPECTED_PROJECT_COMMAND("target_link_libraries");
364 CM_UNEXPECTED_PROJECT_COMMAND("target_sources");
365 CM_UNEXPECTED_PROJECT_COMMAND("try_compile");
366 CM_UNEXPECTED_PROJECT_COMMAND("try_run");
368 // deprecated commands
369 CM_UNEXPECTED_PROJECT_COMMAND("export_library_dependencies");
370 CM_UNEXPECTED_PROJECT_COMMAND("load_command");
371 CM_UNEXPECTED_PROJECT_COMMAND("output_required_files");
372 CM_UNEXPECTED_PROJECT_COMMAND("subdir_depends");
373 CM_UNEXPECTED_PROJECT_COMMAND("utility_source");
374 CM_UNEXPECTED_PROJECT_COMMAND("variable_requires");
376 #undef CM_UNEXPECTED_PROJECT_COMMAND