Skip to content

Commit

Permalink
Comment out most of cmakelists to speedup testing
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankiesz committed Dec 7, 2023
1 parent 977e6c5 commit 8af00c8
Showing 1 changed file with 150 additions and 150 deletions.
300 changes: 150 additions & 150 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,172 +92,172 @@ if(ADD_MUCLIBC)
endif()


message(STATUS "Kinesis Video WebRTC Client path is ${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}")
message(STATUS "dependencies install path is ${OPEN_SRC_INSTALL_PREFIX}")

# pass ca cert location to sdk
add_definitions(-DKVS_CA_CERT_PATH="${CMAKE_SOURCE_DIR}/certs/cert.pem")
add_definitions(-DCMAKE_DETECTED_CACERT_PATH)

if (ENABLE_KVS_THREADPOOL)
add_definitions(-DENABLE_KVS_THREADPOOL)
endif()

if(USE_OPENSSL)
add_definitions(-DKVS_USE_OPENSSL)
elseif(USE_MBEDTLS)
add_definitions(-DKVS_USE_MBEDTLS)
# FIXME: there's probably a better way to inject MBEDTLS_USER_CONFIG_FILE flag without mutating the global CMAKE_C_FLAGS and CMAKE_CXX_FLAGS
if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
message(STATUS "Detected clang")
set(CMAKE_C_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"<config_mbedtls.h>\" ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"<config_mbedtls.h>\" ${CMAKE_CXX_FLAGS}")
else()
message(STATUS "Detected gcc")
set(CMAKE_C_FLAGS "-Wno-error=stringop-overflow -I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"<config_mbedtls.h>\" ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wno-error=stringop-overflow -I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"<config_mbedtls.h>\" ${CMAKE_CXX_FLAGS}")
endif()
endif()

if(BUILD_DEPENDENCIES)
if(NOT EXISTS ${OPEN_SRC_INSTALL_PREFIX})
file(MAKE_DIRECTORY ${OPEN_SRC_INSTALL_PREFIX})
endif()

set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${OPEN_SRC_INSTALL_PREFIX}/lib/pkgconfig")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${OPEN_SRC_INSTALL_PREFIX})

message(STATUS "Begin building dependencies.")

set(SSL_OPTIONS USE_OPENSSL USE_MBEDTLS)
count_true(ENABLED_SSL_OPTION_COUNT ${SSL_OPTIONS})

if(ENABLED_SSL_OPTION_COUNT GREATER "1")
message(FATAL_ERROR "Only one of ${SSL_OPTIONS} can be enabled")
endif()

if (USE_OPENSSL)
set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
-DBUILD_OPENSSL_PLATFORM=${BUILD_OPENSSL_PLATFORM}
-DOPENSSL_EXTRA=${OPENSSL_EXTRA})
build_dependency(openssl ${BUILD_ARGS})
set(OPENSSL_ROOT_DIR ${OPEN_SRC_INSTALL_PREFIX})
elseif(USE_MBEDTLS)
set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -std=c99")
build_dependency(mbedtls ${BUILD_ARGS})
endif()


if(WIN32)
set(OPENSSL_INCLUDE_DIRS "${OPEN_SRC_INSTALL_PREFIX}/include/")
set(OPENSSL_CRYPTO_LIBRARY "${OPEN_SRC_INSTALL_PREFIX}/lib/libcrypto.lib")
set(OPENSSL_SSL_LIBRARY "${OPEN_SRC_INSTALL_PREFIX}/lib/libssl.lib")
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
string(REPLACE ";" "|" OPENSSL_LIBRARIES_ALT_SEP "${OPENSSL_LIBRARIES}")
set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
-DUSE_OPENSSL=${USE_OPENSSL}
-DUSE_MBEDTLS=${USE_MBEDTLS}
-DLWS_EXT_PTHREAD_INCLUDE_DIR=${EXT_PTHREAD_INCLUDE_DIR}
-DLWS_EXT_PTHREAD_LIBRARIES=${EXT_PTHREAD_LIBRARIES}
-DLWS_OPENSSL_INCLUDE_DIRS=${OPENSSL_INCLUDE_DIRS}
-DLWS_OPENSSL_LIBRARIES=${OPENSSL_LIBRARIES_ALT_SEP}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
else()
set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
-DOPENSSL_DIR=${OPEN_SRC_INSTALL_PREFIX}
-DUSE_OPENSSL=${USE_OPENSSL}
-DUSE_MBEDTLS=${USE_MBEDTLS}
-DLWS_OPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}
-DLWS_OPENSSL_SSL_LIBRARY=${OPENSSL_SSL_LIBRARY}
-DLWS_OPENSSL_INCLUDE_DIRS=${OPENSSL_INCLUDE_DIR}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
endif()
build_dependency(websockets ${BUILD_ARGS})

