Skip to content

Commit 3604be1

Browse files
committed
Remove GLSLANG_BUILD_PIC flag
On closer inspection, it appears that nearly all the targets use the `POSITION_INDEPENDENT_CODE` target option anyway. Simplify all this away by always being PIC.
1 parent 948dc03 commit 3604be1

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

CMakeLists.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,6 @@ if(USE_CCACHE)
107107
endif(CCACHE_FOUND)
108108
endif()
109109

110-
# If projects are statically importing glslang targets into a shared library
111-
# then they'll likely need to build with -fPIC. This can be enabled by setting
112-
# GLSLANG_BUILD_PIC to 1 before calling add_subdirectory() to import glslang.
113-
# Note: -fPIC is automatically used when BUILD_SHARED_LIBS is enabled.
114-
if(NOT DEFINED GLSLANG_BUILD_PIC)
115-
option(GLSLANG_BUILD_PIC "Compile glslang with -fPIC" OFF)
116-
endif()
117-
118110
# Precompiled header macro. Parameters are source file list and filename for pch cpp file.
119111
macro(glslang_pch SRCS PCHCPP)
120112
if(MSVC AND CMAKE_GENERATOR MATCHES "^Visual Studio" AND NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND ENABLE_PCH)
@@ -160,9 +152,6 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
160152
add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
161153
-Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions)
162154
add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
163-
if(BUILD_SHARED_LIBS OR GLSLANG_BUILD_PIC)
164-
add_compile_options(-fPIC)
165-
endif()
166155
if(NOT ENABLE_RTTI)
167156
add_compile_options(-fno-rtti)
168157
endif()
@@ -183,9 +172,6 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT MSVC)
183172
add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
184173
-Wunused-parameter -Wunused-value -Wunused-variable)
185174
add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
186-
if(BUILD_SHARED_LIBS OR GLSLANG_BUILD_PIC)
187-
add_compile_options(-fPIC)
188-
endif()
189175
if(NOT ENABLE_RTTI)
190176
add_compile_options(-fno-rtti)
191177
endif()

glslang/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ endif(EMSCRIPTEN OR ENABLE_GLSLANG_JS)
5050
add_library(GenericCodeGen STATIC
5151
GenericCodeGen/CodeGen.cpp
5252
GenericCodeGen/Link.cpp)
53+
set_property(TARGET GenericCodeGen PROPERTY POSITION_INDEPENDENT_CODE ON)
5354
set_property(TARGET GenericCodeGen PROPERTY FOLDER glslang)
5455

5556
################################################################################
@@ -130,6 +131,7 @@ if(ENABLE_HLSL)
130131
endif(ENABLE_HLSL)
131132

132133
add_library(MachineIndependent STATIC ${MACHINEINDEPENDENT_SOURCES} ${MACHINEINDEPENDENT_HEADERS})
134+
set_property(TARGET MachineIndependent PROPERTY POSITION_INDEPENDENT_CODE ON)
133135
set_property(TARGET MachineIndependent PROPERTY FOLDER glslang)
134136
glslang_pch(SOURCES MachineIndependent/pch.cpp)
135137

0 commit comments

Comments
 (0)