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

Building with clang using ninja on windows #766

Closed
Hatrickek opened this issue Nov 20, 2023 · 5 comments
Closed

Building with clang using ninja on windows #766

Hatrickek opened this issue Nov 20, 2023 · 5 comments

Comments

@Hatrickek
Copy link

Currently Jolt doesn't build with clang on Windows because of this line: https://github.com/jrouwe/JoltPhysics/blob/master/Build/CMakeLists.txt#L82

Giving this error:

CLANG_~1: error: no such file or directory: '/Zc:__cplusplus'
CLANG_~1: error: no such file or directory: '/Gm-'
CLANG_~1: error: no such file or directory: '/MP'
CLANG_~1: error: no such file or directory: '/nologo'
CLANG_~1: error: no such file or directory: '/diagnostics:classic'
CLANG_~1: error: no such file or directory: '/FC'
CLANG_~1: error: no such file or directory: '/fp:except-'
CLANG_~1: error: no such file or directory: '/Zc:inline'
CLANG_~1: error: no such file or directory: '/Zi'
CLANG_~1: error: no such file or directory: '/GR-'
CLANG_~1: error: no such file or directory: '/showFilenames'
CLANG_~1: error: no such file or directory: '/GS-'
CLANG_~1: error: no such file or directory: '/Gy'
CLANG_~1: error: no such file or directory: '/O2'
CLANG_~1: error: no such file or directory: '/Oi'
CLANG_~1: error: no such file or directory: '/Ot'

I could simply fix it by adding AND NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" to the top if check in my fork and it built and run successfully.
https://github.com/Hatrickek/JoltPhysics/blob/master/Build/CMakeLists.txt#L69

@cranflavin
Copy link

I hit the same issue as @Hatrickek (apparently 7 hours after). The workaround is good to get buildling/running, although it may be that skipping that if block means some of the build configurations won't be set up right. I have been using cmake/ninja/clang for builds.

@mihe
Copy link
Contributor

mihe commented Nov 21, 2023

if (("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore") AND NOT MINGW)

I would probably advise just replacing that whole thing with if (MSVC), which will be truthy whenever the compiler defines _MSC_VER, which would cover Microsoft's own cl as well as clang-cl, but none of the compilers adhering to the GCC-like interface, like MinGW-based compilers or (in this case) native clang.

elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "iOS" OR MINGW OR EMSCRIPTEN OR ANDROID)

Then this could probably just be an else(), since any other supported compiler is likely to emulate the GCC-like interface anyway, including native clang on Windows.

@jrouwe
Copy link
Owner

jrouwe commented Nov 21, 2023

I like @mihe's solution better. I've created #767 and it looks like it passes all builds. Can you let me know if this works for ninja too? (I don't use it)

@cranflavin
Copy link

I can confirm that @mihe's solution works for my cmake/clang/ninja setup.

@Hatrickek
Copy link
Author

It indeed works thanks 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants