-
Notifications
You must be signed in to change notification settings - Fork 456
Allow install of static slang library #11458
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,3 +177,11 @@ jobs: | |
| - name: Build Slang (${{ matrix.option }}) | ||
| if: (matrix.linux_only != 'true' || inputs.os == 'linux') && (matrix.windows_only != 'true' || inputs.os == 'windows') && matrix.container_only != 'true' && (matrix.skip_linux_aarch64 != 'true' || inputs.os != 'linux' || inputs.platform != 'aarch64') | ||
| run: cmake --build build --config "$cmake_config" | ||
|
|
||
| # Exercise `cmake --install` for entries that opt in via install_test. | ||
| # The static-lib build (SLANG_LIB_TYPE=STATIC) used to skip the | ||
| # install(EXPORT ...) step entirely, so a broken export would not have | ||
| # been caught by a plain configure+build. See issue #11359. | ||
| - name: Install Slang (${{ matrix.option }}) | ||
| if: matrix.install_test == 'true' && (matrix.linux_only != 'true' || inputs.os == 'linux') && (matrix.windows_only != 'true' || inputs.os == 'windows') && matrix.container_only != 'true' && (matrix.skip_linux_aarch64 != 'true' || inputs.os != 'linux' || inputs.platform != 'aarch64') | ||
| run: cmake --install build --config "$cmake_config" --prefix install | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Gap: The reported failure mode in #11359 is In particular, if a future change re-introduces a guard around just the Suggested fix: chain a tiny - name: Smoke-test find_package(slang) against install prefix
if: matrix.install_test == 'true' && (matrix.linux_only != 'true' || inputs.os == 'linux') && (matrix.windows_only != 'true' || inputs.os == 'windows') && matrix.container_only != 'true' && (matrix.skip_linux_aarch64 != 'true' || inputs.os != 'linux' || inputs.platform != 'aarch64')
shell: bash
run: |
mkdir -p find_pkg_test && cd find_pkg_test
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.22)
project(find_slang_smoke LANGUAGES CXX)
find_package(slang CONFIG REQUIRED)
if(NOT TARGET slang::slang)
message(FATAL_ERROR "slang::slang target missing after find_package")
endif()
EOF
cmake -S . -B build -Dslang_ROOT="$GITHUB_WORKSPACE/install"Same change applies to |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -663,29 +663,38 @@ configure_package_config_file( | |
| # Conditionally handle the case for Emscripten where slang does not create | ||
| # linkable targets. In this case do not export the targets. Otherwise, just | ||
| # export the slang targets. | ||
| # | ||
| # A STATIC build used to be excluded here because slang's internal link | ||
| # dependencies (core, prelude, compiler-core, slang-capability-*, | ||
| # slang-lookup-tables, SPIRV-Headers, ...) leaked onto its public link | ||
| # interface and weren't in any export set, which made install(EXPORT ...) fail | ||
| # (see issue #5821 / PR #6158). slang_add_target now wraps private link deps in | ||
| # $<BUILD_LOCAL_INTERFACE:...> / $<BUILD_INTERFACE:...> (cmake/SlangTarget.cmake), | ||
| # so those targets no longer appear in the install/export interface and a static | ||
| # install exports cleanly. Exporting also for STATIC keeps SlangConfig.cmake's | ||
| # unconditional include() of slangTargets.cmake (cmake/SlangConfig.cmake.in) | ||
| # satisfied, so find_package(slang) works for static installs too. | ||
| if(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten") | ||
| if(NOT ${SLANG_LIB_TYPE} STREQUAL "STATIC") | ||
| install( | ||
| EXPORT SlangTargets | ||
| FILE ${PROJECT_NAME}Targets.cmake | ||
| NAMESPACE ${PROJECT_NAME}:: | ||
| DESTINATION ${SLANG_CMAKE_CONFIG_DIR} | ||
| ) | ||
| install( | ||
| EXPORT SlangTargets | ||
| FILE ${PROJECT_NAME}Targets.cmake | ||
| NAMESPACE ${PROJECT_NAME}:: | ||
| DESTINATION ${SLANG_CMAKE_CONFIG_DIR} | ||
| ) | ||
|
|
||
| if(UNIX) | ||
| configure_file( | ||
| "${PROJECT_SOURCE_DIR}/extras/pkgconfig/slang-compiler.pc.in" | ||
| "${PROJECT_BINARY_DIR}/slang-compiler.pc" | ||
| @ONLY | ||
| ) | ||
| if(UNIX) | ||
| configure_file( | ||
| "${PROJECT_SOURCE_DIR}/extras/pkgconfig/slang-compiler.pc.in" | ||
| "${PROJECT_BINARY_DIR}/slang-compiler.pc" | ||
| @ONLY | ||
| ) | ||
|
|
||
| # TODO: When build system is changed to respect CMAKE_INSTALL_LIBDIR, | ||
| # update this destination. | ||
| install( | ||
| FILES "${PROJECT_BINARY_DIR}/slang-compiler.pc" | ||
| DESTINATION "lib/pkgconfig" | ||
| ) | ||
| endif() | ||
| # TODO: When build system is changed to respect CMAKE_INSTALL_LIBDIR, | ||
| # update this destination. | ||
| install( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Gap: pkgconfig file installed for STATIC builds, but Removing the
Example: a downstream UNIX project does Suggested fix: either keep the pkgconfig install gated on shared (the simplest patch and consistent with the if(UNIX AND NOT ${SLANG_LIB_TYPE} STREQUAL "STATIC")
configure_file(...)
install(FILES "${PROJECT_BINARY_DIR}/slang-compiler.pc" DESTINATION "lib/pkgconfig")
endif() |
||
| FILES "${PROJECT_BINARY_DIR}/slang-compiler.pc" | ||
| DESTINATION "lib/pkgconfig" | ||
| ) | ||
| endif() | ||
| endif() | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial | 🏗️ Heavy lift
Consider validating
find_package(slang)after install, not just thatcmake --installsucceeds.Issue
#11359manifested asfind_package(slang)failing becauseslangTargets.cmakewasn't installed — yet the install command itself still succeeded with the old guard in place. The "not in any export set" failure is caught at configure/generate time now, but this step alone would not catch a future regression where the install completes but the exported package config is inconsistent. A minimal consumerfind_package(slang CONFIG PATHS install ... NO_DEFAULT_PATH)check (resolvingslang::slang) would directly guard the originally-reported breakage.