summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Byrne <50328838+byrnHDF@users.noreply.github.com>2024-03-07 17:27:56 (GMT)
committerGitHub <noreply@github.com>2024-03-07 17:27:56 (GMT)
commitc872acae63feb8b391f6919b94c2d2d06deb1a19 (patch)
tree8b80a7f2f973724dc5f62c9f63314f85a82240ff
parent64a0b71c86bd6606c4e6feb0206e6fdcad5a7771 (diff)
downloadhdf5-c872acae63feb8b391f6919b94c2d2d06deb1a19.zip
hdf5-c872acae63feb8b391f6919b94c2d2d06deb1a19.tar.gz
hdf5-c872acae63feb8b391f6919b94c2d2d06deb1a19.tar.bz2
New option for building with static CRT in Windows (#4062)
-rw-r--r--config/cmake/HDFUseFortran.cmake8
-rw-r--r--config/cmake/UserMacros/Windows_MT.cmake34
-rw-r--r--release_docs/INSTALL_CMake.txt9
-rw-r--r--release_docs/RELEASE.txt9
4 files changed, 17 insertions, 43 deletions
diff --git a/config/cmake/HDFUseFortran.cmake b/config/cmake/HDFUseFortran.cmake
index 392ea30..2d53a50 100644
--- a/config/cmake/HDFUseFortran.cmake
+++ b/config/cmake/HDFUseFortran.cmake
@@ -19,14 +19,6 @@ set (HDF_PREFIX "H5")
include (CheckFortranSourceRuns)
include (CheckFortranSourceCompiles)
-#-------------------------------------------------------------------------------
-# Fix Fortran flags if we are compiling statically on Windows using
-# Windows_MT.cmake from config/cmake/UserMacros
-#-------------------------------------------------------------------------------
-if (BUILD_STATIC_CRT_LIBS)
- TARGET_STATIC_CRT_FLAGS ()
-endif ()
-
#-----------------------------------------------------------------------------
# Detect name mangling convention used between Fortran and C
#-----------------------------------------------------------------------------
diff --git a/config/cmake/UserMacros/Windows_MT.cmake b/config/cmake/UserMacros/Windows_MT.cmake
index c8edbe4..351c991 100644
--- a/config/cmake/UserMacros/Windows_MT.cmake
+++ b/config/cmake/UserMacros/Windows_MT.cmake
@@ -20,34 +20,10 @@
# INCLUDE(path_to_file/WINDOWS_MT.cmake)
#-----------------------------------------------------------------------------
-# Option to Build with Static CRT libraries on Windows
-#-------------------------------------------------------------------------------
-macro (TARGET_STATIC_CRT_FLAGS)
- if (MSVC AND NOT BUILD_SHARED_LIBS)
- foreach (flag_var
- CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
- CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
- CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
- CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
- if (${flag_var} MATCHES "/MD")
- string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
- endif ()
- endforeach ()
- foreach (flag_var
- CMAKE_Fortran_FLAGS CMAKE_Fortran_FLAGS_DEBUG CMAKE_Fortran_FLAGS_RELEASE
- CMAKE_Fortran_FLAGS_MINSIZEREL CMAKE_Fortran_FLAGS_RELWITHDEBINFO)
- if (${flag_var} MATCHES "/libs:dll")
- string (REGEX REPLACE "/libs:dll" "/libs:static" ${flag_var} "${${flag_var}}")
- endif ()
- endforeach ()
- set (WIN_COMPILE_FLAGS "")
- set (WIN_LINK_FLAGS "/NODEFAULTLIB:MSVCRT")
- endif ()
-endmacro ()
-
+# Option to Build with Static CRT libraries on Windows (USE WITH CAUTION!!!)
#-----------------------------------------------------------------------------
-option (BUILD_STATIC_CRT_LIBS "Build With Static CRT Libraries" OFF)
-mark_as_advanced (BUILD_STATIC_CRT_LIBS)
-if (BUILD_STATIC_CRT_LIBS)
- TARGET_STATIC_CRT_FLAGS ()
+option (HDF5_BUILD_STATIC_CRT_LIBS "Build With Static Windows CRT Libraries" OFF)
+mark_as_advanced (HDF5_BUILD_STATIC_CRT_LIBS)
+if (HDF5_BUILD_STATIC_CRT_LIBS)
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif ()
diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt
index 392abf3..4d4af24 100644
--- a/release_docs/INSTALL_CMake.txt
+++ b/release_docs/INSTALL_CMake.txt
@@ -968,13 +968,10 @@ VII. User Defined Options for HDF5 Libraries with CMake
========================================================================
Support for User Defined macros and options has been added. The file
-UserMacros.cmake has an example of the technique. In the folder,
-config/cmake/UserMacros, is an implementation for Windows Visual Studio
-users for linking libraries to the static CRT - Windows_MT.cmake.
+UserMacros.cmake has an example of the technique.
-Copy the contents of the file, both macro and option, into the
-UserMacros.cmake file. Then enable the option to the CMake configuration,
-build and test process.
+Replace the template code with your macro in the UserMacros.cmake file.
+Then enable the option to the CMake configuration, build and test process.
========================================================================
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 9ef3f45..25bcbbf 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -47,6 +47,15 @@ New Features
Configuration:
-------------
+ - New option for building with static CRT in Windows
+
+ The following option has been added:
+ HDF5_BUILD_STATIC_CRT_LIBS "Build With Static Windows CRT Libraries" OFF
+ Because our minimum CMake is 3.18, the macro to change runtime flags no longer
+ works as CMake changed the default behavior in CMake 3.15.
+
+ Fixes GitHub issue #3984
+
- Added support for the new MSVC preprocessor
Microsoft added support for a new, standards-conformant preprocessor