Skip to content

Commit

Permalink
CMake: Compile with -fPIC when building SOs
Browse files Browse the repository at this point in the history
Without this embedding static libraries into shared libraries may result in link time errors.

Issue: KhronosGroup#2283
  • Loading branch information
ben-clayton committed Jun 29, 2020
1 parent 27e915e commit 981e127
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
-Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions)
add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
if(BUILD_SHARED_LIBS)
add_compile_options(-fPIC)
endif()
if(NOT ENABLE_RTTI)
add_compile_options(-fno-rtti)
endif()
Expand All @@ -132,6 +135,9 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT MSVC)
add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
-Wunused-parameter -Wunused-value -Wunused-variable)
add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
if(BUILD_SHARED_LIBS)
add_compile_options(-fPIC)
endif()
if(NOT ENABLE_RTTI)
add_compile_options(-fno-rtti)
endif()
Expand Down

0 comments on commit 981e127

Please sign in to comment.