Skip to content

Commit

Permalink
mingw-w64 fixes (#317)
Browse files Browse the repository at this point in the history
* cmake: use FindThreads module
* cmake: don't use msvc syntax on pkg-config file
* cmake: include ws2_32 for mingw too
  • Loading branch information
wiiaboo authored and rndi committed Mar 23, 2018
1 parent 33e01d4 commit 56d3d3c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ project(SRT C CXX)
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
include(haiUtil)
include(FindPkgConfig)
include(FindThreads)

set (SRT_VERSION 1.2.2)
set_version_variables(SRT_VERSION ${SRT_VERSION})
Expand Down Expand Up @@ -226,8 +227,10 @@ else()
message(FATAL_ERROR "Failed to find pthread library. Specify PTHREAD_LIBRARY.")
endif()

elseif(THREADS_FOUND)
set(PTHREAD_LIBRARY ${CMAKE_THREAD_LIBS_INIT})
else()
find_library(PTHREAD_LIBRARY NAMES pthread pthreadGC2 pthreadGC)
find_library(PTHREAD_LIBRARY NAMES pthread pthreadGC2 pthreadGC)
endif() # if (NOT MINGW)

# This is required in some projects that add some other sources
Expand Down Expand Up @@ -364,8 +367,8 @@ set_target_properties (${TARGET_haicrypt} PROPERTIES VERSION ${SRT_VERSION} SOVE
target_link_libraries(${TARGET_haicrypt} PRIVATE ${SRT_LIBS_PRIVATE} ${SSL_LIBRARIES})

if ( WIN32 AND NOT CYGWIN )
target_link_libraries(${TARGET_haicrypt} PRIVATE ws2_32.lib)
set (SRT_LIBS_PRIVATE ${SRT_LIBS_PRIVATE} ws2_32.lib)
target_link_libraries(${TARGET_haicrypt} PRIVATE ws2_32)
set (SRT_LIBS_PRIVATE ${SRT_LIBS_PRIVATE} "-lws2_32")
endif()

# ---
Expand All @@ -389,8 +392,8 @@ if (ENABLE_SHARED)
target_compile_definitions(${TARGET_srt} PUBLIC -DUDT_DYNAMIC)
endif()

if ( WIN32 AND (NOT MINGW AND NOT CYGWIN) )
target_link_libraries(${TARGET_srt} PUBLIC Ws2_32.lib)
if ( WIN32 AND NOT CYGWIN )
target_link_libraries(${TARGET_srt} PUBLIC ws2_32)
endif()

install(TARGETS ${TARGET_srt}
Expand Down

0 comments on commit 56d3d3c

Please sign in to comment.