Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glslang third party build needs -fPIC #1093

Merged
merged 1 commit into from
Jul 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ if(${SHADERC_ENABLE_TESTS})
endif()

set(OLD_PLATFORM_TOOLSET ${CMAKE_GENERATOR_TOOLSET})
check_cxx_compiler_flag(-fPIC COMPILER_SUPPORTS_PIC)


if (IS_DIRECTORY ${SHADERC_SPIRV_HEADERS_DIR})
Expand Down Expand Up @@ -64,7 +65,17 @@ endif()

if (NOT TARGET glslang)
if (IS_DIRECTORY ${SHADERC_GLSLANG_DIR})
add_subdirectory(${SHADERC_GLSLANG_DIR} glslang)
# Add -fPIC to glslang build, if supported
if (COMPILER_SUPPORTS_PIC)
set(CXX_BACK ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-fPIC")
# cmake inserts a semicolon, change it to a space.
string(REGEX REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_subdirectory(${SHADERC_GLSLANG_DIR} glslang)
set(CMAKE_CXX_FLAGS ${CXX_BACK})
else()
add_subdirectory(${SHADERC_GLSLANG_DIR} glslang)
endif()
endif()
if (NOT TARGET glslang)
message(FATAL_ERROR "glslang was not found - required for compilation")
Expand All @@ -82,7 +93,6 @@ if (SHADERC_ENABLE_SPVC)
if (NOT TARGET spirv-cross-core)
if (IS_DIRECTORY ${SHADERC_SPIRV_CROSS_DIR})
# Add -fPIC to SPIRV-Cross build, if supported
check_cxx_compiler_flag(-fPIC COMPILER_SUPPORTS_PIC)
if (COMPILER_SUPPORTS_PIC)
set(CXX_BACK ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-fPIC")
Expand Down