Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
3b6d8b8f
Commit
3b6d8b8f
authored
Apr 06, 2009
by
dt
Browse files
Add the ability to add Runconfigurations for cmake-targets we know about
Task: 250415
parent
6a55ca97
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/cmakeprojectmanager/cmakeproject.cpp
View file @
3b6d8b8f
...
...
@@ -207,30 +207,30 @@ void CMakeProject::parseCMakeLists()
// Create run configurations for m_targets
//qDebug()<<"Create run configurations of m_targets";
QMap
<
QString
,
QSharedPointer
<
CMakeRunConfiguration
>
>
existingRunConfigurations
;
QM
ultiM
ap
<
QString
,
QSharedPointer
<
CMakeRunConfiguration
>
>
existingRunConfigurations
;
foreach
(
QSharedPointer
<
ProjectExplorer
::
RunConfiguration
>
cmakeRunConfiguration
,
runConfigurations
())
{
if
(
QSharedPointer
<
CMakeRunConfiguration
>
rc
=
cmakeRunConfiguration
.
dynamicCast
<
CMakeRunConfiguration
>
())
{
existingRunConfigurations
.
insert
(
rc
->
title
(),
rc
);
}
}
bool
setActive
=
false
;
bool
setActive
=
existingRunConfigurations
.
isEmpty
()
;
foreach
(
const
CMakeTarget
&
ct
,
m_targets
)
{
if
(
ct
.
executable
.
isEmpty
())
continue
;
if
(
ct
.
title
.
endsWith
(
"/fast"
))
continue
;
QMap
<
QString
,
QSharedPointer
<
CMakeRunConfiguration
>
>::
iterator
it
=
existingRunConfigurations
.
find
(
ct
.
title
);
if
(
it
!=
existingRunConfigurations
.
end
())
{
QList
<
QSharedPointer
<
CMakeRunConfiguration
>
>
list
=
existingRunConfigurations
.
values
(
ct
.
title
);
if
(
!
list
.
isEmpty
())
{
// Already exists, so override the settings...
QSharedPointer
<
CMakeRunConfiguration
>
rc
=
it
.
value
();
//qDebug()<<"Updating Run Configuration with title"<<ct.title;
//qDebug()<<" Executable new:"<<ct.executable<< "old:"<<rc->executable();
//qDebug()<<" WD new:"<<ct.workingDirectory<<"old:"<<rc->workingDirectory();
rc
->
setExecutable
(
ct
.
executable
);
rc
->
setWorkingDirectory
(
ct
.
workingDirectory
);
existingRunConfigurations
.
erase
(
it
);
foreach
(
QSharedPointer
<
CMakeRunConfiguration
>
rc
,
list
)
{
//qDebug()<<"Updating Run Configuration with title"<<ct.title;
//qDebug()<<" Executable new:"<<ct.executable<< "old:"<<rc->executable();
//qDebug()<<" WD new:"<<ct.workingDirectory<<"old:"<<rc->workingDirectory();
rc
->
setExecutable
(
ct
.
executable
);
rc
->
setWorkingDirectory
(
ct
.
workingDirectory
);
}
existingRunConfigurations
.
remove
(
ct
.
title
);
}
else
{
// Does not exist yet
//qDebug()<<"Adding new run configuration with title"<<ct.title;
...
...
@@ -238,13 +238,13 @@ void CMakeProject::parseCMakeLists()
QSharedPointer
<
ProjectExplorer
::
RunConfiguration
>
rc
(
new
CMakeRunConfiguration
(
this
,
ct
.
executable
,
ct
.
workingDirectory
,
ct
.
title
));
addRunConfiguration
(
rc
);
// The first one gets the honour of beeing the active one
if
(
!
setActive
)
{
if
(
setActive
)
{
setActiveRunConfiguration
(
rc
);
setActive
=
tru
e
;
setActive
=
fals
e
;
}
}
}
QMap
<
QString
,
QSharedPointer
<
CMakeRunConfiguration
>
>::
const_iterator
it
=
QM
ultiM
ap
<
QString
,
QSharedPointer
<
CMakeRunConfiguration
>
>::
const_iterator
it
=
existingRunConfigurations
.
constBegin
();
for
(
;
it
!=
existingRunConfigurations
.
constEnd
();
++
it
)
{
QSharedPointer
<
CMakeRunConfiguration
>
rc
=
it
.
value
();
...
...
@@ -282,8 +282,13 @@ QString CMakeProject::buildParser(const QString &buildConfiguration) const
QStringList
CMakeProject
::
targets
()
const
{
QStringList
results
;
foreach
(
const
CMakeTarget
&
ct
,
m_targets
)
foreach
(
const
CMakeTarget
&
ct
,
m_targets
)
{
if
(
ct
.
executable
.
isEmpty
())
continue
;
if
(
ct
.
title
.
endsWith
(
"/fast"
))
continue
;
results
<<
ct
.
title
;
}
return
results
;
}
...
...
@@ -526,6 +531,14 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
parseCMakeLists
();
// Gets the directory from the active buildconfiguration
}
CMakeTarget
CMakeProject
::
targetForTitle
(
const
QString
&
title
)
{
foreach
(
const
CMakeTarget
&
ct
,
m_targets
)
if
(
ct
.
title
==
title
)
return
ct
;
return
CMakeTarget
();
}
CMakeFile
::
CMakeFile
(
CMakeProject
*
parent
,
QString
fileName
)
:
Core
::
IFile
(
parent
),
m_project
(
parent
),
m_fileName
(
fileName
)
{
...
...
src/plugins/cmakeprojectmanager/cmakeproject.h
View file @
3b6d8b8f
...
...
@@ -101,6 +101,7 @@ public:
MakeStep
*
makeStep
()
const
;
QStringList
targets
()
const
;
QString
buildParser
(
const
QString
&
buildConfiguration
)
const
;
CMakeTarget
targetForTitle
(
const
QString
&
title
);
protected:
virtual
void
saveSettingsImpl
(
ProjectExplorer
::
PersistentSettingsWriter
&
writer
);
...
...
src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp
View file @
3b6d8b8f
...
...
@@ -168,8 +168,11 @@ QStringList CMakeRunConfigurationFactory::canCreate(ProjectExplorer::Project *pr
CMakeProject
*
pro
=
qobject_cast
<
CMakeProject
*>
(
project
);
if
(
!
pro
)
return
QStringList
();
// TODO gather all targets and return them here
return
QStringList
();
QStringList
allTargets
=
pro
->
targets
();
for
(
int
i
=
0
;
i
<
allTargets
.
size
();
++
i
)
{
allTargets
[
i
]
=
Constants
::
CMAKERUNCONFIGURATION
+
allTargets
[
i
];
}
return
allTargets
;
}
// used to translate the types to names to display to the user
...
...
@@ -193,9 +196,9 @@ QSharedPointer<ProjectExplorer::RunConfiguration> CMakeRunConfigurationFactory::
return
rc
;
}
else
{
// Adding new
// TODO extract target from type
QString
file
=
type
.
mid
(
QString
(
Constants
::
CMAKERUNCONFIGURATION
).
length
()
);
QSharedPointer
<
ProjectExplorer
::
RunConfiguration
>
rc
(
new
CMakeRunConfiguration
(
pro
,
file
,
QString
::
null
,
QString
::
null
));
const
QString
title
=
type
.
mid
(
QString
(
Constants
::
CMAKERUNCONFIGURATION
).
length
());
const
CMakeTarget
&
ct
=
pro
->
targetForTitle
(
title
);
QSharedPointer
<
ProjectExplorer
::
RunConfiguration
>
rc
(
new
CMakeRunConfiguration
(
pro
,
ct
.
executable
,
ct
.
workingDirectory
,
ct
.
title
));
return
rc
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment