From 39df8929de6ff3cfb558aa68cb85ac90f90d7249 Mon Sep 17 00:00:00 2001 From: Paolo Bosetti Date: Sun, 11 Aug 2024 17:40:38 +0200 Subject: [PATCH] Improved CMake PIC compile option management --- cmake/ftxui_set_options.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/ftxui_set_options.cmake b/cmake/ftxui_set_options.cmake index 077afdf..6e5a8e0 100644 --- a/cmake/ftxui_set_options.cmake +++ b/cmake/ftxui_set_options.cmake @@ -49,9 +49,11 @@ function(ftxui_set_options library) target_compile_options(${library} PUBLIC "/utf-8") endif() - if(UNIX) - target_compile_options(${library} PRIVATE "-fPIC") - endif() + # CMake does automatically add -fPIC when linking a shared library, but it + # does not add it when linking a static library. This is a problem when the + # static library is later linked into a shared library. + # Doing it helps some users. + set_property(TARGET ${library} PROPERTY POSITION_INDEPENDENT_CODE ON) # Add as many warning as possible: if (WIN32)