Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Marc Chevrier
CMake
Commits
72edfe80
Commit
72edfe80
authored
Jan 25, 2019
by
Marc Chevrier
Browse files
XCode generator: Manage 'GCC_DYNAMIC_NO_PIC' attribute
parent
0d8d7a68
Changes
5
Hide whitespace changes
Inline
Side-by-side
Source/cmGeneratorTarget.cxx
View file @
72edfe80
...
...
@@ -497,6 +497,26 @@ const char* cmGeneratorTarget::GetFeature(const std::string& feature,
return
this
->
LocalGenerator
->
GetFeature
(
feature
,
config
);
}
const
char
*
cmGeneratorTarget
::
GetCompilePICProperty
(
const
std
::
string
&
config
)
const
{
if
(
this
->
GetType
()
==
cmStateEnums
::
OBJECT_LIBRARY
)
{
return
this
->
GetProperty
(
"POSITION_INDEPENDENT_CODE"
);
}
else
{
static
std
::
string
PICValue
;
PICValue
=
this
->
GetLinkInterfaceDependentStringAsBoolProperty
(
"POSITION_INDEPENDENT_CODE"
,
config
);
if
(
PICValue
==
"(unset)"
)
{
// POSITION_INDEPENDENT_CODE is not set
return
nullptr
;
}
else
{
return
PICValue
.
c_str
();
}
}
}
const
char
*
cmGeneratorTarget
::
GetLinkPIEProperty
(
const
std
::
string
&
config
)
const
{
...
...
Source/cmGeneratorTarget.h
View file @
72edfe80
...
...
@@ -170,6 +170,7 @@ public:
const
char
*
GetFeature
(
const
std
::
string
&
feature
,
const
std
::
string
&
config
)
const
;
const
char
*
GetCompilePICProperty
(
const
std
::
string
&
config
)
const
;
const
char
*
GetLinkPIEProperty
(
const
std
::
string
&
config
)
const
;
bool
IsIPOEnabled
(
std
::
string
const
&
lang
,
std
::
string
const
&
config
)
const
;
...
...
Source/cmGlobalXCodeGenerator.cxx
View file @
72edfe80
...
...
@@ -1771,6 +1771,21 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
}
}
void
cmGlobalXCodeGenerator
::
AddPositionIndependentCompileAttribute
(
cmGeneratorTarget
*
target
,
cmXCodeObject
*
buildSettings
,
const
std
::
string
&
configName
)
{
const
char
*
PICValue
=
target
->
GetCompilePICProperty
(
configName
);
if
(
PICValue
==
nullptr
)
{
// POSITION_INDEPENDENT_CODE is not set
return
;
}
buildSettings
->
AddAttribute
(
"GCC_DYNAMIC_NO_PIC"
,
this
->
CreateString
(
cmSystemTools
::
IsOn
(
PICValue
)
?
"NO"
:
"YES"
));
}
void
cmGlobalXCodeGenerator
::
AddPositionIndependentLinkAttribute
(
cmGeneratorTarget
*
target
,
cmXCodeObject
*
buildSettings
,
const
std
::
string
&
configName
)
...
...
@@ -1827,6 +1842,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
configName
);
}
// Handle PIC compiler configuration
this
->
AddPositionIndependentCompileAttribute
(
gtgt
,
buildSettings
,
configName
);
std
::
string
llang
=
gtgt
->
GetLinkerLanguage
(
configName
);
if
(
binary
&&
llang
.
empty
())
{
cmSystemTools
::
Error
(
...
...
Source/cmGlobalXCodeGenerator.h
View file @
72edfe80
...
...
@@ -171,6 +171,9 @@ private:
const
std
::
string
&
configName
);
cmXCodeObject
*
CreateUtilityTarget
(
cmGeneratorTarget
*
gtgt
);
void
AddDependAndLinkInformation
(
cmXCodeObject
*
target
);
void
AddPositionIndependentCompileAttribute
(
cmGeneratorTarget
*
target
,
cmXCodeObject
*
buildSettings
,
const
std
::
string
&
configName
);
void
AddPositionIndependentLinkAttribute
(
cmGeneratorTarget
*
target
,
cmXCodeObject
*
buildSettings
,
const
std
::
string
&
configName
);
...
...
Tests/RunCMake/PositionIndependentCode/Debug.cmake
View file @
72edfe80
add_library
(
iface INTERFACE
)
set_property
(
TARGET iface PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE
ON
)
set_property
(
TARGET iface PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE
TRUE
)
set
(
CMAKE_DEBUG_TARGET_PROPERTIES POSITION_INDEPENDENT_CODE
)
add_library
(
foo main.cpp
)
target_link_libraries
(
foo iface
)
set_property
(
TARGET foo PROPERTY POSITION_INDEPENDENT_CODE
ON
)
set_property
(
TARGET foo PROPERTY POSITION_INDEPENDENT_CODE
TRUE
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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