Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Add an option to opt-out static libgcc #69

Merged
merged 1 commit into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
xantares marked this conversation as resolved.
Show resolved Hide resolved

if (MSVC)
set (CMAKE_MFC_FLAG 0)
set (WIN_COMPILE_FLAGS "")
Expand Down
4 changes: 2 additions & 2 deletions c++/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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++
)
Expand All @@ -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++
)
Expand Down
2 changes: 1 addition & 1 deletion c++/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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++
)
Expand Down
2 changes: 1 addition & 1 deletion c++/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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++
)
Expand Down
2 changes: 2 additions & 0 deletions config/cmake/cacheinit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions release_docs/INSTALL_CMake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down