Enable position independent code by default

Add a build option (--disable-pic, wxBUILD_PIC=OFF) to disable it.

Note that it is always enabled for shared libraries and static third party libraries.
This commit is contained in:
Maarten Bent
2020-08-05 20:04:05 +02:00
parent 3328480f78
commit 4ee04daa7c
4 changed files with 73 additions and 10 deletions

View File

@@ -83,6 +83,10 @@ function(wx_set_common_target_properties target_name)
RUNTIME_OUTPUT_DIRECTORY "${wxOUTPUT_DIR}${wxPLATFORM_LIB_DIR}"
)
if(wxBUILD_PIC)
set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
endif()
if(MSVC)
if(wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
set(MSVC_WARNING_LEVEL "/W3")
@@ -498,6 +502,10 @@ function(wx_set_builtin_target_properties target_name)
set_target_properties(${target_name} PROPERTIES FOLDER "Third Party Libraries")
if(wxBUILD_SHARED OR wxBUILD_PIC)
set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
endif()
wx_set_common_target_properties(${target_name} DEFAULT_WARNINGS)
if(NOT wxBUILD_SHARED)
wx_install(TARGETS ${name} ARCHIVE DESTINATION "lib${wxPLATFORM_LIB_DIR}")
@@ -518,9 +526,6 @@ function(wx_add_builtin_library name)
add_library(wx::${name_short} ALIAS ${name})
wx_set_builtin_target_properties(${name})
set_target_properties(${name} PROPERTIES PROJECT_LABEL ${name_short})
if(wxBUILD_SHARED)
set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
endif()
endfunction()
# List of third party libraries added via wx_add_thirdparty_library()