KhronosGroup / KhronosGroup/SPIRV-Tools
[cmake] Question about target ${SPIRV_TOOLS}-shared and ${SPIRV_TOOLS}
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 709
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 28
Description
In the following code:
https://github.com/KhronosGroup/SPIRV-Tools/blob/983ee2313c6818d72dc0692b6a7824ca080357fc/source/CMakeLists.txt#L374-L403
There are two scenarios here:
1. If I pass `-DSPIRV_TOOLS_BUILD_STATIC=ON`, there will be 3 targets:
- ${SPIRV_TOOLS}-shared
- ${SPIRV_TOOLS}-static
- ${SPIRV_TOOLS}
`${SPIRV_TOOLS}` is point to `${SPIRV_TOOLS}-shared` or `${SPIRV_TOOLS}-static` according to `BUILD_SHARED_LIBS`. that's okay, but I don’t know why `SPIRV_TOOLS_BUILD_STATIC` and `SPIRV_TOOLS_LIBRARY_TYPE` and `BUILD_SHARED_LIBS` can exist at the same time.
If we use `BUILD_SHARED_LIBS`, the generated library should have the same expectation as the value of `BUILD_SHARED_LIBS`: generate dynamic library, otherwise generate static library.
2. If I pass `-DSPIRV_TOOLS_BUILD_STATIC=OFF`, there will be 2 targets:
- ${SPIRV_TOOLS}-shared
- ${SPIRV_TOOLS}
`${SPIRV_TOOLS}` uses the same source files with `${SPIRV_TOOLS}-shared`.
And if `BUILD_SHARED_LIBS` is `ON`, there will be 2 dynamic libraries!
On Windows, `${SPIRV_TOOLS}` has exported symbols, and `${SPIRV_TOOLS}-shared` doesn't export any symbols. I think that's not make sence: how to use a dynamic library that does not export any symbols?
On non-Windows, you will see `SPIRV_TOOLS` is same with `${SPIRV_TOOLS}-shared`.
So my question is:
1. Why is there such a design?
2. What is the point of always generating dynamic libraries?
3. Why not just use `BUILD_SHARED_LIBS` or `SPIRV_TOOLS_BUILD_STATIC` or `SPIRV_TOOLS_LIBRARY_TYPE` ?
Related downstrem PR: https://github.com/microsoft/vcpkg/pull/19219
Contributor guide
Research direction
Start with source/CMakeLists.txt lines 374-403 and trace how SPIRV_TOOLS_BUILD_STATIC, SPIRV_TOOLS_LIBRARY_TYPE, and BUILD_SHARED_LIBS select targets. Compare the behavior described for Windows and non-Windows, then review the related vcpkg PR. Done requires a maintainer decision or clarified design for the target and library combinations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100