diff --git a/README.md b/README.md index 1e4b8cc9..29c988b5 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,7 @@ information on what to include when reporting a bug. Windows 10 version 1703 (#1511) - [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) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 21ba4838..c93dbe5f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -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() @@ -54,9 +55,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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e6a1fa2..80a0d753 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -130,18 +130,14 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU") endif() # Enable a reasonable set of warnings -if (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) +# 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") + + target_compile_options(glfw PRIVATE "-Wall") endif() if (WIN32) @@ -166,8 +162,8 @@ if (MINGW) endif() endif() -# Workaround for VS deprecating parts of the standard library -if (MSVC) +# Workaround for the MS CRT deprecating parts of the standard library +if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC") target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 52588244..a704bc07 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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() @@ -58,9 +59,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)