summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichel Zou <xantares09@hotmail.com>2020-10-30 09:44:24 (GMT)
committerMichel Zou <xantares09@hotmail.com>2020-10-31 09:31:38 (GMT)
commit7259b5eb7ac291f00cc989a44c5fe4964759efaf (patch)
tree805715ed48133b0127a15185f85b5f74f42d364d
parentd8b7b3593b0727acade59ebddf4c749ea774ae2a (diff)
downloadhdf5-7259b5eb7ac291f00cc989a44c5fe4964759efaf.zip
hdf5-7259b5eb7ac291f00cc989a44c5fe4964759efaf.tar.gz
hdf5-7259b5eb7ac291f00cc989a44c5fe4964759efaf.tar.bz2
CMake: Add an option to opt-out static libgcc
With sjlj exception model, statically link to libgcc/libstdc++ prevents exceptions to be caught from other dynamic libraries.
-rw-r--r--CMakeLists.txt2
-rw-r--r--c++/examples/CMakeLists.txt4
-rw-r--r--c++/src/CMakeLists.txt2
-rw-r--r--c++/test/CMakeLists.txt2
-rw-r--r--config/cmake/cacheinit.cmake2
-rw-r--r--release_docs/INSTALL_CMake.txt1
-rw-r--r--release_docs/RELEASE.txt7
7 files changed, 16 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d0eebad..dc2cf1a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -578,6 +578,8 @@ if (WIN32 OR MINGW)
add_compile_definitions (_BIND_TO_CURRENT_VCLIBS_VERSION=1 _CRT_SECURE_NO_WARNINGS _CONSOLE)
endif ()
+option (HDF5_MINGW_STATIC_GCC_LIBS "Statically link libgcc/libstdc++" OFF)
+
if (MSVC)
set (CMAKE_MFC_FLAG 0)
set (WIN_COMPILE_FLAGS "")
diff --git a/c++/examples/CMakeLists.txt b/c++/examples/CMakeLists.txt
index 3035841..c50315f 100644
--- a/c++/examples/CMakeLists.txt
+++ b/c++/examples/CMakeLists.txt
@@ -41,7 +41,7 @@ foreach (example ${examples})
else ()
TARGET_C_PROPERTIES (cpp_ex_${example} SHARED)
target_link_libraries (cpp_ex_${example} PRIVATE ${HDF5_CPP_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
- if (MINGW)
+ if (MINGW AND HDF5_MINGW_STATIC_GCC_LIBS)
target_link_options (${HDF5_CPP_LIBSH_TARGET}
PRIVATE -static-libgcc -static-libstdc++
)
@@ -66,7 +66,7 @@ foreach (example ${tutr_examples})
else ()
TARGET_C_PROPERTIES (cpp_ex_${example} SHARED)
target_link_libraries (cpp_ex_${example} PRIVATE ${HDF5_CPP_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
- if (MINGW)
+ if (MINGW AND HDF5_MINGW_STATIC_GCC_LIBS)
target_link_options (${HDF5_CPP_LIBSH_TARGET}
PRIVATE -static-libgcc -static-libstdc++
)
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt
index 04822cf..de2306e 100644
--- a/c++/src/CMakeLists.txt
+++ b/c++/src/CMakeLists.txt
@@ -117,7 +117,7 @@ if (BUILD_SHARED_LIBS)
target_link_libraries (${HDF5_CPP_LIBSH_TARGET}
PUBLIC ${HDF5_LIBSH_TARGET}
)
- if (MINGW)
+ if (MINGW AND HDF5_MINGW_STATIC_GCC_LIBS)
target_link_options (${HDF5_CPP_LIBSH_TARGET}
PRIVATE -static-libgcc -static-libstdc++
)
diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt
index 550b7ea..1255e39 100644
--- a/c++/test/CMakeLists.txt
+++ b/c++/test/CMakeLists.txt
@@ -49,7 +49,7 @@ if (NOT BUILD_SHARED_LIBS)
else ()
TARGET_C_PROPERTIES (cpp_testhdf5 SHARED)
target_link_libraries (cpp_testhdf5 PRIVATE ${HDF5_CPP_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET})
- if (MINGW)
+ if (MINGW AND HDF5_MINGW_STATIC_GCC_LIBS)
target_link_options (${HDF5_CPP_LIBSH_TARGET}
PRIVATE -static-libgcc -static-libstdc++
)
diff --git a/config/cmake/cacheinit.cmake b/config/cmake/cacheinit.cmake
index f8ab3a2..71c8b4a 100644
--- a/config/cmake/cacheinit.cmake
+++ b/config/cmake/cacheinit.cmake
@@ -40,6 +40,8 @@ set (HDF5_ENABLE_ALL_WARNINGS ON CACHE BOOL "Enable all warnings" FORCE)
set (HDF_TEST_EXPRESS "2" CACHE STRING "Control testing framework (0-3)" FORCE)
+set (HDF5_MINGW_STATIC_GCC_LIBS ON CACHE BOOL "Statically link libgcc/libstdc++" FORCE)
+
set (HDF5_ALLOW_EXTERNAL_SUPPORT "NO" CACHE STRING "Allow External Library Building (NO GIT TGZ)" FORCE)
set_property (CACHE HDF5_ALLOW_EXTERNAL_SUPPORT PROPERTY STRINGS NO GIT TGZ)
diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt
index ed27bb2..89d3ac0 100644
--- a/release_docs/INSTALL_CMake.txt
+++ b/release_docs/INSTALL_CMake.txt
@@ -778,6 +778,7 @@ HDF5_WANT_DATA_ACCURACY "IF data accuracy is guaranteed during data conve
HDF5_WANT_DCONV_EXCEPTION "exception handling functions is checked during data conversions" ON
HDF5_ENABLE_THREADSAFE "Enable Threadsafety" OFF
HDF5_MSVC_NAMING_CONVENTION "Use MSVC Naming conventions for Shared Libraries" OFF
+HDF5_MINGW_STATIC_GCC_LIBS "Statically link libgcc/libstdc++" OFF
if (APPLE)
HDF5_BUILD_WITH_INSTALL_NAME "Build with library install_name set to the installation path" OFF
if (CMAKE_BUILD_TYPE MATCHES Debug)
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 70af053..43356527 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -54,6 +54,13 @@ New Features
when using a MinGW toolchain
(xan - 2020/10/30)
+
+ - CMake option to statically link gcc libs with MinGW
+
+ HDF5_MINGW_STATIC_GCC_LIBS allows to statically link libg/libstdc++
+ with the MinGW toolchain
+
+ (xan - 2020/10/30)
- CMake option to build the HDF filter plugins project as an external project