set(BUILD_ARGS
-DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
-DOPENSSL_DIR=${OPEN_SRC_INSTALL_PREFIX}
-DBUILD_LIBSRTP_HOST_PLATFORM=${BUILD_LIBSRTP_HOST_PLATFORM}
-DBUILD_LIBSRTP_DESTINATION_PLATFORM=${BUILD_LIBSRTP_DESTINATION_PLATFORM}
-DUSE_OPENSSL=${USE_OPENSSL}
-DUSE_MBEDTLS=${USE_MBEDTLS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
# message(STATUS "Kinesis Video WebRTC Client path is ${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}")
# message(STATUS "dependencies install path is ${OPEN_SRC_INSTALL_PREFIX}")

# # pass ca cert location to sdk
# add_definitions(-DKVS_CA_CERT_PATH="${CMAKE_SOURCE_DIR}/certs/cert.pem")
# add_definitions(-DCMAKE_DETECTED_CACERT_PATH)

# if (ENABLE_KVS_THREADPOOL)
# add_definitions(-DENABLE_KVS_THREADPOOL)
# endif()

# if(USE_OPENSSL)
# add_definitions(-DKVS_USE_OPENSSL)
# elseif(USE_MBEDTLS)
# add_definitions(-DKVS_USE_MBEDTLS)
# # FIXME: there's probably a better way to inject MBEDTLS_USER_CONFIG_FILE flag without mutating the global CMAKE_C_FLAGS and CMAKE_CXX_FLAGS
# if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
# message(STATUS "Detected clang")
# set(CMAKE_C_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"<config_mbedtls.h>\" ${CMAKE_C_FLAGS}")
# set(CMAKE_CXX_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"<config_mbedtls.h>\" ${CMAKE_CXX_FLAGS}")
# else()
# message(STATUS "Detected gcc")
# set(CMAKE_C_FLAGS "-Wno-error=stringop-overflow -I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"<config_mbedtls.h>\" ${CMAKE_C_FLAGS}")
# set(CMAKE_CXX_FLAGS "-Wno-error=stringop-overflow -I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"<config_mbedtls.h>\" ${CMAKE_CXX_FLAGS}")
# endif()
# endif()

# if(BUILD_DEPENDENCIES)
# if(NOT EXISTS ${OPEN_SRC_INSTALL_PREFIX})
# file(MAKE_DIRECTORY ${OPEN_SRC_INSTALL_PREFIX})
# endif()

# set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${OPEN_SRC_INSTALL_PREFIX}/lib/pkgconfig")
# set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${OPEN_SRC_INSTALL_PREFIX})

# message(STATUS "Begin building dependencies.")

# set(SSL_OPTIONS USE_OPENSSL USE_MBEDTLS)
# count_true(ENABLED_SSL_OPTION_COUNT ${SSL_OPTIONS})

# if(ENABLED_SSL_OPTION_COUNT GREATER "1")
# message(FATAL_ERROR "Only one of ${SSL_OPTIONS} can be enabled")
# endif()

# if (USE_OPENSSL)
# set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
# -DBUILD_OPENSSL_PLATFORM=${BUILD_OPENSSL_PLATFORM}
# -DOPENSSL_EXTRA=${OPENSSL_EXTRA})
# build_dependency(openssl ${BUILD_ARGS})
# set(OPENSSL_ROOT_DIR ${OPEN_SRC_INSTALL_PREFIX})
# elseif(USE_MBEDTLS)
# set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
# "-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -std=c99")
# build_dependency(mbedtls ${BUILD_ARGS})
# endif()


# if(WIN32)
# set(OPENSSL_INCLUDE_DIRS "${OPEN_SRC_INSTALL_PREFIX}/include/")
# set(OPENSSL_CRYPTO_LIBRARY "${OPEN_SRC_INSTALL_PREFIX}/lib/libcrypto.lib")
# set(OPENSSL_SSL_LIBRARY "${OPEN_SRC_INSTALL_PREFIX}/lib/libssl.lib")
# set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
# string(REPLACE ";" "|" OPENSSL_LIBRARIES_ALT_SEP "${OPENSSL_LIBRARIES}")
# set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
# -DUSE_OPENSSL=${USE_OPENSSL}
# -DUSE_MBEDTLS=${USE_MBEDTLS}
# -DLWS_EXT_PTHREAD_INCLUDE_DIR=${EXT_PTHREAD_INCLUDE_DIR}
# -DLWS_EXT_PTHREAD_LIBRARIES=${EXT_PTHREAD_LIBRARIES}
# -DLWS_OPENSSL_INCLUDE_DIRS=${OPENSSL_INCLUDE_DIRS}
# -DLWS_OPENSSL_LIBRARIES=${OPENSSL_LIBRARIES_ALT_SEP}
# -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
# else()
# set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
# -DOPENSSL_DIR=${OPEN_SRC_INSTALL_PREFIX}
# -DUSE_OPENSSL=${USE_OPENSSL}
# -DUSE_MBEDTLS=${USE_MBEDTLS}
# -DLWS_OPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}
# -DLWS_OPENSSL_SSL_LIBRARY=${OPENSSL_SSL_LIBRARY}
# -DLWS_OPENSSL_INCLUDE_DIRS=${OPENSSL_INCLUDE_DIR}
# -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
# endif()
# build_dependency(websockets ${BUILD_ARGS})

# set(BUILD_ARGS
# -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
# -DOPENSSL_DIR=${OPEN_SRC_INSTALL_PREFIX}
# -DBUILD_LIBSRTP_HOST_PLATFORM=${BUILD_LIBSRTP_HOST_PLATFORM}
# -DBUILD_LIBSRTP_DESTINATION_PLATFORM=${BUILD_LIBSRTP_DESTINATION_PLATFORM}
# -DUSE_OPENSSL=${USE_OPENSSL}
# -DUSE_MBEDTLS=${USE_MBEDTLS}
# -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})

build_dependency(srtp ${BUILD_ARGS})
# build_dependency(srtp ${BUILD_ARGS})

set(BUILD_ARGS
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
# set(BUILD_ARGS
# -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})

build_dependency(usrsctp ${BUILD_ARGS})
if(BUILD_TEST)
build_dependency(gtest)
endif()

if(BUILD_BENCHMARK)
build_dependency(benchmark)
endif()
# if(BUILD_BENCHMARK)
# build_dependency(benchmark)
# endif()

if (LINK_PROFILER)
build_dependency(gperftools)
endif()
message(STATUS "Finished building dependencies.")
endif()
# if (LINK_PROFILER)
# build_dependency(gperftools)
# endif()
# message(STATUS "Finished building dependencies.")
# endif()

# building kvsCommonLws also builds kvspic
set(BUILD_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DUSE_OPENSSL=${USE_OPENSSL}
-DUSE_MBEDTLS=${USE_MBEDTLS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
build_dependency(kvsCommonLws ${BUILD_ARGS})
# set(BUILD_ARGS
# -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
# -DUSE_OPENSSL=${USE_OPENSSL}
# -DUSE_MBEDTLS=${USE_MBEDTLS}
# -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
# build_dependency(kvsCommonLws ${BUILD_ARGS})

############# find dependent libraries ############

find_package(Threads)
find_package(PkgConfig REQUIRED)
if (USE_OPENSSL)
find_package(OpenSSL REQUIRED)
set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
else()
find_package(MbedTLS REQUIRED)
set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIRS})
endif()

if (OPEN_SRC_INSTALL_PREFIX)
find_library(SRTP_LIBRARIES srtp2 REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX})

if (LINK_PROFILER)
find_library(GPERFTOOLS_MALLOC_LIBRARIES tcmalloc REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX})
find_library(GPERFTOOLS_PROFILER_LIBRARIES profiler REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX})
endif()
else()
find_library(SRTP_LIBRARIES srtp2 REQUIRED )
if (LINK_PROFILER)
find_library(GPERFTOOLS_MALLOC_LIBRARIES tcmalloc REQUIRED)
find_library(GPERFTOOLS_PROFILER_LIBRARIES profiler REQUIRED)
endif()
endif()

