Pārlūkot izejas kodu

Update USE_MSVC_RUNTIME_LIBRARY_DLL for CMake 3.15

This makes USE_MSVC_RUNTIME_LIBRARY_DLL update the directory scope
CMAKE_MSVC_RUNTIME_LIBRARY variable instead of CMAKE_C_FLAGS on CMake
3.15 and later.

Solution proposed by @moritz-h.

Fixes #1783.
Closes #1796.

(cherry picked from commit f4a73296049b432720c9b6c230e479f9b41d74d3)
Camilla Löwy 5 gadi atpakaļ
vecāks
revīzija
658744e222
3 mainītis faili ar 11 papildinājumiem un 2 dzēšanām
  1. 5 1
      CMakeLists.txt
  2. 2 1
      README.md
  3. 4 0
      docs/compile.dox

+ 5 - 1
CMakeLists.txt

@@ -80,8 +80,10 @@ if (MSVC)
         # Workaround for VS 2008 not shipping with stdint.h
         # Workaround for VS 2008 not shipping with stdint.h
         list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/vs2008")
         list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/vs2008")
     endif()
     endif()
+endif()
 
 
-    if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
+if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
+    if (${CMAKE_VERSION} VERSION_LESS 3.15)
         foreach (flag CMAKE_C_FLAGS
         foreach (flag CMAKE_C_FLAGS
                       CMAKE_C_FLAGS_DEBUG
                       CMAKE_C_FLAGS_DEBUG
                       CMAKE_C_FLAGS_RELEASE
                       CMAKE_C_FLAGS_RELEASE
@@ -96,6 +98,8 @@ if (MSVC)
             endif()
             endif()
 
 
         endforeach()
         endforeach()
+    else()
+        set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
     endif()
     endif()
 endif()
 endif()
 
 

+ 2 - 1
README.md

@@ -118,7 +118,8 @@ information on what to include when reporting a bug.
 
 
 ## Changelog
 ## Changelog
 
 
-There is nothing here yet.
+ - [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or
+   later (#1783,#1796)
 
 
 
 
 ## Contact
 ## Contact

+ 4 - 0
docs/compile.dox

@@ -234,6 +234,10 @@ __USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or th
 static library version of the Visual C++ runtime library.  If set to `ON`, the
 static library version of the Visual C++ runtime library.  If set to `ON`, the
 DLL version of the Visual C++ library is used.
 DLL version of the Visual C++ library is used.
 
 
+@note On CMake 3.15 and later you can set the
+[CMAKE_MSVC_RUNTIME_LIBRARY](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html)
+variable instead of this option.
+
 @anchor GLFW_USE_HYBRID_HPG
 @anchor GLFW_USE_HYBRID_HPG
 __GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and
 __GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and
 `AmdPowerXpressRequestHighPerformance` symbols, which force the use of the
 `AmdPowerXpressRequestHighPerformance` symbols, which force the use of the