From db7e9cb07341043ac9949012d9e1a978fa7c8508 Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Sat, 30 Jan 2021 19:33:13 -0500 Subject: [PATCH] cmake: turn on CMAKE_POSITION_INDEPENDENT_CODE for shared This prevents an error while linking libbx.a into libbgfx.so on linux --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52a7315b..4412be12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,10 @@ set( BGFX_LIBRARY_TYPE "STATIC" CACHE STRING "Linking type for library" ) set_property( CACHE BGFX_LIBRARY_TYPE PROPERTY STRINGS STATIC SHARED ) +if( BGFX_LIBRARY_TYPE MATCHES "SHARED" ) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +endif() + if( NOT BX_DIR ) set( BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bx." ) elseif( NOT IS_ABSOLUTE "${BX_DIR}")