Browse Source

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.
pull/556/head
Vladimír Vondruš 4 years ago
parent
commit
1c6f77389d
  1. 18
      src/Magnum/Platform/CMakeLists.txt

18
src/Magnum/Platform/CMakeLists.txt

@ -60,7 +60,7 @@ if(WITH_EMSCRIPTENAPPLICATION OR WITH_GLFWAPPLICATION OR WITH_SDL2APPLICATION)
${MagnumPlatform_HEADERS} ${MagnumPlatform_HEADERS}
${MagnumPlatform_PRIVATE_HEADERS}) ${MagnumPlatform_PRIVATE_HEADERS})
target_include_directories(MagnumPlatformObjects PUBLIC $<TARGET_PROPERTY:Magnum,INTERFACE_INCLUDE_DIRECTORIES>) target_include_directories(MagnumPlatformObjects PUBLIC $<TARGET_PROPERTY:Magnum,INTERFACE_INCLUDE_DIRECTORIES>)
if(BUILD_STATIC_PIC) if(NOT BUILD_STATIC OR BUILD_STATIC_PIC)
set_target_properties(MagnumPlatformObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(MagnumPlatformObjects PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif() endif()
set_target_properties(MagnumPlatformObjects PROPERTIES FOLDER "Magnum/Platform") set_target_properties(MagnumPlatformObjects PROPERTIES FOLDER "Magnum/Platform")
@ -803,7 +803,7 @@ endif()
if(NEED_CGLCONTEXT OR WITH_CGLCONTEXT) if(NEED_CGLCONTEXT OR WITH_CGLCONTEXT)
add_library(MagnumCglContextObjects OBJECT ${MagnumContext_SRCS}) add_library(MagnumCglContextObjects OBJECT ${MagnumContext_SRCS})
target_include_directories(MagnumCglContextObjects PUBLIC $<TARGET_PROPERTY:MagnumGL,INTERFACE_INCLUDE_DIRECTORIES>) target_include_directories(MagnumCglContextObjects PUBLIC $<TARGET_PROPERTY:MagnumGL,INTERFACE_INCLUDE_DIRECTORIES>)
if(BUILD_STATIC_PIC) if(NOT BUILD_STATIC OR BUILD_STATIC_PIC)
set_target_properties(MagnumCglContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(MagnumCglContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif() endif()
set_target_properties(MagnumCglContextObjects PROPERTIES FOLDER "Magnum/Platform") set_target_properties(MagnumCglContextObjects PROPERTIES FOLDER "Magnum/Platform")
@ -820,7 +820,7 @@ if(NEED_CGLCONTEXT OR WITH_CGLCONTEXT)
set_target_properties(MagnumCglContext PROPERTIES set_target_properties(MagnumCglContext PROPERTIES
DEBUG_POSTFIX "-d" DEBUG_POSTFIX "-d"
FOLDER "Magnum/Platform") FOLDER "Magnum/Platform")
if(BUILD_STATIC_PIC) if(NOT BUILD_STATIC OR BUILD_STATIC_PIC)
set_target_properties(MagnumCglContext PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(MagnumCglContext PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif() endif()
target_link_libraries(MagnumCglContext PUBLIC MagnumGL) target_link_libraries(MagnumCglContext PUBLIC MagnumGL)
@ -847,7 +847,7 @@ if(NEED_EGLCONTEXT OR WITH_EGLCONTEXT)
$<TARGET_PROPERTY:MagnumGL,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:MagnumGL,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:EGL::EGL,INTERFACE_INCLUDE_DIRECTORIES>) $<TARGET_PROPERTY:EGL::EGL,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_definitions(MagnumEglContextObjects PRIVATE "MAGNUM_PLATFORM_USE_EGL") 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) set_target_properties(MagnumEglContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif() endif()
set_target_properties(MagnumEglContextObjects PROPERTIES FOLDER "Magnum/Platform") set_target_properties(MagnumEglContextObjects PROPERTIES FOLDER "Magnum/Platform")
@ -864,7 +864,7 @@ if(NEED_EGLCONTEXT OR WITH_EGLCONTEXT)
set_target_properties(MagnumEglContext PROPERTIES set_target_properties(MagnumEglContext PROPERTIES
DEBUG_POSTFIX "-d" DEBUG_POSTFIX "-d"
FOLDER "Magnum/Platform") FOLDER "Magnum/Platform")
if(BUILD_STATIC_PIC) if(NOT BUILD_STATIC OR BUILD_STATIC_PIC)
set_target_properties(MagnumEglContext PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(MagnumEglContext PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif() endif()
target_link_libraries(MagnumEglContext PUBLIC MagnumGL EGL::EGL) target_link_libraries(MagnumEglContext PUBLIC MagnumGL EGL::EGL)
@ -886,7 +886,7 @@ if(NEED_GLXCONTEXT OR WITH_GLXCONTEXT)
$<TARGET_PROPERTY:MagnumGL,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:MagnumGL,INTERFACE_INCLUDE_DIRECTORIES>
${X11_INCLUDE_DIR}) ${X11_INCLUDE_DIR})
target_compile_definitions(MagnumGlxContextObjects PRIVATE "MAGNUM_PLATFORM_USE_GLX") 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) set_target_properties(MagnumGlxContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif() endif()
set_target_properties(MagnumGlxContextObjects PROPERTIES FOLDER "Magnum/Platform") set_target_properties(MagnumGlxContextObjects PROPERTIES FOLDER "Magnum/Platform")
@ -901,7 +901,7 @@ if(NEED_GLXCONTEXT OR WITH_GLXCONTEXT)
set_target_properties(MagnumGlxContext PROPERTIES set_target_properties(MagnumGlxContext PROPERTIES
DEBUG_POSTFIX "-d" DEBUG_POSTFIX "-d"
FOLDER "Magnum/Platform") FOLDER "Magnum/Platform")
if(BUILD_STATIC_PIC) if(NOT BUILD_STATIC OR BUILD_STATIC_PIC)
set_target_properties(MagnumGlxContext PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(MagnumGlxContext PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif() endif()
target_include_directories(MagnumGlxContext PUBLIC ${X11_INCLUDE_DIR}) target_include_directories(MagnumGlxContext PUBLIC ${X11_INCLUDE_DIR})
@ -924,7 +924,7 @@ endif()
if(NEED_WGLCONTEXT OR WITH_WGLCONTEXT) if(NEED_WGLCONTEXT OR WITH_WGLCONTEXT)
add_library(MagnumWglContextObjects OBJECT ${MagnumContext_SRCS}) add_library(MagnumWglContextObjects OBJECT ${MagnumContext_SRCS})
target_include_directories(MagnumWglContextObjects PUBLIC $<TARGET_PROPERTY:MagnumGL,INTERFACE_INCLUDE_DIRECTORIES>) target_include_directories(MagnumWglContextObjects PUBLIC $<TARGET_PROPERTY:MagnumGL,INTERFACE_INCLUDE_DIRECTORIES>)
if(BUILD_STATIC_PIC) if(NOT BUILD_STATIC OR BUILD_STATIC_PIC)
set_target_properties(MagnumWglContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(MagnumWglContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif() endif()
set_target_properties(MagnumWglContextObjects PROPERTIES FOLDER "Magnum/Platform") set_target_properties(MagnumWglContextObjects PROPERTIES FOLDER "Magnum/Platform")
@ -939,7 +939,7 @@ if(NEED_WGLCONTEXT OR WITH_WGLCONTEXT)
set_target_properties(MagnumWglContext PROPERTIES set_target_properties(MagnumWglContext PROPERTIES
DEBUG_POSTFIX "-d" DEBUG_POSTFIX "-d"
FOLDER "Magnum/Platform") FOLDER "Magnum/Platform")
if(BUILD_STATIC_PIC) if(NOT BUILD_STATIC OR BUILD_STATIC_PIC)
set_target_properties(MagnumWglContext PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(MagnumWglContext PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif() endif()
target_link_libraries(MagnumWglContext PUBLIC MagnumGL) target_link_libraries(MagnumWglContext PUBLIC MagnumGL)

Loading…
Cancel
Save