Re-enable position independent code, but in a portable way.
CMake 2.8.9 introduce a `POSITION_INDEPENDENT_CODE` property.
This sets `-fPIE` on executables, giving us back optimizations such as
inlining of global variables and functions, while setting `-fPIC` on
libraries.
Although we do not need position independent code on executables, it
seems like some gcc versions (like 4.9.2) have issues in combinations
with `_FORTIFY_SOURCE`.
On shared libraries, CMake should per documentation even use position
independent code by default.
References:
- http://www.cmake.org/cmake/help/v3.0/prop_tgt/POSITION_INDEPENDENT_CODE.html#prop_tgt:POSITION_INDEPENDENT_CODE
- http://public.kitware.com/pipermail/cmake-developers/2012-May/015839.html
- https://github.com/Project-OSRM/osrm-backend/pull/1647
- cae59c7395
This commit is contained in:
parent
57e522065a
commit
c5064710a8
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
cmake_minimum_required(VERSION 2.8.9)
|
||||
|
||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND NOT MSVC_IDE)
|
||||
message(FATAL_ERROR "In-source builds are not allowed.
|
||||
@ -371,6 +371,12 @@ set_property(TARGET osrm-prepare PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
set_property(TARGET osrm-datastore PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
set_property(TARGET osrm-routed PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
set_property(TARGET OSRM PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
set_property(TARGET osrm-extract PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
set_property(TARGET osrm-prepare PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
set_property(TARGET osrm-datastore PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
set_property(TARGET osrm-routed PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
install(FILES ${InstallGlob} DESTINATION include/osrm)
|
||||
install(FILES ${VariantGlob} DESTINATION include/variant)
|
||||
install(TARGETS osrm-extract DESTINATION bin)
|
||||
|
Loading…
Reference in New Issue
Block a user