Skip to content

Commit

Permalink
Move CMAKE_POSITION_INDEPENDENT_CODE to CMakeCommon and disable -pie. F…
Browse files Browse the repository at this point in the history
…ixes indilib#1504
  • Loading branch information
knro committed Jun 29, 2021
1 parent 90a87d9 commit 7fb682d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ PROJECT(libindi C CXX)
# to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Build Position Independent Code
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules/")
include(GNUInstallDirs)
Expand Down
7 changes: 3 additions & 4 deletions cmake_modules/CMakeCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ include(CheckCCompilerFlag)
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#ENDIF ()

# Build Position Independent Code
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# C++14 Support
if (NOT ANDROID)
set(CMAKE_CXX_STANDARD 14)
Expand Down Expand Up @@ -33,7 +36,6 @@ IF (UNIX OR APPLE OR ANDROID)
IF (${COMPATIBLE_FORTIFY_SOURCE})
SET(SEC_COMP_FLAGS "-D_FORTIFY_SOURCE=2")
ENDIF ()
SET(SEC_COMP_FLAGS "${SEC_COMP_FLAGS} -fstack-protector-all -fPIE")
# Make sure to add optimization flag. Some systems require this for _FORTIFY_SOURCE.
IF (NOT CMAKE_BUILD_TYPE MATCHES "MinSizeRel" AND NOT CMAKE_BUILD_TYPE MATCHES "Release" AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
SET(SEC_COMP_FLAGS "${SEC_COMP_FLAGS} -O1")
Expand All @@ -47,9 +49,6 @@ IF (UNIX OR APPLE OR ANDROID)
IF (NOT APPLE AND NOT CYGWIN AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
SET(SEC_LINK_FLAGS "${SEC_LINK_FLAGS} -Wl,-z,nodump -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
ENDIF ()
IF (NOT ANDROID AND NOT APPLE)
SET(SEC_LINK_FLAGS "${SEC_LINK_FLAGS} -pie")
ENDIF ()
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SEC_LINK_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SEC_LINK_FLAGS}")
ENDIF ()
Expand Down

0 comments on commit 7fb682d

Please sign in to comment.