MCPcopy Create free account
hub / github.com/Kitware/CMake / cmAddLibraryCommand

Function cmAddLibraryCommand

Source/cmAddLibraryCommand.cxx:18–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#include "cmValue.h"
17
18bool cmAddLibraryCommand(std::vector<std::string> const& args,
19 cmExecutionStatus& status)
20{
21 if (args.empty()) {
22 status.SetError("called with incorrect number of arguments");
23 return false;
24 }
25
26 cmMakefile& mf = status.GetMakefile();
27 // Library type defaults to value of BUILD_SHARED_LIBS, if it exists,
28 // otherwise it defaults to static library.
29 cmStateEnums::TargetType type = cmStateEnums::SHARED_LIBRARY;
30 if (mf.GetDefinition("BUILD_SHARED_LIBS").IsOff()) {
31 type = cmStateEnums::STATIC_LIBRARY;
32 }
33 bool excludeFromAll = false;
34 bool importTarget = false;
35 bool importGlobal = false;
36 bool symbolicTarget = false;
37
38 auto s = args.begin();
39
40 std::string const& libName = *s;
41
42 ++s;
43
44 // If the second argument is "SHARED" or "STATIC", then it controls
45 // the type of library. Otherwise, it is treated as a source or
46 // source list name. There may be two keyword arguments, check for them
47 bool haveSpecifiedType = false;
48 bool isAlias = false;
49 while (s != args.end()) {
50 std::string libType = *s;
51 if (libType == "STATIC") {
52 if (type == cmStateEnums::INTERFACE_LIBRARY) {
53 status.SetError(
54 "INTERFACE library specified with conflicting STATIC type.");
55 return false;
56 }
57 ++s;
58 type = cmStateEnums::STATIC_LIBRARY;
59 haveSpecifiedType = true;
60 } else if (libType == "SHARED") {
61 if (type == cmStateEnums::INTERFACE_LIBRARY) {
62 status.SetError(
63 "INTERFACE library specified with conflicting SHARED type.");
64 return false;
65 }
66 ++s;
67 type = cmStateEnums::SHARED_LIBRARY;
68 haveSpecifiedType = true;
69 } else if (libType == "MODULE") {
70 if (type == cmStateEnums::INTERFACE_LIBRARY) {
71 status.SetError(
72 "INTERFACE library specified with conflicting MODULE type.");
73 return false;
74 }
75 ++s;

Callers

nothing calls this directly

Calls 15

FindTargetToUseMethod · 0.80
AddImportedTargetMethod · 0.80
SetSymbolicMethod · 0.80
EnforceUniqueNameMethod · 0.80
cmStrCatFunction · 0.70
emptyMethod · 0.45
SetErrorMethod · 0.45
GetMakefileMethod · 0.45
IsOffMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…