Skip to content

Commit

Permalink
Always build with CMAKE_POSITION_INDEPENDENT_CODE=ON
Browse files Browse the repository at this point in the history
not just for shared library builds. This allows static bmx
libraries to be linked into other shared libraries.
  • Loading branch information
philipnbbc committed Oct 6, 2023
1 parent 1820bda commit a1cd198
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ if(MSVC AND BMX_SET_MSVC_RUNTIME AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()

if(BUILD_SHARED_LIBS)
# Ensure that static library code can be linked into the dynamic libraries (-fPIC compile option)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
# Ensure that static library code can be linked into the dynamic libraries (-fPIC compile option)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(CMAKE_CXX_STANDARD 11)

# Set the test samples output directory
Expand Down
7 changes: 3 additions & 4 deletions deps/libMXF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ if(MSVC AND LIBMXF_SET_MSVC_RUNTIME AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.15
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()

if(BUILD_SHARED_LIBS)
# Ensure that static library code can be linked into the dynamic libraries (-fPIC compile option)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
# Ensure that static library code can be linked into the dynamic libraries (-fPIC compile option)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(CMAKE_CXX_STANDARD 11)

# Set the test samples output directory
Expand Down
7 changes: 3 additions & 4 deletions deps/libMXFpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ if(MSVC AND LIBMXFPP_SET_MSVC_RUNTIME AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()

if(BUILD_SHARED_LIBS)
# Ensure that static library code can be linked into the dynamic libraries (-fPIC compile option)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
# Ensure that static library code can be linked into the dynamic libraries (-fPIC compile option)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(CMAKE_CXX_STANDARD 11)

if(MSVC)
Expand Down

0 comments on commit a1cd198

Please sign in to comment.