diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 489b2825e79..2f5e2dd4183 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,6 +1,6 @@ # BAREOS® - Backup Archiving REcovery Open Sourced # -# Copyright (C) 2017-2022 Bareos GmbH & Co. KG +# Copyright (C) 2017-2023 Bareos GmbH & Co. KG # # This program is Free Software; you can redistribute it and/or # modify it under the terms of version three of the GNU Affero General Public @@ -46,6 +46,11 @@ endif(CCACHE_FOUND) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +# enable PIC/PIE by default +include(CheckPIESupported) +check_pie_supported() +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + option(ENABLE_SANITIZERS "Build with ASan/LSan/UBSan enabled" OFF) if(ENABLE_SANITIZERS) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/core/src/droplet/libdroplet/CMakeLists.txt b/core/src/droplet/libdroplet/CMakeLists.txt index 52792cbc8e4..4be7186709b 100644 --- a/core/src/droplet/libdroplet/CMakeLists.txt +++ b/core/src/droplet/libdroplet/CMakeLists.txt @@ -1,6 +1,6 @@ # BAREOS® - Backup Archiving REcovery Open Sourced # -# Copyright (C) 2020-2022 Bareos GmbH & Co. KG +# Copyright (C) 2020-2023 Bareos GmbH & Co. KG # # This program is Free Software; you can redistribute it and/or # modify it under the terms of version three of the GNU Affero General Public @@ -110,7 +110,6 @@ bareos_disable_warnings( C_ONLY ADD_FOR_LTO ) -set_property(TARGET droplet PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories( droplet PUBLIC include ${LIBXML2_INCLUDE_DIR} ${JSONC_INCLUDE_DIRS} diff --git a/core/src/lib/CMakeLists.txt b/core/src/lib/CMakeLists.txt index 09906b8464e..7faec1fc1fe 100644 --- a/core/src/lib/CMakeLists.txt +++ b/core/src/lib/CMakeLists.txt @@ -1,6 +1,6 @@ # BAREOS® - Backup Archiving REcovery Open Sourced # -# Copyright (C) 2017-2022 Bareos GmbH & Co. KG +# Copyright (C) 2017-2023 Bareos GmbH & Co. KG # # This program is Free Software; you can redistribute it and/or # modify it under the terms of version three of the GNU Affero General Public @@ -151,7 +151,6 @@ target_compile_definitions( -DBAREOS_PROG_DATE_TIME="${BAREOS_PROG_DATE_TIME}" -DBAREOS_YEAR="${BAREOS_YEAR}" ) -set_target_properties(version-obj PROPERTIES POSITION_INDEPENDENT_CODE ON) target_link_libraries( bareos diff --git a/core/src/stored/backends/CMakeLists.txt b/core/src/stored/backends/CMakeLists.txt index 20598b3887f..abe21813f58 100644 --- a/core/src/stored/backends/CMakeLists.txt +++ b/core/src/stored/backends/CMakeLists.txt @@ -29,7 +29,6 @@ macro(add_sd_backend backend_name) add_library(${backend_name} OBJECT) target_link_libraries(bareossd PRIVATE ${backend_name}) endif() - set_property(TARGET ${backend_name} PROPERTY POSITION_INDEPENDENT_CODE ON) endmacro() if(${HAVE_GLUSTERFS}) @@ -70,9 +69,6 @@ endif() if(HAVE_DYNAMIC_SD_BACKENDS) add_library(bareossd-autochanger_test MODULE) - set_property( - TARGET bareossd-autochanger_test PROPERTY POSITION_INDEPENDENT_CODE ON - ) target_sources( bareossd-autochanger_test PRIVATE autochanger_test_device.cc unix_file_device.cc