cmake: fix -fPIC/-fPIE handling in precompiled headers (PCH)

pull/10394/head
Alexander Alekhin 7 years ago
parent 09c84a0164
commit 6c252d8cdc
  1. 18
      cmake/OpenCVPCHSupport.cmake

@ -261,6 +261,24 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
endif()
endif()
if(type STREQUAL "SHARED_LIBRARY" OR type STREQUAL "STATIC_LIBRARY")
get_target_property(__pic ${_targetName} POSITION_INDEPENDENT_CODE)
if(__pic AND CMAKE_CXX_COMPILE_OPTIONS_PIC
AND NOT OPENCV_SKIP_PCH_PIC_HANDLING
AND NOT OPENCV_SKIP_PCH_PIC_HANDLING_${_targetName}
)
list(APPEND _compile_FLAGS "${CMAKE_CXX_COMPILE_OPTIONS_PIC}")
endif()
elseif(type STREQUAL "EXECUTABLE")
get_target_property(__pie ${_targetName} POSITION_INDEPENDENT_CODE)
if(__pie AND CMAKE_CXX_COMPILE_OPTIONS_PIE
AND NOT OPENCV_SKIP_PCH_PIE_HANDLING
AND NOT OPENCV_SKIP_PCH_PIE_HANDLING_${_targetName}
)
list(APPEND _compile_FLAGS "${CMAKE_CXX_COMPILE_OPTIONS_PIE}")
endif()
endif()
get_target_property(DIRINC ${_targetName} INCLUDE_DIRECTORIES)
set_target_properties(${_targetName}_pch_dephelp PROPERTIES INCLUDE_DIRECTORIES "${DIRINC}")

Loading…
Cancel
Save