diff options
author | Robert <krzmbrzl@gmail.com> | 2020-10-13 16:18:39 +0300 |
---|---|---|
committer | Robert <krzmbrzl@gmail.com> | 2020-10-13 17:25:52 +0300 |
commit | 5cf9dde08be6b64b7a43b5b016c4ff2604f19ad1 (patch) | |
tree | 3b3632ee73fae49fe41eb3cb9dcb41a333d7aba6 /cmake/compiler.cmake | |
parent | 30c51665a66f64536fabacc8f9884ba7fd1ca108 (diff) |
BUILD(cmake): Fix use of generator expression
The changed files used a generator expression in an if-statement, which
is invalid as these generator expressions are not evaluated during the
initial configuration stage (at which point the if-statement is
evaluated).
This commit changes the use of the generator-expression in such a way
that it will actually do what it was meant to.
Note that this commit also enables position independent code for all
platforms and all build-types instead of only for debug builds on unix
systems. This was the preferred choice instead of porting the -fPIE
compiler option to use proper generator expressions as the presence of
these options caused linking errors with Celt/Opus.
Diffstat (limited to 'cmake/compiler.cmake')
-rw-r--r-- | cmake/compiler.cmake | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 0c56a64d2..a333d8e04 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -11,6 +11,8 @@ else() message(FATAL_ERROR "Unknown architecture - only 32bit and 64bit are supported") endif() +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + if(MSVC) if($<CONFIG:Release>) add_compile_options( @@ -96,19 +98,18 @@ elseif(UNIX OR MINGW) # In Mumble builds with warnings-as-errors, this will cause build failures. add_compile_options("-U_FORTIFY_SOURCE") - if($<CONFIG:Debug>) - if(NOT MINGW) - add_compile_options("-fstack-protector") - endif() - add_compile_options("-fPIE") - add_link_options( - "-pie" - "-Wl,--no-add-needed" - ) - else() - add_compile_options("-D_FORTIFY_SOURCE=2") + if(NOT MINGW) + add_compile_options($<$<CONFIG:Debug>:-fstack-protector>) endif() + add_compile_options( + $<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2> + ) + + add_link_options( + $<$<CONFIG:Debug>:-Wl,--no-add-needed> + ) + if(symbols) add_compile_options("-g") endif() |