Skip to content

Commit

Permalink
Added build improvements from 'master' branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Małecki committed Dec 7, 2017
1 parent 4fc5c2c commit f2cb544
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 33 deletions.
55 changes: 35 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,19 @@ endif()
set_if(DARWIN ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set_if(LINUX ${CMAKE_SYSTEM_NAME} MATCHES "Linux")

# When you use crosscompiling, you have to take care that PKT_CONFIG_PATH
# When you use crosscompiling, you have to take care that PKG_CONFIG_PATH
# and CMAKE_PREFIX_PATH are set properly.

# find OpenSSL
if ( USE_GNUTLS )
pkg_check_modules (SSL REQUIRED gnutls nettle)
set (SSL_REQUIRED_MODULES "gnutls nettle")
if (WIN32)
if (MINGW)
set (SSL_REQUIRED_MODULES "${SSL_REQUIRED_MODULES} zlib")
endif()
endif()

pkg_check_modules (SSL REQUIRED ${SSL_REQUIRED_MODULES})

add_definitions(
-DUSE_GNUTLS=1
Expand Down Expand Up @@ -243,21 +250,24 @@ if (${ENABLE_PROFILE} AND HAVE_COMPILER_GNU_COMPAT)
endif()


# find pthread
find_path(PTHREAD_INCLUDE_DIR pthread.h HINTS C:/pthread-win32/include)
if (PTHREAD_INCLUDE_DIR)
message(STATUS "Pthread include dir: ${PTHREAD_INCLUDE_DIR}")
if (MINGW)
set (PTHREAD_LIBRARY -lpthreadGC2)
else()
message(FATAL_ERROR "Failed to find pthread.h. Specify PTHREAD_INCLUDE_DIR.")
endif()
# find pthread
find_path(PTHREAD_INCLUDE_DIR pthread.h HINTS C:/pthread-win32/include)
if (PTHREAD_INCLUDE_DIR)
message(STATUS "Pthread include dir: ${PTHREAD_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Failed to find pthread.h. Specify PTHREAD_INCLUDE_DIR.")
endif()

find_library(PTHREAD_LIBRARY NAMES pthread pthread_dll pthread_lib HINTS C:/pthread-win32/lib)
if (PTHREAD_LIBRARY)
message(STATUS "Pthread library: ${PTHREAD_LIBRARY}")
else()
message(FATAL_ERROR "Failed to find pthread library. Specify PTHREAD_LIBRARY.")
endif()

if (PTHREAD_LIBRARY)
message(STATUS "Pthread library: ${PTHREAD_LIBRARY}")
else()
message(FATAL_ERROR "Failed to find pthread library. Specify PTHREAD_LIBRARY.")
endif()
endif() # if (NOT MINGW)

# This is required in some projects that add some other sources
# to the SRT library to be compiled together (aka "virtual library").
Expand Down Expand Up @@ -400,7 +410,8 @@ target_include_directories(${TARGET_haicrypt}
set_target_properties (${TARGET_haicrypt} PROPERTIES VERSION ${SRT_VERSION} SOVERSION ${SRT_VERSION_MAJOR})
target_link_libraries(${TARGET_haicrypt} PRIVATE ${SSL_LIBRARIES})
set (SRT_LIBS_PRIVATE ${SSL_LIBRARIES})
if (WIN32)

if ( WIN32 AND (NOT MINGW AND NOT CYGWIN) )
target_link_libraries(${TARGET_haicrypt} PRIVATE ws2_32.lib)
set (SRT_LIBS_PRIVATE ${SRT_LIBS_PRIVATE} ws2_32.lib)
endif()
Expand All @@ -414,7 +425,7 @@ target_link_libraries (${TARGET_srt} PUBLIC ${PTHREAD_LIBRARY} ${DEPENDS_srt})
set (SRT_LIBS_PRIVATE ${SRT_LIBS_PRIVATE} ${PTHREAD_LIBRARY})
target_include_directories(${TARGET_srt} PUBLIC ${PTHREAD_INCLUDE_DIR} ${SRT_SRC_SRTCORE_DIR})

# Not sure why it's required, but somehow only on Linux
# Not sure why librt is required, but somehow only on Linux
if ( LINUX )
target_link_libraries(${TARGET_srt} PUBLIC rt)
target_link_libraries(${TARGET_srt} PUBLIC dl)
Expand All @@ -427,10 +438,8 @@ if (ENABLE_SHARED)
target_compile_definitions(${TARGET_srt} PUBLIC -DSRT_DYNAMIC)
endif()

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

install(TARGETS ${TARGET_srt}
Expand Down Expand Up @@ -494,6 +503,11 @@ endif()

if ( ENABLE_CXX11 )

if ( MINGW )
# FIXME: with MINGW, it fails to build stransmit
# https://github.com/Haivision/srt/issues/177
message(WARNING "On MinGW, C++11 apps are blocked due to lacking proper C++11 headers for <thread>. FIX IF POSSIBLE.")
else()
set (SOURCES_transmit
${CMAKE_CURRENT_SOURCE_DIR}/common/uriparser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/common/socketoptions.cpp
Expand Down Expand Up @@ -581,6 +595,7 @@ if ( ENABLE_CXX11 )
target_link_libraries(srt-file-transmit ${TARGET_srt} ${DEPENDS_srt})
install(TARGETS srt-file-transmit RUNTIME DESTINATION bin)
endif()
endif() # ( MINGW )

install(PROGRAMS scripts/srt-ffplay DESTINATION bin)

Expand Down
27 changes: 15 additions & 12 deletions configure-data.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -364,23 +364,26 @@ proc postprocess {} {
}

if { $::HAVE_DARWIN } {
# ON Darwin there's a problem with linking against the Mac-provided OpenSSL.
# This must use brew-provided OpenSSL.
#
if { !$have_openssl || !$have_gnutls } {

set er [catch {exec brew info openssl} res]
if { $er } {
error "You must have OpenSSL installed from 'brew' tool. The standard Mac version is inappropriate."
}

lappend ::cmakeopt "-DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include"
lappend ::cmakeopt "-DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib/libcrypto.a"
} elseif { $have_gnutls } {
if { $have_gnutls } {
set er [catch {exec brew info gnutls} res]
if { $er } {
error "Cannot find gnutls in brew"
}
} else {
# ON Darwin there's a problem with linking against the Mac-provided OpenSSL.
# This must use brew-provided OpenSSL.
#
if { !$have_openssl } {

set er [catch {exec brew info openssl} res]
if { $er } {
error "You must have OpenSSL installed from 'brew' tool. The standard Mac version is inappropriate."
}

lappend ::cmakeopt "-DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include"
lappend ::cmakeopt "-DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib/libcrypto.a"
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion srtcore/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ inline std::string SockaddrToString(const sockaddr* sadr)

std::ostringstream output;
char hostbuf[1024];
if (inet_ntop(sadr->sa_family, addr, hostbuf, 1024))
if (!getnameinfo(sadr, sizeof(*sadr), hostbuf, 1024, NULL, 0, NI_NAMEREQD))
{
output << hostbuf;
}
Expand Down

0 comments on commit f2cb544

Please sign in to comment.