cmake: Install MinGW libraries

These libraries must be installed into the bin/ directory in order to
run the speed-dreams-2 executable.

Note that MinGW is distributed with several flavours and therefore might
define different names for libgcc. [1] libstdc++-6.dll has also been
found on different directories depending on the flavour. On the other
hand, libssp might not be available on some distributions, so it remains
optional.

[1]: https://wiki.unvanquished.net/wiki/MinGW


git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9602 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 84c850bd58150fc67bdd124c0a353815185f86b0
Former-commit-id: 602c3a1227936c9da5b727c9e10ae6c90526227d
This commit is contained in:
xavi92 2024-10-27 08:06:42 +00:00
parent 7cd494f55e
commit ec2222a1a4
2 changed files with 56 additions and 4 deletions

View file

@ -230,9 +230,57 @@ MACRO(SD_INSTALL_CUSTOM_3RDPARTY TARGET_NAME)
ELSEIF(MINGW)
# Works with MinGW 4.4 and 4.7.
# Works with MinGW 14.2.0.
GET_FILENAME_COMPONENT(_MINGW_BINDIR "${CMAKE_CXX_COMPILER}" PATH)
SET(_COMPILER_DLL_PATHNAMES "${_MINGW_BINDIR}/libstdc++-6.dll;${_MINGW_BINDIR}/libgcc_s_dw2-1.dll")
GET_FILENAME_COMPONENT(_MINGW_BINDIR "${_MINGW_BINDIR}/../" REALPATH)
FIND_FILE(libstdcxx_path "libstdc++-6.dll"
HINTS
"${_MINGW_BINDIR}/bin"
"${_MINGW_BINDIR}/lib"
"${_MINGW_BINDIR}/*/bin"
"${_MINGW_BINDIR}/*/lib"
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
FIND_FILE(libgcc_path
NAMES
"libgcc_s_seh-1.dll"
"libgcc_s_dw2-1.dll"
"libgcc_s_sjlj-1.dll"
HINTS
"${_MINGW_BINDIR}/bin"
"${_MINGW_BINDIR}/lib"
"${_MINGW_BINDIR}/*/bin"
"${_MINGW_BINDIR}/*/lib"
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
FIND_FILE(libssp_path "libssp-0.dll"
HINTS
"${_MINGW_BINDIR}/bin"
"${_MINGW_BINDIR}/lib"
"${_MINGW_BINDIR}/*/bin"
"${_MINGW_BINDIR}/*/lib"
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
IF(libstdcxx_path STREQUAL "libstdcxx_path-NOTFOUND")
MESSAGE(FATAL_ERROR "Could not find libstdc++")
ENDIF()
IF(libgcc_path STREQUAL "libgcc_path-NOTFOUND")
MESSAGE(FATAL_ERROR "Could not find libgcc")
ENDIF()
IF(libssp_path STREQUAL "libssp_path-NOTFOUND")
MESSAGE(STATUS "Could not find libssp. speed-dreams-2 might be unable to run.")
ELSE()
SET(_COMPILER_DLL_PATHNAMES "${libssp_path}")
ENDIF()
SET(_COMPILER_DLL_PATHNAMES
${_COMPILER_DLL_PATHNAMES}
"${libstdcxx_path}"
"${libgcc_path}"
)
ENDIF(MSVC)

View file

@ -115,8 +115,12 @@ MACRO(SD_UPDATE_SETTINGS_VERSION)
IF(MINGW AND NOT CMAKE_GENERATOR STREQUAL "MSYS Makefiles")
GET_FILENAME_COMPONENT(_MINGW_BINDIR "${CMAKE_CXX_COMPILER}" PATH)
LIST(APPEND _DLLS_TO_INSTALL "${_MINGW_BINDIR}/libstdc++-6.dll")
LIST(APPEND _DLLS_TO_INSTALL "${_MINGW_BINDIR}/libgcc_s_dw2-1.dll")
LIST(APPEND _DLLS_TO_INSTALL "${libstdcxx_path}")
LIST(APPEND _DLLS_TO_INSTALL "${libgcc_path}")
IF(NOT libssp_path STREQUAL "libssp_path-NOTFOUND")
LIST(APPEND _DLLS_TO_INSTALL "${libssp_path}")
ENDIF()
ENDIF(MINGW AND NOT CMAKE_GENERATOR STREQUAL "MSYS Makefiles")