if (WIN32)
SET(LIBWEBSOCKETS_LIBRARIES "websockets.lib")
else()
pkg_check_modules(LIBWEBSOCKETS REQUIRED libwebsockets)
endif()
# find_package(Threads)
# find_package(PkgConfig REQUIRED)
# if (USE_OPENSSL)
# find_package(OpenSSL REQUIRED)
# set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
# else()
# find_package(MbedTLS REQUIRED)
# set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIRS})
# endif()

# if (OPEN_SRC_INSTALL_PREFIX)
# find_library(SRTP_LIBRARIES srtp2 REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX})

# if (LINK_PROFILER)
# find_library(GPERFTOOLS_MALLOC_LIBRARIES tcmalloc REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX})
# find_library(GPERFTOOLS_PROFILER_LIBRARIES profiler REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX})
# endif()
# else()
# find_library(SRTP_LIBRARIES srtp2 REQUIRED )
# if (LINK_PROFILER)
# find_library(GPERFTOOLS_MALLOC_LIBRARIES tcmalloc REQUIRED)
# find_library(GPERFTOOLS_PROFILER_LIBRARIES profiler REQUIRED)
# endif()
# endif()

# if (WIN32)
# SET(LIBWEBSOCKETS_LIBRARIES "websockets.lib")
# else()
# pkg_check_modules(LIBWEBSOCKETS REQUIRED libwebsockets)
# endif()

