diff --git a/CMakeLists.txt b/CMakeLists.txt index 1288473..ed8a818 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) include(CheckPIESupported) check_pie_supported(LANGUAGES CXX) +set(USER_DEFINED_PIE (DEFINED CMAKE_POSITION_INDEPENDENT_CODE)) if (CMAKE_CXX_LINK_PIE_SUPPORTED) - if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) + if (NOT USER_DEFINED_PIE) set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) endif() else() @@ -161,6 +162,9 @@ if (NOT (UPPERCASE_BUILD_TYPE STREQUAL "DEBUG" OR UPPERCASE_BUILD_TYPE STREQUAL include(FindSelfPackers) if (SELF_PACKER_FOR_EXECUTABLE MATCHES upx) # UPX version d61edc9 or higher is required when using a cross-compiler to target the musl C library set(SELF_PACKER_FOR_EXECUTABLE_FLAGS ${SELF_PACKER_FOR_EXECUTABLE_FLAGS} --ultra-brute --best) + if (USER_DEFINED_PIE AND CMAKE_POSITION_INDEPENDENT_CODE) + message(NOTICE "-- Could NOT manually enable PIE (UPX is in use)") + endif() set(CMAKE_POSITION_INDEPENDENT_CODE FALSE) set_target_properties(${EXENAME} PROPERTIES POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE}) endif()