From 6f96a685080c4809e23c25525d78dd8f6d2a713b Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 30 Sep 2022 14:25:32 +0400 Subject: [PATCH] Revert "Move more compiler options to DESKTOP_APP_SPECIAL_TARGET condition" This reverts commit 32257877e0a6ce4561896f5ba009b08de4d93ad8. --- options_linux.cmake | 62 +++++++++++++++++++++++---------------------- options_mac.cmake | 25 +++++++++--------- variables.cmake | 4 --- 3 files changed, 45 insertions(+), 46 deletions(-) diff --git a/options_linux.cmake b/options_linux.cmake index 2fdaafeb..00657504 100644 --- a/options_linux.cmake +++ b/options_linux.cmake @@ -6,11 +6,32 @@ target_compile_options(common_options INTERFACE - $<$>:-fno-strict-aliasing> + $,,-fno-strict-aliasing> +) + +target_compile_options_if_exists(common_options +INTERFACE + -fstack-protector-all + -fstack-clash-protection + -fPIC + -pipe + -Wall + -Wextra + -Wno-unused-parameter + -Wno-switch + -Wno-maybe-uninitialized + -Wno-missing-field-initializers + -Wno-sign-compare -Wno-deprecated # implicit capture of 'this' via '[=]' is deprecated in C++20 -Wno-deprecated-declarations # TODO: Remove when there will be no Qt 5 support ) +target_compile_definitions(common_options +INTERFACE + $,,_FORTIFY_SOURCE=2> + _GLIBCXX_ASSERTIONS +) + target_link_options_if_exists(common_options INTERFACE -pthread @@ -20,40 +41,17 @@ INTERFACE if (DESKTOP_APP_SPECIAL_TARGET) target_compile_options(common_options INTERFACE - $<$>:-Ofast> - $<$>:-g> - $<$>:-flto> - ) - target_compile_options_if_exists(common_options - INTERFACE - -fstack-protector-all - -fstack-clash-protection - -pipe - -Wall + $,,-Ofast> -Werror - -Wextra - -Wno-unused-parameter - -Wno-switch - -Wno-maybe-uninitialized - -Wno-missing-field-initializers - -Wno-sign-compare - ) - target_compile_definitions(common_options - INTERFACE - $<$>:_FORTIFY_SOURCE=2> - _GLIBCXX_ASSERTIONS ) + target_link_options(common_options INTERFACE - $<$>:-Ofast> - $<$>:-g> - $<$>:-flto> - $<$>:-fuse-linker-plugin> - $<$>:-fwhole-program> - -Wl,-z,relro - -Wl,-z,now - # -pie # https://gitlab.gnome.org/GNOME/nautilus/-/issues/1601 + $,,-Ofast> ) + + target_compile_options(common_options INTERFACE $,,-g -flto>) + target_link_options(common_options INTERFACE $,,-g -flto -fuse-linker-plugin>) endif() if (NOT DESKTOP_APP_USE_PACKAGED) @@ -77,6 +75,10 @@ if (NOT DESKTOP_APP_USE_PACKAGED) target_link_options(common_options INTERFACE -rdynamic + -fwhole-program + -Wl,-z,relro + -Wl,-z,now + # -pie # https://gitlab.gnome.org/GNOME/nautilus/-/issues/1601 ) endif() diff --git a/options_mac.cmake b/options_mac.cmake index 32358781..8da4ab48 100644 --- a/options_mac.cmake +++ b/options_mac.cmake @@ -20,29 +20,30 @@ endif() target_compile_options(common_options INTERFACE + -pipe + -Wall + -Wextra + -fPIE $<$:-fobjc-weak> -fvisibility-inlines-hidden -fvisibility=hidden -Wno-deprecated-declarations # temp for range-v3 + -Wno-unused-variable + -Wno-unused-parameter + -Wno-unused-function + -Wno-switch + -Wno-comment + -Wno-missing-field-initializers + -Wno-sign-compare + -Wno-unknown-attributes + -Wno-pragma-system-header-outside-header ) if (DESKTOP_APP_SPECIAL_TARGET) target_compile_options(common_options INTERFACE - -pipe -g - -Wall -Werror - -Wextra - -Wno-unused-variable - -Wno-unused-parameter - -Wno-unused-function - -Wno-switch - -Wno-comment - -Wno-missing-field-initializers - -Wno-sign-compare - -Wno-unknown-attributes - -Wno-pragma-system-header-outside-header ) endif() diff --git a/variables.cmake b/variables.cmake index 43cf8fc2..dfd652f7 100644 --- a/variables.cmake +++ b/variables.cmake @@ -34,10 +34,6 @@ cmake_dependent_option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled H cmake_dependent_option(DESKTOP_APP_NO_PDB "Disable PDB file generation." OFF WIN32 OFF) cmake_dependent_option(DESKTOP_APP_DISABLE_JEMALLOC "Disable jemalloc, use system malloc." OFF LINUX OFF) -if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) - set(CMAKE_POSITION_INDEPENDENT_CODE ON) -endif() - if (APPLE AND NOT DEFINED DESKTOP_APP_MAC_ARCH) if (DEFINED CMAKE_OSX_ARCHITECTURES) set(DESKTOP_APP_MAC_ARCH "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING "Target macOS arch.")