Improved CMake PIC compile option management

This commit is contained in:
Paolo Bosetti 2024-08-11 17:40:38 +02:00
parent d0e10d3b73
commit 39df8929de

View File

@ -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)