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

Add SlangConfig.cmake with slang build targets #5674

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ov-l
Copy link

@ov-l ov-l commented Nov 25, 2024

Closes #5649

@ov-l ov-l requested a review from a team as a code owner November 25, 2024 19:24
@CLAassistant
Copy link

CLAassistant commented Nov 25, 2024

CLA assistant check
All committers have signed the CLA.

@jkwak-work jkwak-work added the pr: non-breaking PRs without breaking changes label Nov 26, 2024
@ov-l
Copy link
Author

ov-l commented Nov 26, 2024

I need to reformat the CMakeLists file.

@obhi-d
Copy link

obhi-d commented Nov 26, 2024

I am not able to make the wasm build work, so probably I need to skip adding slang as target. I tried to add through this macro:

macro(export_slang_targets)
  set(SlangExportTargetList)
  foreach(target IN ITEMS ${ARGN})
    message(STATUS "----------------> ADDING TARGET ${target}")
    if(TARGET ${target})
      list(APPEND SlangExportTargetList ${target})
    endif()
  endforeach()
  
  if (SlangExportTargetList)
  
    install(TARGETS ${SlangExportTargetList} EXPORT SlangExportTarget)
    
    install(
        EXPORT SlangExportTarget
        FILE ${PROJECT_NAME}Targets.cmake
        NAMESPACE ${PROJECT_NAME}::
        DESTINATION cmake
    )
    
    install(
        FILES
            "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
            "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
        DESTINATION cmake
    )
  
  endif()
endmacro()

# 
export_slang_targets(
  core
  prelude
  unordered_dense
  compiler-core
  slang-capability-defs
  slang-capability-lookup
  slang-reflect-headers
  slang-lookup-tables
  SPIRV-Headers
  slang-common-objects
  slang
)

But other issues crop up if I do so, notably : Target "slang-reflect-headers" INTERFACE_INCLUDE_DIRECTORIES property
contains path: , which is prefixed in the build directory.

Exporting all targets specified in SlangTargets is also not an option because it seems SlangTargets include every target declared within the library and they should not be linked to (for ex. executable targets).

For my use-case, only single slang target works for both Linux and Windows. Probably this needs to be handled correctly instead of how I am doing.

@eliemichel
Copy link
Contributor

It might be ok to just not try to find a prebuilt version of Slang when cross-compiling with emscripten (i.e., enclose the find_package within a if (NOT EMSCRIPTEN) and fallback to "manually" locating slangc executable in that case (because I suppose that's all what is needed when the target is WebAssembly -- unless one wants to link slang library into a WebAssembly module but there is no precompiled release for WebAssembly anyways, so one would build from scratch in that case).

@obhi-d
Copy link

obhi-d commented Nov 27, 2024

It might be ok to just not try to find a prebuilt version of Slang when cross-compiling with emscripten (i.e., enclose the find_package within a if (NOT EMSCRIPTEN) and fallback to "manually" locating slangc executable in that case (because I suppose that's all what is needed when the target is WebAssembly -- unless one wants to link slang library into a WebAssembly module but there is no precompiled release for WebAssembly anyways, so one would build from scratch in that case).

Yes, I missed your point earlier. I will try that. Thanks for clarifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: non-breaking PRs without breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide SlangConfig.cmake in releases
5 participants