# usrsctp dont support pkgconfig yet
find_library(
Usrsctp
NAMES ${USRSCTP_LIBNAME} usrsctp REQUIRED
PATHS ${OPEN_SRC_INSTALL_PREFIX}/lib ${OPEN_SRC_INSTALL_PREFIX}/lib64)

set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${LIBSRTP_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS} ${LIBWEBSOCKETS_INCLUDE_DIRS})

link_directories(${LIBSRTP_LIBRARY_DIRS})
link_directories(${LIBWEBSOCKETS_LIBRARY_DIRS})
link_directories(${OPEN_SRC_INSTALL_PREFIX}/lib)
link_directories(${OPEN_SRC_INSTALL_PREFIX}/lib64)
# find_library(
# Usrsctp
# NAMES ${USRSCTP_LIBNAME} usrsctp REQUIRED
# PATHS ${OPEN_SRC_INSTALL_PREFIX}/lib ${OPEN_SRC_INSTALL_PREFIX}/lib64)

# set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${LIBSRTP_INCLUDE_DIRS}
# ${CURL_INCLUDE_DIRS} ${LIBWEBSOCKETS_INCLUDE_DIRS})

# link_directories(${LIBSRTP_LIBRARY_DIRS})
# link_directories(${LIBWEBSOCKETS_LIBRARY_DIRS})
# link_directories(${OPEN_SRC_INSTALL_PREFIX}/lib)
# link_directories(${OPEN_SRC_INSTALL_PREFIX}/lib64)

############# find dependent libraries end ############

Expand Down

0 comments on commit 8af00c8

Please sign in to comment.