CMake: Fold HLSL source into glslang

... and stub the HLSL target.

Fixes the building of shared libraries.

This breaks the cyclic dependency between the `glslang` and `hlsl` targets (by essentially removing the `hlsl` target).

The `BUILD.gn` and `BUILD.bazel` build rules already pull the `HLSL` source into the `glslang` target.

`Android.mk` is the only remaining build config that has a dedicated `HLSL` target, but this is explicity static and does not suffer the same link-time issues with the cyclic dependency (we may wish to stub this target too).

Related issue: #1484, #2147
Related PR: #2267
This commit is contained in:
Ben Clayton 2020-06-15 13:54:55 +01:00
parent 1a6c8ecb20
commit dcad9ad056
3 changed files with 67 additions and 29 deletions

View file

@ -82,11 +82,32 @@ set(HEADERS
glslang_pch(SOURCES MachineIndependent/pch.cpp)
if(ENABLE_HLSL)
list(APPEND SOURCES
../hlsl/hlslAttributes.cpp
../hlsl/hlslParseHelper.cpp
../hlsl/hlslScanContext.cpp
../hlsl/hlslOpMap.cpp
../hlsl/hlslTokenStream.cpp
../hlsl/hlslGrammar.cpp
../hlsl/hlslParseables.cpp)
list(APPEND HEADERS
../hlsl/hlslAttributes.h
../hlsl/hlslParseHelper.h
../hlsl/hlslTokens.h
../hlsl/hlslScanContext.h
../hlsl/hlslOpMap.h
../hlsl/hlslTokenStream.h
../hlsl/hlslGrammar.h
../hlsl/hlslParseables.h)
endif(ENABLE_HLSL)
add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${SOURCES} ${HEADERS})
set_property(TARGET glslang PROPERTY FOLDER glslang)
set_property(TARGET glslang PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(glslang OGLCompiler OSDependent)
target_include_directories(glslang PUBLIC
target_include_directories(glslang PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
@ -94,10 +115,6 @@ if(WIN32 AND BUILD_SHARED_LIBS)
set_target_properties(glslang PROPERTIES PREFIX "")
endif()
if(ENABLE_HLSL)
target_link_libraries(glslang HLSL)
endif()
if(WIN32)
source_group("Public" REGULAR_EXPRESSION "Public/*")
source_group("MachineIndependent" REGULAR_EXPRESSION "MachineIndependent/[^/]*")