Fix SHMath CMake build on non-Windows platforms - #348
Open
Joel Kiptoo (Kiptoo-Deus) wants to merge 1 commit into
Open
Joel Kiptoo (Kiptoo-Deus) wants to merge 1 commit into
Joel Kiptoo (Kiptoo-Deus) wants to merge 1 commit into
Conversation
The sal.h include directory was only added in the configure run that downloaded sal.h. Reconfiguring an existing build directory skipped the whole block, so the include path was lost and DirectXSH.cpp no longer compiled. Add the include directory whenever the build is not on Windows, and only guard the download itself. /ZH:SHA_256 was added for all Clang compilers version 16 and later, but it is only valid for clang-cl. Apple Clang and Clang on Linux fail with "no such file or directory: '/ZH:SHA_256'". Only add it when Clang uses the MSVC command-line frontend. Fixes microsoft#346
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #346.
Two problems stop SHMath from building on non-Windows platforms.
sal.h include directory lost on reconfigure.
target_include_directories(... sal)was insideif((NOT WIN32) AND (NOT EXISTS ".../sal/sal.h")), so it was only added in the configure run that downloaded the file. Running CMake again on the same build directory skipped the block, the-I.../SHMath/salflag disappeared from the build, andDirectXSH.cppfailed to compile. The include directory is now added whenever the build is not on Windows, and only the download is guarded byNOT EXISTS.On the first point in the issue: I left the download in the build directory, since that keeps generated files out of the source tree.
/ZH:SHA_256passed to non-MSVC Clang. TheClang|IntelLLVMbranch added/ZH:SHA_256for Clang 16 and later, which is only valid for clang-cl. Apple Clang (and Clang on Linux) treat it as a file name, so the first build already failed with:It is now only added when
CMAKE_CXX_COMPILER_FRONTEND_VARIANTisMSVC.-Wno-unsafe-buffer-usageis still added for all Clang 16+.Testing
On macOS (arm64) with Apple Clang 21 and GCC 15.1,
-DBUILD_SHMATH=ON:/ZH:SHA_256)A small program linked against the built library gets the expected values from
XMSHEvalDirectionfor +Z (Y00 = 0.282095, Y10 = 0.488603).I couldn't test clang-cl or MSVC here; the change keeps
/ZH:SHA_256for clang-cl and doesn't touch the MSVC branch. SHMath is currently only built by the Windows workflows, which is probably why this wasn't caught.