Add crypto and ssl if using bundled curl

Fixes #926.
This commit is contained in:
heinrich5991 2017-10-24 15:29:53 +02:00
parent 19a8054df6
commit f3abdd43cb
6 changed files with 46 additions and 16 deletions

View file

@ -91,11 +91,22 @@ endfunction()
function(set_extra_dirs_include VARIABLE NAME LIBRARY)
set("PATHS_${VARIABLE}_INCLUDEDIR" PARENT_SCOPE)
set("HINTS_${VARIABLE}_INCLUDEDIR" PARENT_SCOPE)
if(LIBRARY)
string(FIND "${LIBRARY}" "${PROJECT_SOURCE_DIR}" LOCAL_PATH_POS)
if(LOCAL_PATH_POS EQUAL 0 AND TARGET_BITS AND TARGET_OS)
is_bundled(IS_BUNDLED "${LIBRARY}")
if(IS_BUNDLED)
set("HINTS_${VARIABLE}_INCLUDEDIR" "ddnet-libs/${NAME}/include" PARENT_SCOPE)
endif()
endfunction()
function(is_bundled VARIABLE PATH)
if(PATH)
string(FIND "${PATH}" "${PROJECT_SOURCE_DIR}" LOCAL_PATH_POS)
if(LOCAL_PATH_POS EQUAL 0 AND TARGET_BITS AND TARGET_OS)
set("${VARIABLE}" ON PARENT_SCOPE)
else()
set("${VARIABLE}" OFF PARENT_SCOPE)
endif()
else()
set("${VARIABLE}" OFF PARENT_SCOPE)
endif()
endfunction()
@ -130,8 +141,8 @@ message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Dependencies:")
function(show_dependency_status NAME FOUND PATH)
if(FOUND)
string(FIND "${PATH}" "${PROJECT_SOURCE_DIR}" LOCAL_PATH_POS)
if(LOCAL_PATH_POS EQUAL 0)
is_bundled(IS_BUNDLED "${PATH}")
if(IS_BUNDLED)
message(STATUS " * ${NAME} not found (using bundled version)")
else()
message(STATUS " * ${NAME} found")

View file

@ -18,11 +18,30 @@ find_package_handle_standard_args(Curl DEFAULT_MSG CURL_LIBRARY CURL_INCLUDEDIR)
mark_as_advanced(CURL_LIBRARY CURL_INCLUDEDIR)
is_bundled(IS_BUNDLED "${CURL_LIBRARY}")
set(CURL_LIBRARIES ${CURL_LIBRARY})
set(CURL_INCLUDE_DIRS ${CURL_INCLUDEDIR})
if(IS_BUNDLED AND TARGET_OS STREQUAL "linux")
find_library(CURL_LIBRARY_SSL
NAMES ssl
HINTS ${EXTRA_CURL_LIBDIR}
)
find_library(CURL_LIBRARY_CRYPTO
NAMES crypto
HINTS ${EXTRA_CURL_LIBDIR}
)
# If we don't add `dl`, we get a missing reference to `dlclose`:
# ```
# /usr/bin/ld: ../ddnet-libs/curl/linux/lib64/libcrypto.a(dso_dlfcn.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
# ```
#
# Order matters, SSL needs to be linked before CRYPTO, otherwise we also get
# undefined symbols.
list(APPEND CURL_LIBRARIES ${CURL_LIBRARY_SSL} ${CURL_LIBRARY_CRYPTO} dl)
endif()
string(FIND "${CURL_LIBRARY}" "${PROJECT_SOURCE_DIR}" LOCAL_PATH_POS)
if(LOCAL_PATH_POS EQUAL 0 AND TARGET_OS STREQUAL "windows")
if(IS_BUNDLED AND TARGET_OS STREQUAL "windows")
set(CURL_COPY_FILES
"${EXTRA_CURL_LIBDIR}/libcurl.dll"
)

View file

@ -23,8 +23,8 @@ mark_as_advanced(FREETYPE_LIBRARY FREETYPE_INCLUDEDIR)
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY})
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDEDIR})
string(FIND "${FREETYPE_LIBRARY}" "${PROJECT_SOURCE_DIR}" LOCAL_PATH_POS)
if(LOCAL_PATH_POS EQUAL 0 AND TARGET_OS STREQUAL "windows")
is_bundled(IS_BUNDLED "${FREETYPE_LIBRARY}")
if(IS_BUNDLED AND TARGET_OS STREQUAL "windows")
set(FREETYPE_COPY_FILES "${EXTRA_FREETYPE_LIBDIR}/libfreetype.dll")
else()
set(FREETYPE_COPY_FILES)

View file

@ -21,8 +21,8 @@ mark_as_advanced(GLEW_LIBRARY GLEW_INCLUDEDIR)
set(GLEW_LIBRARIES ${GLEW_LIBRARY})
set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDEDIR})
string(FIND "${GLEW_LIBRARY}" "${PROJECT_SOURCE_DIR}" LOCAL_PATH_POS)
if(LOCAL_PATH_POS EQUAL 0 AND TARGET_OS STREQUAL "windows")
is_bundled(IS_BUNDLED "${GLEW_LIBRARY}")
if(IS_BUNDLED AND TARGET_OS STREQUAL "windows")
set(GLEW_COPY_FILES "${EXTRA_GLEW_LIBDIR}/glew32.dll")
else()
set(GLEW_COPY_FILES)

View file

@ -22,15 +22,15 @@ mark_as_advanced(OPUSFILE_LIBRARY OPUSFILE_INCLUDEDIR)
set(OPUSFILE_LIBRARIES ${OPUSFILE_LIBRARY})
set(OPUSFILE_INCLUDE_DIRS ${OPUSFILE_INCLUDEDIR})
string(FIND "${OPUSFILE_LIBRARY}" "${PROJECT_SOURCE_DIR}" LOCAL_PATH_POS)
if(LOCAL_PATH_POS EQUAL 0 AND TARGET_OS STREQUAL "windows")
is_bundled(IS_BUNDLED "${OPUSFILE_LIBRARY}")
if(IS_BUNDLED AND TARGET_OS STREQUAL "windows")
set(OPUSFILE_COPY_FILES
"${EXTRA_OPUSFILE_LIBDIR}/libogg.dll"
"${EXTRA_OPUSFILE_LIBDIR}/libopus.dll"
"${EXTRA_OPUSFILE_LIBDIR}/libopusfile.dll"
"${EXTRA_OPUSFILE_LIBDIR}/libwinpthread-1.dll"
)
if (TARGET_BITS EQUAL 32)
if(TARGET_BITS EQUAL 32)
list(APPEND OPUSFILE_COPY_FILES
"${EXTRA_OPUSFILE_LIBDIR}/libgcc_s_sjlj-1.dll"
)

View file

@ -24,8 +24,8 @@ mark_as_advanced(SDL2_LIBRARY SDL2_INCLUDEDIR)
set(SDL2_LIBRARIES ${SDL2_LIBRARY})
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDEDIR})
string(FIND "${SDL2_LIBRARY}" "${PROJECT_SOURCE_DIR}" LOCAL_PATH_POS)
if(LOCAL_PATH_POS EQUAL 0 AND TARGET_OS STREQUAL "windows")
is_bundled(IS_BUNDLED "${SDL2_LIBRARY}")
if(IS_BUNDLED AND TARGET_OS STREQUAL "windows")
set(SDL2_COPY_FILES "${EXTRA_SDL2_LIBDIR}/SDL2.dll")
else()
set(SDL2_COPY_FILES)