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

Support for compiling with ninja on Windows #767

Merged
merged 3 commits into from
Nov 22, 2023
Merged

Support for compiling with ninja on Windows #767

merged 3 commits into from
Nov 22, 2023

Conversation

jrouwe
Copy link
Owner

@jrouwe jrouwe commented Nov 21, 2023

No description provided.

@mihe
Copy link
Contributor

mihe commented Nov 21, 2023

Just to clarify, the issue here isn't with Ninja per se and more of an issue with compiling with the Windows-native version of clang++, as opposed to something like clang-cl. I've been using Ninja on all platforms for Godot Jolt since the beginning, but with clang-cl as the compiler on Windows.

Anyway, this doesn't seem to work quite right just yet. You'll need to use if (MSVC) in these three places as well:

if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT MINGW)
target_link_options(UnitTests PUBLIC "/SUBSYSTEM:CONSOLE")
endif()

if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT MINGW)
target_link_options(HelloWorld PUBLIC "/SUBSYSTEM:CONSOLE")
endif()

if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT MINGW)
target_link_options(PerformanceTest PUBLIC "/SUBSYSTEM:CONSOLE")
endif()

Then there's also the problem of what to do with the -pthread flag, since that one doesn't make a whole lot of sense when compiling on Windows, which leads Clang to emit a warning about unused arguments, which becomes an error.

I suppose you can choose to either not add that flag when "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows", or just throw in -Qunused-arguments when "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang", much like what's already being done for clang-cl on Windows:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") # Clang emits warnings about unused arguments such as /MP and /GL

With those changes I can successfully build and run all of Jolt's applications with the Ninja Multi-Config generator and CMAKE_CXX_COMPILER=clang++.

Copy link

sonarcloud bot commented Nov 22, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@mihe
Copy link
Contributor

mihe commented Nov 22, 2023

It struck me just now that maybe MinGW still needs the -pthread flag? I'm not very familiar with how the runtime stuff work there.

@jrouwe
Copy link
Owner Author

jrouwe commented Nov 22, 2023

Apparently not:
image

@jrouwe jrouwe merged commit 3f11ba4 into master Nov 22, 2023
67 checks passed
@jrouwe jrouwe deleted the feature/ninja branch November 22, 2023 21:26
jrouwe added a commit that referenced this pull request Dec 27, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants