From 1c6f77389d68827a5df75dfbbaacc8fa98850f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 26 Feb 2022 20:26:11 +0100 Subject: [PATCH] Platform: consistently add -fPIC to all contexts on dynamic builds. Similar change was done for applications long ago. They're built always as static (as they're tiny) and original expectation was that they would get linked just to the final executable and not any shared library, thus not needing the -fPIC. But real-world experience was different, so I added that. The same needs to be done for (also static) context libraries, yet somehow I forgot until now. --- src/Magnum/Platform/CMakeLists.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index 090ff523e..d551d406b 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -60,7 +60,7 @@ if(WITH_EMSCRIPTENAPPLICATION OR WITH_GLFWAPPLICATION OR WITH_SDL2APPLICATION) ${MagnumPlatform_HEADERS} ${MagnumPlatform_PRIVATE_HEADERS}) target_include_directories(MagnumPlatformObjects PUBLIC $) - if(BUILD_STATIC_PIC) + if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumPlatformObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() set_target_properties(MagnumPlatformObjects PROPERTIES FOLDER "Magnum/Platform") @@ -803,7 +803,7 @@ endif() if(NEED_CGLCONTEXT OR WITH_CGLCONTEXT) add_library(MagnumCglContextObjects OBJECT ${MagnumContext_SRCS}) target_include_directories(MagnumCglContextObjects PUBLIC $) - if(BUILD_STATIC_PIC) + if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumCglContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() set_target_properties(MagnumCglContextObjects PROPERTIES FOLDER "Magnum/Platform") @@ -820,7 +820,7 @@ if(NEED_CGLCONTEXT OR WITH_CGLCONTEXT) set_target_properties(MagnumCglContext PROPERTIES DEBUG_POSTFIX "-d" FOLDER "Magnum/Platform") - if(BUILD_STATIC_PIC) + if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumCglContext PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() target_link_libraries(MagnumCglContext PUBLIC MagnumGL) @@ -847,7 +847,7 @@ if(NEED_EGLCONTEXT OR WITH_EGLCONTEXT) $ $) target_compile_definitions(MagnumEglContextObjects PRIVATE "MAGNUM_PLATFORM_USE_EGL") - if(BUILD_STATIC_PIC) + if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumEglContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() set_target_properties(MagnumEglContextObjects PROPERTIES FOLDER "Magnum/Platform") @@ -864,7 +864,7 @@ if(NEED_EGLCONTEXT OR WITH_EGLCONTEXT) set_target_properties(MagnumEglContext PROPERTIES DEBUG_POSTFIX "-d" FOLDER "Magnum/Platform") - if(BUILD_STATIC_PIC) + if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumEglContext PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() target_link_libraries(MagnumEglContext PUBLIC MagnumGL EGL::EGL) @@ -886,7 +886,7 @@ if(NEED_GLXCONTEXT OR WITH_GLXCONTEXT) $ ${X11_INCLUDE_DIR}) target_compile_definitions(MagnumGlxContextObjects PRIVATE "MAGNUM_PLATFORM_USE_GLX") - if(BUILD_STATIC_PIC) + if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumGlxContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() set_target_properties(MagnumGlxContextObjects PROPERTIES FOLDER "Magnum/Platform") @@ -901,7 +901,7 @@ if(NEED_GLXCONTEXT OR WITH_GLXCONTEXT) set_target_properties(MagnumGlxContext PROPERTIES DEBUG_POSTFIX "-d" FOLDER "Magnum/Platform") - if(BUILD_STATIC_PIC) + if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumGlxContext PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() target_include_directories(MagnumGlxContext PUBLIC ${X11_INCLUDE_DIR}) @@ -924,7 +924,7 @@ endif() if(NEED_WGLCONTEXT OR WITH_WGLCONTEXT) add_library(MagnumWglContextObjects OBJECT ${MagnumContext_SRCS}) target_include_directories(MagnumWglContextObjects PUBLIC $) - if(BUILD_STATIC_PIC) + if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumWglContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() set_target_properties(MagnumWglContextObjects PROPERTIES FOLDER "Magnum/Platform") @@ -939,7 +939,7 @@ if(NEED_WGLCONTEXT OR WITH_WGLCONTEXT) set_target_properties(MagnumWglContext PROPERTIES DEBUG_POSTFIX "-d" FOLDER "Magnum/Platform") - if(BUILD_STATIC_PIC) + if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumWglContext PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() target_link_libraries(MagnumWglContext PUBLIC MagnumGL)