Fix CMake for OSDependent install

This commit is contained in:
Moritz Heinemann 2023-03-24 15:18:09 +01:00 committed by arcady-lunarg
parent c43008e829
commit 1db9cd2854
2 changed files with 12 additions and 16 deletions

View File

@ -356,10 +356,18 @@ endif()
if(ENABLE_GLSLANG_INSTALL)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/glslang-config.cmake.in" [=[
@PACKAGE_INIT@
@INSTALL_CONFIG_UNIX@
include("@PACKAGE_PATH_EXPORT_TARGETS@")
]=])
set(PATH_EXPORT_TARGETS "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/glslang-targets.cmake")
if(UNIX OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
set(INSTALL_CONFIG_UNIX [=[
include(CMakeFindDependencyMacro)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_dependency(Threads REQUIRED)
]=])
endif()
configure_package_config_file(
"${CMAKE_CURRENT_BINARY_DIR}/glslang-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/glslang-config.cmake"

View File

@ -36,21 +36,9 @@ set_property(TARGET OSDependent PROPERTY FOLDER glslang)
set_property(TARGET OSDependent PROPERTY POSITION_INDEPENDENT_CODE ON)
# Link pthread
set(CMAKE_THREAD_PREFER_PTHREAD ON)
if(${CMAKE_VERSION} VERSION_LESS "3.1.0" OR CMAKE_CROSSCOMPILING)
# Needed as long as we support CMake 2.8 for Ubuntu 14.04,
# which does not support the recommended Threads::Threads target.
# https://cmake.org/cmake/help/v2.8.12/cmake.html#module:FindThreads
# Also needed when cross-compiling to work around
# https://gitlab.kitware.com/cmake/cmake/issues/16920
find_package(Threads)
target_link_libraries(OSDependent ${CMAKE_THREAD_LIBS_INIT})
else()
# This is the recommended way, so we use it for 3.1+.
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
target_link_libraries(OSDependent Threads::Threads)
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(OSDependent Threads::Threads)
if(ENABLE_GLSLANG_INSTALL AND NOT BUILD_SHARED_LIBS)
install(TARGETS OSDependent EXPORT glslang-targets)