MantisBT - CMake
View Issue Details
0016002CMakeCMakepublic2016-03-02 09:052016-06-10 14:31
Jordan 
Kitware Robot 
normalblockalways
closedmoved 
 
 
0016002: CMake strips -fPIC from executable compilation which blocks the use of Qt5 and GCC5
I understand this case https://cmake.org/Bug/view.php?id=9659. [^]
However, Qt5 and GCC 5 are now forcing fPIC on all compilation.
I have brought this to QT's attention with https://bugreports.qt.io/browse/QTBUG-51593, [^] but they say the policy will not change.
As far as I can tell there is no way to apply fPIC to the executable.
It appears to be stripped from the CMAKE_CXX_FLAGS.
This blocks the use of Qt5 and GCC5.
Take prebuild Qt-5.4.1 or new.
Use GCC-5 or newer.
No tags attached.
Issue History
2016-03-02 09:05JordanNew Issue
2016-03-02 09:25Clinton StimpsonNote Added: 0040588
2016-03-02 10:16JordanNote Added: 0040589
2016-06-10 14:29Kitware RobotNote Added: 0042954
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0040588)
Clinton Stimpson   
2016-03-02 09:25   
This snippet from Qt5CoreConfigExtras.cmake which is part of a Qt5 installation may be relevant.


# Targets using Qt need to use the POSITION_INDEPENDENT_CODE property. The
# Qt5_POSITION_INDEPENDENT_CODE variable is used in the # qt5_use_module
# macro to add it.
set(Qt5_POSITION_INDEPENDENT_CODE True)
set(Qt5Core_EXECUTABLE_COMPILE_FLAGS "-fPIC")
if (CMAKE_VERSION VERSION_LESS 2.8.12
        AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
        OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
    set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE "ON")
else()
    set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_OPTIONS -fPIC)
endif()
(0040589)
Jordan   
2016-03-02 10:16   
I use SET(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "") and I SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILEFLAGS}" CACHE BOOL "" FORCE)
neither works.
(0042954)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.