Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
CMake
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2,684
Issues
2,684
List
Boards
Labels
Milestones
Merge Requests
19
Merge Requests
19
Packages
Packages
Container Registry
External Wiki
External Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
CMake
CMake
Commits
9ba0bf60
Commit
9ba0bf60
authored
Aug 06, 2019
by
wahikihiki
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmA*Command: Turn into free functions
Ref:
#19499
parent
52d9cd62
Changes
25
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
257 additions
and
594 deletions
+257
-594
Source/cmAddCompileDefinitionsCommand.cxx
Source/cmAddCompileDefinitionsCommand.cxx
+5
-9
Source/cmAddCompileDefinitionsCommand.h
Source/cmAddCompileDefinitionsCommand.h
+2
-22
Source/cmAddCompileOptionsCommand.cxx
Source/cmAddCompileOptionsCommand.cxx
+5
-9
Source/cmAddCompileOptionsCommand.h
Source/cmAddCompileOptionsCommand.h
+2
-22
Source/cmAddCustomCommandCommand.cxx
Source/cmAddCustomCommandCommand.cxx
+43
-41
Source/cmAddCustomCommandCommand.h
Source/cmAddCustomCommandCommand.h
+2
-31
Source/cmAddCustomTargetCommand.cxx
Source/cmAddCustomTargetCommand.cxx
+19
-23
Source/cmAddCustomTargetCommand.h
Source/cmAddCustomTargetCommand.h
+2
-29
Source/cmAddDefinitionsCommand.cxx
Source/cmAddDefinitionsCommand.cxx
+5
-11
Source/cmAddDefinitionsCommand.h
Source/cmAddDefinitionsCommand.h
+2
-28
Source/cmAddDependenciesCommand.cxx
Source/cmAddDependenciesCommand.cxx
+10
-11
Source/cmAddDependenciesCommand.h
Source/cmAddDependenciesCommand.h
+2
-27
Source/cmAddExecutableCommand.cxx
Source/cmAddExecutableCommand.cxx
+28
-31
Source/cmAddExecutableCommand.h
Source/cmAddExecutableCommand.h
+2
-28
Source/cmAddLibraryCommand.cxx
Source/cmAddLibraryCommand.cxx
+48
-52
Source/cmAddLibraryCommand.h
Source/cmAddLibraryCommand.h
+2
-28
Source/cmAddLinkOptionsCommand.cxx
Source/cmAddLinkOptionsCommand.cxx
+5
-9
Source/cmAddLinkOptionsCommand.h
Source/cmAddLinkOptionsCommand.h
+2
-22
Source/cmAddSubDirectoryCommand.cxx
Source/cmAddSubDirectoryCommand.cxx
+16
-17
Source/cmAddSubDirectoryCommand.h
Source/cmAddSubDirectoryCommand.h
+2
-29
Source/cmAddTestCommand.cxx
Source/cmAddTestCommand.cxx
+27
-22
Source/cmAddTestCommand.h
Source/cmAddTestCommand.h
+2
-30
Source/cmAuxSourceDirectoryCommand.cxx
Source/cmAuxSourceDirectoryCommand.cxx
+10
-11
Source/cmAuxSourceDirectoryCommand.h
Source/cmAuxSourceDirectoryCommand.h
+2
-31
Source/cmCommands.cxx
Source/cmCommands.cxx
+12
-21
No files found.
Source/cmAddCompileDefinitionsCommand.cxx
View file @
9ba0bf60
...
@@ -2,19 +2,15 @@
...
@@ -2,19 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddCompileDefinitionsCommand.h"
#include "cmAddCompileDefinitionsCommand.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMakefile.h"
class
cmExecutionStatus
;
bool
cmAddCompileDefinitionsCommand
(
std
::
vector
<
std
::
string
>
const
&
args
,
cmExecutionStatus
&
status
)
bool
cmAddCompileDefinitionsCommand
::
InitialPass
(
std
::
vector
<
std
::
string
>
const
&
args
,
cmExecutionStatus
&
)
{
{
if
(
args
.
empty
())
{
cmMakefile
&
mf
=
status
.
GetMakefile
();
return
true
;
}
for
(
std
::
string
const
&
i
:
args
)
{
for
(
std
::
string
const
&
i
:
args
)
{
this
->
Makefile
->
AddCompileDefinition
(
i
);
mf
.
AddCompileDefinition
(
i
);
}
}
return
true
;
return
true
;
}
}
Source/cmAddCompileDefinitionsCommand.h
View file @
9ba0bf60
...
@@ -8,29 +8,9 @@
...
@@ -8,29 +8,9 @@
#include <string>
#include <string>
#include <vector>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
class
cmExecutionStatus
;
class
cmExecutionStatus
;
class
cmAddCompileDefinitionsCommand
:
public
cmCommand
bool
cmAddCompileDefinitionsCommand
(
std
::
vector
<
std
::
string
>
const
&
args
,
{
cmExecutionStatus
&
status
);
public:
/**
* This is a virtual constructor for the command.
*/
std
::
unique_ptr
<
cmCommand
>
Clone
()
override
{
return
cm
::
make_unique
<
cmAddCompileDefinitionsCommand
>
();
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
bool
InitialPass
(
std
::
vector
<
std
::
string
>
const
&
args
,
cmExecutionStatus
&
status
)
override
;
};
#endif
#endif
Source/cmAddCompileOptionsCommand.cxx
View file @
9ba0bf60
...
@@ -2,19 +2,15 @@
...
@@ -2,19 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddCompileOptionsCommand.h"
#include "cmAddCompileOptionsCommand.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMakefile.h"
class
cmExecutionStatus
;
bool
cmAddCompileOptionsCommand
(
std
::
vector
<
std
::
string
>
const
&
args
,
cmExecutionStatus
&
status
)
bool
cmAddCompileOptionsCommand
::
InitialPass
(
std
::
vector
<
std
::
string
>
const
&
args
,
cmExecutionStatus
&
)
{
{
if
(
args
.
empty
())
{
cmMakefile
&
mf
=
status
.
GetMakefile
();
return
true
;
}
for
(
std
::
string
const
&
i
:
args
)
{
for
(
std
::
string
const
&
i
:
args
)
{
this
->
Makefile
->
AddCompileOption
(
i
);
mf
.
AddCompileOption
(
i
);
}
}
return
true
;
return
true
;
}
}
Source/cmAddCompileOptionsCommand.h
View file @
9ba0bf60
...
@@ -8,29 +8,9 @@
...
@@ -8,29 +8,9 @@
#include <string>
#include <string>
#include <vector>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
class
cmExecutionStatus
;
class
cmExecutionStatus
;
class
cmAddCompileOptionsCommand
:
public
cmCommand
bool
cmAddCompileOptionsCommand
(
std
::
vector
<
std
::
string
>
const
&
args
,
{
cmExecutionStatus
&
status
);
public:
/**
* This is a virtual constructor for the command.
*/
std
::
unique_ptr
<
cmCommand
>
Clone
()
override
{
return
cm
::
make_unique
<
cmAddCompileOptionsCommand
>
();
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
bool
InitialPass
(
std
::
vector
<
std
::
string
>
const
&
args
,
cmExecutionStatus
&
status
)
override
;
};
#endif
#endif
Source/cmAddCustomCommandCommand.cxx
View file @
9ba0bf60
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include "cmCustomCommand.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
#include "cmCustomCommandLines.h"
#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmMessageType.h"
...
@@ -16,21 +17,22 @@
...
@@ -16,21 +17,22 @@
#include "cmSystemTools.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTarget.h"
class
cmExecutionStatus
;
static
bool
cmAddCustomCommandCommandCheckOutputs
(
const
std
::
vector
<
std
::
string
>&
outputs
,
cmExecutionStatus
&
status
);
// cmAddCustomCommandCommand
bool
cmAddCustomCommandCommand
(
std
::
vector
<
std
::
string
>
const
&
args
,
bool
cmAddCustomCommandCommand
::
InitialPass
(
cmExecutionStatus
&
status
)
std
::
vector
<
std
::
string
>
const
&
args
,
cmExecutionStatus
&
)
{
{
/* Let's complain at the end of this function about the lack of a particular
/* Let's complain at the end of this function about the lack of a particular
arg. For the moment, let's say that COMMAND, and either TARGET or SOURCE
arg. For the moment, let's say that COMMAND, and either TARGET or SOURCE
are required.
are required.
*/
*/
if
(
args
.
size
()
<
4
)
{
if
(
args
.
size
()
<
4
)
{
this
->
SetError
(
"called with wrong number of arguments."
);
status
.
SetError
(
"called with wrong number of arguments."
);
return
false
;
return
false
;
}
}
cmMakefile
&
mf
=
status
.
GetMakefile
();
std
::
string
source
,
target
,
main_dependency
,
working
,
depfile
,
job_pool
;
std
::
string
source
,
target
,
main_dependency
,
working
,
depfile
,
job_pool
;
std
::
string
comment_buffer
;
std
::
string
comment_buffer
;
const
char
*
comment
=
nullptr
;
const
char
*
comment
=
nullptr
;
...
@@ -167,9 +169,9 @@ bool cmAddCustomCommandCommand::InitialPass(
...
@@ -167,9 +169,9 @@ bool cmAddCustomCommandCommand::InitialPass(
doing
=
doing_comment
;
doing
=
doing_comment
;
}
else
if
(
copy
==
keyDEPFILE
)
{
}
else
if
(
copy
==
keyDEPFILE
)
{
doing
=
doing_depfile
;
doing
=
doing_depfile
;
if
(
this
->
Makefile
->
GetGlobalGenerator
()
->
GetName
()
!=
"Ninja"
)
{
if
(
mf
.
GetGlobalGenerator
()
->
GetName
()
!=
"Ninja"
)
{
this
->
SetError
(
"Option DEPFILE not supported by "
+
status
.
SetError
(
"Option DEPFILE not supported by "
+
this
->
Makefile
->
GetGlobalGenerator
()
->
GetName
());
mf
.
GetGlobalGenerator
()
->
GetName
());
return
false
;
return
false
;
}
}
}
else
if
(
copy
==
keyJOB_POOL
)
{
}
else
if
(
copy
==
keyJOB_POOL
)
{
...
@@ -192,7 +194,7 @@ bool cmAddCustomCommandCommand::InitialPass(
...
@@ -192,7 +194,7 @@ bool cmAddCustomCommandCommand::InitialPass(
// and later references "${CMAKE_CURRENT_SOURCE_DIR}/out.txt".
// and later references "${CMAKE_CURRENT_SOURCE_DIR}/out.txt".
// This is fairly obscure so we can wait for someone to
// This is fairly obscure so we can wait for someone to
// complain.
// complain.
filename
=
this
->
Makefile
->
GetCurrentBinaryDirectory
();
filename
=
mf
.
GetCurrentBinaryDirectory
();
filename
+=
"/"
;
filename
+=
"/"
;
}
}
filename
+=
copy
;
filename
+=
copy
;
...
@@ -269,7 +271,7 @@ bool cmAddCustomCommandCommand::InitialPass(
...
@@ -269,7 +271,7 @@ bool cmAddCustomCommandCommand::InitialPass(
comment
=
comment_buffer
.
c_str
();
comment
=
comment_buffer
.
c_str
();
break
;
break
;
default:
default:
this
->
SetError
(
"Wrong syntax. Unknown type of argument."
);
status
.
SetError
(
"Wrong syntax. Unknown type of argument."
);
return
false
;
return
false
;
}
}
}
}
...
@@ -284,31 +286,31 @@ bool cmAddCustomCommandCommand::InitialPass(
...
@@ -284,31 +286,31 @@ bool cmAddCustomCommandCommand::InitialPass(
// At this point we could complain about the lack of arguments. For
// At this point we could complain about the lack of arguments. For
// the moment, let's say that COMMAND, TARGET are always required.
// the moment, let's say that COMMAND, TARGET are always required.
if
(
output
.
empty
()
&&
target
.
empty
())
{
if
(
output
.
empty
()
&&
target
.
empty
())
{
this
->
SetError
(
"Wrong syntax. A TARGET or OUTPUT must be specified."
);
status
.
SetError
(
"Wrong syntax. A TARGET or OUTPUT must be specified."
);
return
false
;
return
false
;
}
}
if
(
source
.
empty
()
&&
!
target
.
empty
()
&&
!
output
.
empty
())
{
if
(
source
.
empty
()
&&
!
target
.
empty
()
&&
!
output
.
empty
())
{
this
->
SetError
(
status
.
SetError
(
"Wrong syntax. A TARGET and OUTPUT can not both be specified."
);
"Wrong syntax. A TARGET and OUTPUT can not both be specified."
);
return
false
;
return
false
;
}
}
if
(
append
&&
output
.
empty
())
{
if
(
append
&&
output
.
empty
())
{
this
->
SetError
(
"given APPEND option with no OUTPUT."
);
status
.
SetError
(
"given APPEND option with no OUTPUT."
);
return
false
;
return
false
;
}
}
// Make sure the output names and locations are safe.
// Make sure the output names and locations are safe.
if
(
!
this
->
CheckOutputs
(
output
)
||
!
this
->
CheckOutputs
(
outputs
)
||
if
(
!
cmAddCustomCommandCommandCheckOutputs
(
output
,
status
)
||
!
this
->
CheckOutputs
(
byproducts
))
{
!
cmAddCustomCommandCommandCheckOutputs
(
outputs
,
status
)
||
!
cmAddCustomCommandCommandCheckOutputs
(
byproducts
,
status
))
{
return
false
;
return
false
;
}
}
// Check for an append request.
// Check for an append request.
if
(
append
)
{
if
(
append
)
{
// Lookup an existing command.
// Lookup an existing command.
if
(
cmSourceFile
*
sf
=
if
(
cmSourceFile
*
sf
=
mf
.
GetSourceFileWithOutput
(
output
[
0
]))
{
this
->
Makefile
->
GetSourceFileWithOutput
(
output
[
0
]))
{
if
(
cmCustomCommand
*
cc
=
sf
->
GetCustomCommand
())
{
if
(
cmCustomCommand
*
cc
=
sf
->
GetCustomCommand
())
{
cc
->
AppendCommands
(
commandLines
);
cc
->
AppendCommands
(
commandLines
);
cc
->
AppendDepends
(
depends
);
cc
->
AppendDepends
(
depends
);
...
@@ -321,12 +323,12 @@ bool cmAddCustomCommandCommand::InitialPass(
...
@@ -321,12 +323,12 @@ bool cmAddCustomCommandCommand::InitialPass(
std
::
ostringstream
e
;
std
::
ostringstream
e
;
e
<<
"given APPEND option with output
\n\"
"
<<
output
[
0
]
e
<<
"given APPEND option with output
\n\"
"
<<
output
[
0
]
<<
"
\"\n
which is not already a custom command output."
;
<<
"
\"\n
which is not already a custom command output."
;
this
->
SetError
(
e
.
str
());
status
.
SetError
(
e
.
str
());
return
false
;
return
false
;
}
}
if
(
uses_terminal
&&
!
job_pool
.
empty
())
{
if
(
uses_terminal
&&
!
job_pool
.
empty
())
{
this
->
SetError
(
"JOB_POOL is shadowed by USES_TERMINAL."
);
status
.
SetError
(
"JOB_POOL is shadowed by USES_TERMINAL."
);
return
false
;
return
false
;
}
}
...
@@ -335,22 +337,21 @@ bool cmAddCustomCommandCommand::InitialPass(
...
@@ -335,22 +337,21 @@ bool cmAddCustomCommandCommand::InitialPass(
if
(
source
.
empty
()
&&
output
.
empty
())
{
if
(
source
.
empty
()
&&
output
.
empty
())
{
// Source is empty, use the target.
// Source is empty, use the target.
std
::
vector
<
std
::
string
>
no_depends
;
std
::
vector
<
std
::
string
>
no_depends
;
this
->
Makefile
->
AddCustomCommandToTarget
(
mf
.
AddCustomCommandToTarget
(
target
,
byproducts
,
no_depends
,
commandLines
,
target
,
byproducts
,
no_depends
,
commandLines
,
cctype
,
comment
,
cctype
,
comment
,
working
.
c_str
()
,
working
.
c_str
(),
escapeOldStyle
,
uses_terminal
,
depfile
,
job_pool
,
escapeOldStyle
,
uses_terminal
,
depfile
,
command_expand_lists
);
job_pool
,
command_expand_lists
);
}
else
if
(
target
.
empty
())
{
}
else
if
(
target
.
empty
())
{
// Target is empty, use the output.
// Target is empty, use the output.
this
->
Makefile
->
AddCustomCommandToOutput
(
mf
.
AddCustomCommandToOutput
(
output
,
byproducts
,
depends
,
main_dependency
,
output
,
byproducts
,
depends
,
main_dependency
,
commandLines
,
comment
,
commandLines
,
comment
,
working
.
c_str
(),
false
,
working
.
c_str
(),
false
,
escapeOldStyle
,
uses_terminal
,
escapeOldStyle
,
uses_terminal
,
command_expand_lists
,
depfile
,
job_pool
);
command_expand_lists
,
depfile
,
job_pool
);
// Add implicit dependency scanning requests if any were given.
// Add implicit dependency scanning requests if any were given.
if
(
!
implicit_depends
.
empty
())
{
if
(
!
implicit_depends
.
empty
())
{
bool
okay
=
false
;
bool
okay
=
false
;
if
(
cmSourceFile
*
sf
=
if
(
cmSourceFile
*
sf
=
mf
.
GetSourceFileWithOutput
(
output
[
0
]))
{
this
->
Makefile
->
GetSourceFileWithOutput
(
output
[
0
]))
{
if
(
cmCustomCommand
*
cc
=
sf
->
GetCustomCommand
())
{
if
(
cmCustomCommand
*
cc
=
sf
->
GetCustomCommand
())
{
okay
=
true
;
okay
=
true
;
cc
->
SetImplicitDepends
(
implicit_depends
);
cc
->
SetImplicitDepends
(
implicit_depends
);
...
@@ -360,21 +361,21 @@ bool cmAddCustomCommandCommand::InitialPass(
...
@@ -360,21 +361,21 @@ bool cmAddCustomCommandCommand::InitialPass(
std
::
ostringstream
e
;
std
::
ostringstream
e
;
e
<<
"could not locate source file with a custom command producing
\"
"
e
<<
"could not locate source file with a custom command producing
\"
"
<<
output
[
0
]
<<
"
\"
even though this command tried to create it!"
;
<<
output
[
0
]
<<
"
\"
even though this command tried to create it!"
;
this
->
SetError
(
e
.
str
());
status
.
SetError
(
e
.
str
());
return
false
;
return
false
;
}
}
}
}
}
else
if
(
!
byproducts
.
empty
())
{
}
else
if
(
!
byproducts
.
empty
())
{
this
->
SetError
(
"BYPRODUCTS may not be specified with SOURCE signatures"
);
status
.
SetError
(
"BYPRODUCTS may not be specified with SOURCE signatures"
);
return
false
;
return
false
;
}
else
if
(
uses_terminal
)
{
}
else
if
(
uses_terminal
)
{
this
->
SetError
(
"USES_TERMINAL may not be used with SOURCE signatures"
);
status
.
SetError
(
"USES_TERMINAL may not be used with SOURCE signatures"
);
return
false
;
return
false
;
}
else
{
}
else
{
bool
issueMessage
=
true
;
bool
issueMessage
=
true
;
std
::
ostringstream
e
;
std
::
ostringstream
e
;
MessageType
messageType
=
MessageType
::
AUTHOR_WARNING
;
MessageType
messageType
=
MessageType
::
AUTHOR_WARNING
;
switch
(
this
->
Makefile
->
GetPolicyStatus
(
cmPolicies
::
CMP0050
))
{
switch
(
mf
.
GetPolicyStatus
(
cmPolicies
::
CMP0050
))
{
case
cmPolicies
:
:
WARN
:
case
cmPolicies
:
:
WARN
:
e
<<
cmPolicies
::
GetPolicyWarning
(
cmPolicies
::
CMP0050
)
<<
"
\n
"
;
e
<<
cmPolicies
::
GetPolicyWarning
(
cmPolicies
::
CMP0050
)
<<
"
\n
"
;
break
;
break
;
...
@@ -391,30 +392,31 @@ bool cmAddCustomCommandCommand::InitialPass(
...
@@ -391,30 +392,31 @@ bool cmAddCustomCommandCommand::InitialPass(
if
(
issueMessage
)
{
if
(
issueMessage
)
{
e
<<
"The SOURCE signatures of add_custom_command are no longer "
e
<<
"The SOURCE signatures of add_custom_command are no longer "
"supported."
;
"supported."
;
this
->
Makefile
->
IssueMessage
(
messageType
,
e
.
str
());
mf
.
IssueMessage
(
messageType
,
e
.
str
());
if
(
messageType
==
MessageType
::
FATAL_ERROR
)
{
if
(
messageType
==
MessageType
::
FATAL_ERROR
)
{
return
false
;
return
false
;
}
}
}
}
// Use the old-style mode for backward compatibility.
// Use the old-style mode for backward compatibility.
this
->
Makefile
->
AddCustomCommandOldStyle
(
target
,
outputs
,
depends
,
source
,
mf
.
AddCustomCommandOldStyle
(
target
,
outputs
,
depends
,
source
,
commandLines
,
commandLines
,
comment
);
comment
);
}
}
return
true
;
return
true
;
}
}
bool
cmAddCustomCommandCommand
::
CheckOutputs
(
bool
cmAddCustomCommandCommandCheckOutputs
(
const
std
::
vector
<
std
::
string
>&
outputs
)
const
std
::
vector
<
std
::
string
>&
outputs
,
cmExecutionStatus
&
status
)
{
{
cmMakefile
&
mf
=
status
.
GetMakefile
();
for
(
std
::
string
const
&
o
:
outputs
)
{
for
(
std
::
string
const
&
o
:
outputs
)
{
// Make sure the file will not be generated into the source
// Make sure the file will not be generated into the source
// directory during an out of source build.
// directory during an out of source build.
if
(
!
this
->
Makefile
->
CanIWriteThisFile
(
o
))
{
if
(
!
mf
.
CanIWriteThisFile
(
o
))
{
std
::
string
e
=
"attempted to have a file
\"
"
+
o
+
std
::
string
e
=
"attempted to have a file
\"
"
+
o
+
"
\"
in a source directory as an output of custom command."
;
"
\"
in a source directory as an output of custom command."
;
this
->
SetError
(
e
);
status
.
SetError
(
e
);
cmSystemTools
::
SetFatalErrorOccured
();
cmSystemTools
::
SetFatalErrorOccured
();
return
false
;
return
false
;
}
}
...
@@ -425,7 +427,7 @@ bool cmAddCustomCommandCommand::CheckOutputs(
...
@@ -425,7 +427,7 @@ bool cmAddCustomCommandCommand::CheckOutputs(
std
::
ostringstream
msg
;
std
::
ostringstream
msg
;
msg
<<
"called with OUTPUT containing a
\"
"
<<
o
[
pos
]
msg
<<
"called with OUTPUT containing a
\"
"
<<
o
[
pos
]
<<
"
\"
. This character is not allowed."
;
<<
"
\"
. This character is not allowed."
;
this
->
SetError
(
msg
.
str
());
status
.
SetError
(
msg
.
str
());
return
false
;
return
false
;
}
}
}
}
...
...
Source/cmAddCustomCommandCommand.h
View file @
9ba0bf60
...
@@ -8,38 +8,9 @@
...
@@ -8,38 +8,9 @@
#include <string>
#include <string>
#include <vector>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
class
cmExecutionStatus
;
class
cmExecutionStatus
;
/** \class cmAddCustomCommandCommand
bool
cmAddCustomCommandCommand
(
std
::
vector
<
std
::
string
>
const
&
args
,
* \brief cmAddCustomCommandCommand defines a new command (rule) that can
cmExecutionStatus
&
status
);
* be executed within the build process
*
*/
class
cmAddCustomCommandCommand
:
public
cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
std
::
unique_ptr
<
cmCommand
>
Clone
()
override
{
return
cm
::
make_unique
<
cmAddCustomCommandCommand
>
();
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
bool
InitialPass
(
std
::
vector
<
std
::
string
>
const
&
args
,
cmExecutionStatus
&
status
)
override
;
protected:
bool
CheckOutputs
(
const
std
::
vector
<
std
::
string
>&
outputs
);
};
#endif
#endif
Source/cmAddCustomTargetCommand.cxx
View file @
9ba0bf60
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include <utility>
#include <utility>
#include "cmCustomCommandLines.h"
#include "cmCustomCommandLines.h"
#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmMakefile.h"
...
@@ -14,17 +15,15 @@
...
@@ -14,17 +15,15 @@
#include "cmSystemTools.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTarget.h"
class
cmExecutionStatus
;
bool
cmAddCustomTargetCommand
(
std
::
vector
<
std
::
string
>
const
&
args
,
cmExecutionStatus
&
status
)
// cmAddCustomTargetCommand
bool
cmAddCustomTargetCommand
::
InitialPass
(
std
::
vector
<
std
::
string
>
const
&
args
,
cmExecutionStatus
&
)
{
{
if
(
args
.
empty
())
{
if
(
args
.
empty
())
{
this
->
SetError
(
"called with incorrect number of arguments"
);
status
.
SetError
(
"called with incorrect number of arguments"
);
return
false
;
return
false
;
}
}
cmMakefile
&
mf
=
status
.
GetMakefile
();
std
::
string
const
&
targetName
=
args
[
0
];
std
::
string
const
&
targetName
=
args
[
0
];
// Check the target name.
// Check the target name.
...
@@ -33,7 +32,7 @@ bool cmAddCustomTargetCommand::InitialPass(
...
@@ -33,7 +32,7 @@ bool cmAddCustomTargetCommand::InitialPass(
e
<<
"called with invalid target name
\"
"
<<
targetName
e
<<
"called with invalid target name
\"
"
<<
targetName
<<
"
\"
. Target names may not contain a slash. "
<<
"
\"
. Target names may not contain a slash. "
<<
"Use ADD_CUSTOM_COMMAND to generate files."
;
<<
"Use ADD_CUSTOM_COMMAND to generate files."
;
this
->
SetError
(
e
.
str
());
status
.
SetError
(
e
.
str
());
return
false
;
return
false
;
}
}
...
@@ -122,7 +121,7 @@ bool cmAddCustomTargetCommand::InitialPass(
...
@@ -122,7 +121,7 @@ bool cmAddCustomTargetCommand::InitialPass(
case
doing_byproducts
:
{
case
doing_byproducts
:
{
std
::
string
filename
;
std
::
string
filename
;
if
(
!
cmSystemTools
::
FileIsFullPath
(
copy
))
{
if
(
!
cmSystemTools
::
FileIsFullPath
(
copy
))
{
filename
=
this
->
Makefile
->
GetCurrentBinaryDirectory
();
filename
=
mf
.
GetCurrentBinaryDirectory
();
filename
+=
"/"
;
filename
+=
"/"
;
}
}
filename
+=
copy
;
filename
+=
copy
;
...
@@ -145,7 +144,7 @@ bool cmAddCustomTargetCommand::InitialPass(
...
@@ -145,7 +144,7 @@ bool cmAddCustomTargetCommand::InitialPass(
job_pool
=
copy
;
job_pool
=
copy
;
break
;
break
;
default:
default:
this
->
SetError
(
"Wrong syntax. Unknown type of argument."
);
status
.
SetError
(
"Wrong syntax. Unknown type of argument."
);
return
false
;
return
false
;
}
}
}
}
...
@@ -156,7 +155,7 @@ bool cmAddCustomTargetCommand::InitialPass(
...
@@ -156,7 +155,7 @@ bool cmAddCustomTargetCommand::InitialPass(
std
::
ostringstream
msg
;
std
::
ostringstream
msg
;
msg
<<
"called with target name containing a
\"
"
<<
targetName
[
pos
]
msg
<<
"called with target name containing a
\"
"
<<
targetName
[
pos
]
<<
"
\"
. This character is not allowed."
;
<<
"
\"
. This character is not allowed."
;
this
->
SetError
(
msg
.
str
());
status
.
SetError
(
msg
.
str
());
return
false
;
return
false
;
}
}
...
@@ -168,8 +167,7 @@ bool cmAddCustomTargetCommand::InitialPass(
...
@@ -168,8 +167,7 @@ bool cmAddCustomTargetCommand::InitialPass(
if
(
nameOk
)
{
if
(
nameOk
)
{
nameOk
=
targetName
.
find
(
':'
)
==
std
::
string
::
npos
;
nameOk
=
targetName
.
find
(
':'
)
==
std
::
string
::
npos
;
}
}
if
(
!
nameOk
&&
if
(
!
nameOk
&&
!
mf
.
CheckCMP0037
(
targetName
,
cmStateEnums
::
UTILITY
))
{
!
this
->
Makefile
->
CheckCMP0037
(
targetName
,
cmStateEnums
::
UTILITY
))
{
return
false
;
return
false
;
}
}
...
@@ -182,39 +180,37 @@ bool cmAddCustomTargetCommand::InitialPass(
...
@@ -182,39 +180,37 @@ bool cmAddCustomTargetCommand::InitialPass(
// Enforce name uniqueness.
// Enforce name uniqueness.
{
{
std
::
string
msg
;
std
::
string
msg
;
if
(
!
this
->
Makefile
->
EnforceUniqueName
(
targetName
,
msg
,
true
))
{
if
(
!
mf
.
EnforceUniqueName
(
targetName
,
msg
,
true
))
{
this
->
SetError
(
msg
);
status
.
SetError
(
msg
);
return
false
;
return
false
;
}
}
}
}
if
(
commandLines
.
empty
()
&&
!
byproducts
.
empty
())
{
if
(
commandLines
.
empty
()
&&
!
byproducts
.
empty
())
{
this
->
Makefile
->
IssueMessage
(
mf
.
IssueMessage
(
MessageType
::
FATAL_ERROR
,
MessageType
::
FATAL_ERROR
,
"BYPRODUCTS may not be specified without any COMMAND"
);
"BYPRODUCTS may not be specified without any COMMAND"
);
return
true
;
return
true
;
}
}
if
(
commandLines
.
empty
()
&&
uses_terminal
)
{
if
(
commandLines
.
empty
()
&&
uses_terminal
)
{
this
->
Makefile
->
IssueMessage
(
mf
.
IssueMessage
(
MessageType
::
FATAL_ERROR
,
MessageType
::
FATAL_ERROR
,
"USES_TERMINAL may not be specified without any COMMAND"
);
"USES_TERMINAL may not be specified without any COMMAND"
);
return
true
;
return
true
;
}
}
if
(
commandLines
.
empty
()
&&
command_expand_lists
)
{
if
(
commandLines
.
empty
()
&&
command_expand_lists
)
{
this
->
Makefile
->
IssueMessage
(
mf
.
IssueMessage
(
MessageType
::
FATAL_ERROR
,
MessageType
::
FATAL_ERROR
,
"COMMAND_EXPAND_LISTS may not be specified without any COMMAND"
);
"COMMAND_EXPAND_LISTS may not be specified without any COMMAND"
);
return
true
;
return
true
;
}
}
if
(
uses_terminal
&&
!
job_pool
.
empty
())
{
if
(
uses_terminal
&&
!
job_pool
.
empty
())
{
this
->
SetError
(
"JOB_POOL is shadowed by USES_TERMINAL."
);
status
.
SetError
(
"JOB_POOL is shadowed by USES_TERMINAL."
);
return
false
;
return
false
;
}
}
// Add the utility target to the makefile.
// Add the utility target to the makefile.
bool
escapeOldStyle
=
!
verbatim
;
bool
escapeOldStyle
=
!
verbatim
;
cmTarget
*
target
=
this
->
Makefile
->
AddUtilityCommand
(
cmTarget
*
target
=
mf
.
AddUtilityCommand
(
targetName
,
cmMakefile
::
TargetOrigin
::
Project
,
excludeFromAll
,
targetName
,
cmMakefile
::
TargetOrigin
::
Project
,
excludeFromAll
,
working_directory
.
c_str
(),
byproducts
,
depends
,
commandLines
,
working_directory
.
c_str
(),
byproducts
,
depends
,
commandLines
,
escapeOldStyle
,
comment
,
uses_terminal
,
command_expand_lists
,
job_pool
);
escapeOldStyle
,
comment
,
uses_terminal
,
command_expand_lists
,
job_pool
);
...
...
Source/cmAddCustomTargetCommand.h
View file @
9ba0bf60
...
@@ -8,36 +8,9 @@
...
@@ -8,36 +8,9 @@
#include <string>
#include <string>
#include <vector>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
class
cmExecutionStatus
;
class
cmExecutionStatus
;
/** \class cmAddCustomTargetCommand
bool
cmAddCustomTargetCommand
(
std
::
vector
<
std
::
string
>
const
&
args
,
* \brief Command that adds a target to the build system.
cmExecutionStatus
&
status
);
*
* cmAddCustomTargetCommand adds an extra target to the build system.
* This is useful when you would like to add special
* targets like "install,", "clean," and so on.
*/
class
cmAddCustomTargetCommand
:
public
cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
std
::
unique_ptr
<
cmCommand
>
Clone
()
override
{