MinGW: Better finding libraries
This commit is contained in:
parent
cb7eab4f03
commit
89d5cee4c1
@ -278,7 +278,7 @@ else()
|
|||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(PTHREAD_NAMES pthreadVC2)
|
set(PTHREAD_NAMES pthreadVC2)
|
||||||
elseif(MINGW)
|
elseif(MINGW)
|
||||||
set(PTHREAD_NAMES "winpthread-1" pthreadGC2)
|
set(PTHREAD_NAMES "winpthread-1" "pthreadGC2" "libwinpthread-1")
|
||||||
endif()
|
endif()
|
||||||
find_library(PTHREAD_LIBRARY NAMES pthread ${PTHREAD_NAMES} PATHS ${PROJECT_SOURCE_DIR}/dependencies/lib)
|
find_library(PTHREAD_LIBRARY NAMES pthread ${PTHREAD_NAMES} PATHS ${PROJECT_SOURCE_DIR}/dependencies/lib)
|
||||||
mark_as_advanced(PTHREAD_LIBRARY)
|
mark_as_advanced(PTHREAD_LIBRARY)
|
||||||
@ -380,12 +380,22 @@ if(MSVC OR MINGW)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
find_library(LIBGCC NAMES libgcc_s_dw2-1.dll libgcc_s_sjlj-1.dll)
|
find_library(LIBGCC NAMES "libgcc_s_dw2-1.dll" "libgcc_s_sjlj-1.dll" PATHS ${CMAKE_FIND_ROOT_PATH})
|
||||||
find_library(LIBSTDCPP NAMES libstdc++-6.dll)
|
if(LIBGCC)
|
||||||
if(OPENMP_FOUND)
|
file(COPY ${LIBGCC} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
|
||||||
find_library(LIBOPENMP NAMES libgomp-1.dll)
|
endif()
|
||||||
|
find_library(LIBSTDCPP NAMES "libstdc++-6.dll" PATHS ${CMAKE_FIND_ROOT_PATH})
|
||||||
|
if(LIBSTDCPP)
|
||||||
|
file(COPY ${LIBSTDCPP} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
|
||||||
|
endif()
|
||||||
|
find_library(LIBOPENMP NAMES "libgomp-1.dll" PATHS ${CMAKE_FIND_ROOT_PATH})
|
||||||
|
if(LIBOPENMP)
|
||||||
|
file(COPY ${LIBOPENMP} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
|
||||||
|
endif()
|
||||||
|
find_library(LIBPTHREAD NAMES "winpthread-1.dll" "pthreadGC2.dll" "libwinpthread-1.dll" PATHS ${CMAKE_FIND_ROOT_PATH})
|
||||||
|
if(LIBPTHREAD)
|
||||||
|
file(COPY ${LIBPTHREAD} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
|
||||||
endif()
|
endif()
|
||||||
file(COPY ${LIBGCC} ${LIBSTDCPP} ${PTHREAD_LIBRARY} ${LIBOPENMP} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Optional tools
|
# Optional tools
|
||||||
|
@ -7,11 +7,11 @@ SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++-posix)
|
|||||||
SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
|
SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
|
||||||
|
|
||||||
# here is the target environment located
|
# here is the target environment located
|
||||||
SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32 ${PROJECT_SOURCE_DIR}/dependencies)
|
SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32 /usr/lib/gcc/i686-w64-mingw32/4.9-posix ${PROJECT_SOURCE_DIR}/dependencies)
|
||||||
|
|
||||||
# adjust the default behaviour of the FIND_XXX() commands:
|
# adjust the default behaviour of the FIND_XXX() commands:
|
||||||
# search headers and libraries in the target environment, search
|
# search headers and libraries in the target environment, search
|
||||||
# programs in the host environment
|
# programs in the host environment
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ALWAYS)
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
Loading…
Reference in New Issue
Block a user