build: Add option to download Crypto++ headers to CMake
This commit is contained in:
parent
b3d30a5998
commit
03ee03cd07
|
@ -22,6 +22,7 @@ option(DISABLE_WERROR "Ignore compiler warnings" OFF)
|
|||
|
||||
option(UVGRTP_DISABLE_TESTS "Do not build unit tests" OFF)
|
||||
option(UVGRTP_DISABLE_EXAMPLES "Do not build examples" OFF)
|
||||
option(UVGRTP_DOWNLOAD_CRYPTO "Download headers for Crypto++ if they are missing" OFF)
|
||||
|
||||
include(cmake/FindDependencies.cmake)
|
||||
include(cmake/Versioning.cmake)
|
||||
|
@ -222,9 +223,6 @@ if (UNIX)
|
|||
if(CRYPTOPP_FOUND)
|
||||
list(APPEND UVGRTP_CXX_FLAGS ${CRYPTOPP_CFLAGS_OTHER})
|
||||
list(APPEND UVGRTP_LINKER_FLAGS ${CRYPTOPP_LDFLAGS})
|
||||
else()
|
||||
message("libcrypto++ not found. Encryption will be disabled")
|
||||
list(APPEND UVGRTP_CXX_FLAGS "-D__RTP_NO_CRYPTO__")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -238,6 +236,16 @@ if (UNIX)
|
|||
endif(PkgConfig_FOUND)
|
||||
endif (UNIX)
|
||||
|
||||
if (NOT CRYPTOPP_FOUND AND UVGRTP_DOWNLOAD_CRYPTO)
|
||||
include(cmake/CryptoHeaders.cmake)
|
||||
list(APPEND UVGRTP_CXX_FLAGS ${CRYPTOPP_CFLAGS_OTHER})
|
||||
list(APPEND UVGRTP_LINKER_FLAGS ${CRYPTOPP_LDFLAGS})
|
||||
elseif(NOT CRYPTOPP_FOUND AND UNIX)
|
||||
# In Visual Studio, we want to leave user the option to add Crypto++ headers manually
|
||||
message("libcrypto++ not found. Encryption will be disabled")
|
||||
list(APPEND UVGRTP_CXX_FLAGS "-D__RTP_NO_CRYPTO__")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Security")
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
include(FetchContent)
|
||||
|
||||
message(STATUS "Downloading Crypto++ headers")
|
||||
|
||||
FetchContent_Declare(cryptopp
|
||||
URL https://github.com/weidai11/cryptopp/releases/download/CRYPTOPP_8_7_0/cryptopp870.zip
|
||||
URL_HASH SHA256=d0d3a28fcb5a1f6ed66b3adf57ecfaed234a7e194e42be465c2ba70c744538dd
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(cryptopp)
|
||||
|
||||
file(GLOB CRYPTOPP_HEADERS "${cryptopp_SOURCE_DIR}/*.h")
|
||||
file(MAKE_DIRECTORY ${cryptopp_SOURCE_DIR}/include/cryptopp)
|
||||
file(COPY ${CRYPTOPP_HEADERS} DESTINATION ${cryptopp_SOURCE_DIR}/include/cryptopp)
|
||||
|
||||
include_directories(${cryptopp_SOURCE_DIR}/include)
|
||||
|
Loading…
Reference in New Issue