mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 12:18:51 -05:00
Win32: Fix compilation with standalone LLVM
The /clang: suffix passed to Clang-CL was accidentally also passed to
the regular standalone Clang, which caused compilation to fail. We now
pass /W3 to Clang-CL, which it interprets as -Wall.
The _CRT_SECURE_NO_WARNINGS macro is now defined for both Clang and
Clang-CL.
The /entry: flag passed to link.exe is now also passed to lld-link,
letting the windows subsystem tests and examples link.
Fixes #1807.
Closes #1824.
Closes #1874.
(cherry picked from commit 061a0263a9
)
This commit is contained in:
parent
3cded29c2f
commit
5dd6716ee9
|
@ -120,6 +120,7 @@ information on what to include when reporting a bug.
|
|||
|
||||
- [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or
|
||||
later (#1783,#1796)
|
||||
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
|
||||
|
||||
|
||||
## Contact
|
||||
|
|
|
@ -7,7 +7,8 @@ if (MATH_LIBRARY)
|
|||
link_libraries("${MATH_LIBRARY}")
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
# Workaround for the MS CRT deprecating parts of the standard library
|
||||
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
|
@ -62,9 +63,13 @@ if (GLFW_USE_OSMESA)
|
|||
endif()
|
||||
|
||||
if (MSVC)
|
||||
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
|
||||
# Tell MSVC to use main instead of WinMain
|
||||
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||
elseif (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||
# Tell Clang using MS CRT to use main instead of WinMain
|
||||
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||
LINK_FLAGS "-Wl,/entry:mainCRTStartup")
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
|
|
|
@ -121,19 +121,15 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|||
endif()
|
||||
|
||||
# Enable a reasonable set of warnings
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
|
||||
# NOTE: The order matters here, Clang-CL matches both MSVC and Clang
|
||||
if (MSVC)
|
||||
target_compile_options(glfw PRIVATE "/W3")
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
|
||||
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
|
||||
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
||||
|
||||
if (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||
# Tell Clang-CL that this is a Clang flag
|
||||
target_compile_options(glfw PRIVATE "/clang:-Wall")
|
||||
else()
|
||||
target_compile_options(glfw PRIVATE "-Wall")
|
||||
endif()
|
||||
elseif (MSVC)
|
||||
target_compile_options(glfw PRIVATE "/W3")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
target_compile_definitions(glfw PRIVATE _UNICODE)
|
||||
|
@ -176,7 +172,7 @@ if (BUILD_SHARED_LIBS)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@ if (MATH_LIBRARY)
|
|||
link_libraries("${MATH_LIBRARY}")
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
# Workaround for the MS CRT deprecating parts of the standard library
|
||||
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
|
@ -69,9 +70,13 @@ set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
|||
FOLDER "GLFW3/Tests")
|
||||
|
||||
if (MSVC)
|
||||
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
|
||||
# Tell MSVC to use main instead of WinMain
|
||||
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||
elseif (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||
# Tell Clang using MS CRT to use main instead of WinMain
|
||||
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||
LINK_FLAGS "-Wl,/entry:mainCRTStartup")
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
|
|
Loading…
Reference in New Issue
Block a user