Skip to content

Commit

Permalink
dont build dave and mlspp if HAVE_VOICE is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis committed Oct 3, 2024
1 parent d962ad2 commit 020074a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 29 deletions.
41 changes: 25 additions & 16 deletions library-vcpkg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
file(GLOB THE_SOURCES "${DPP_ROOT_PATH}/src/dpp/events/*.cpp" "${DPP_ROOT_PATH}/dpp/dave/*.cpp" "${DPP_ROOT_PATH}/src/dpp/cluster/*.cpp" "${DPP_ROOT_PATH}/src/dpp/*.cpp" "${DPP_ROOT_PATH}/src/dpp/*.rc")
add_compile_definitions(HAVE_VOICE)

if (HAVE_VOICE)
file(GLOB THE_SOURCES "${DPP_ROOT_PATH}/src/dpp/events/*.cpp" "${DPP_ROOT_PATH}/dpp/dave/*.cpp" "${DPP_ROOT_PATH}/src/dpp/cluster/*.cpp" "${DPP_ROOT_PATH}/src/dpp/*.cpp" "${DPP_ROOT_PATH}/src/dpp/*.rc")
else()
file(GLOB THE_SOURCES "${DPP_ROOT_PATH}/src/dpp/events/*.cpp" "${DPP_ROOT_PATH}/src/dpp/cluster/*.cpp" "${DPP_ROOT_PATH}/src/dpp/*.cpp" "${DPP_ROOT_PATH}/src/dpp/*.rc")
endif()


set(LIB_NAME "${PROJECT_NAME}")

Expand Down Expand Up @@ -62,10 +69,12 @@ target_include_directories(
"$<INSTALL_INTERFACE:include>"
)

add_subdirectory("${DPP_ROOT_PATH}/mlspp" "mlspp")
include_directories("${DPP_ROOT_PATH}/mlspp/include")
include_directories("${DPP_ROOT_PATH}/mlspp/lib/bytes/include")
include_directories("${DPP_ROOT_PATH}/mlspp/lib/hpke/include")
if (HAVE_VOICE)
add_subdirectory("${DPP_ROOT_PATH}/mlspp" "mlspp")
include_directories("${DPP_ROOT_PATH}/mlspp/include")
include_directories("${DPP_ROOT_PATH}/mlspp/lib/bytes/include")
include_directories("${DPP_ROOT_PATH}/mlspp/lib/hpke/include")
endif()

set_target_properties(
"${LIB_NAME}" PROPERTIES
Expand All @@ -78,8 +87,6 @@ target_link_options(
"$<$<PLATFORM_ID:Windows>:$<$<CONFIG:Debug>:/DEBUG>>"
)

add_compile_definitions(HAVE_VOICE)

find_package(nlohmann_json CONFIG REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(Opus CONFIG REQUIRED)
Expand All @@ -97,15 +104,17 @@ target_link_libraries(
$<$<TARGET_EXISTS:Threads::Threads>:Threads::Threads>
)

# Private statically linked dependencies
target_link_libraries(
${LIB_NAME} PRIVATE
mlspp
mls_vectors
bytes
tls_syntax
hpke
)
if (HAVE_VOICE)
# Private statically linked dependencies
target_link_libraries(
${LIB_NAME} PRIVATE
mlspp
mls_vectors
bytes
tls_syntax
hpke
)
endif()

set(CONFIG_FILE_NAME "${PROJECT_NAME}Config.cmake")
set(EXPORTED_TARGETS_NAME "${PROJECT_NAME}Targets")
Expand Down
34 changes: 21 additions & 13 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,22 @@ set(modules_dir "../src")

file(GLOB subdirlist ${modules_dir}/dpp)

add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../mlspp" "mlspp")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../mlspp/include")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../mlspp/lib/bytes/include")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../mlspp/lib/hpke/include")
if (HAVE_VOICE)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../mlspp" "mlspp")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../mlspp/include")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../mlspp/lib/bytes/include")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../mlspp/lib/hpke/include")
endif()

foreach (fullmodname ${subdirlist})
get_filename_component(modname ${fullmodname} NAME)
set (modsrc "")

file(GLOB modsrc "${modules_dir}/dpp/*.cpp" "${modules_dir}/dpp/dave/*.cpp" "${modules_dir}/dpp/events/*.cpp" "${modules_dir}/dpp/cluster/*.cpp" "${modules_dir}/dpp/*.rc")
if (HAVE_VOICE)
file(GLOB modsrc "${modules_dir}/dpp/*.cpp" "${modules_dir}/dpp/dave/*.cpp" "${modules_dir}/dpp/events/*.cpp" "${modules_dir}/dpp/cluster/*.cpp" "${modules_dir}/dpp/*.rc")
else()
file(GLOB modsrc "${modules_dir}/dpp/*.cpp" "${modules_dir}/dpp/events/*.cpp" "${modules_dir}/dpp/cluster/*.cpp" "${modules_dir}/dpp/*.rc")
endif()

if(BUILD_SHARED_LIBS)
add_library(${modname} SHARED ${modsrc})
Expand Down Expand Up @@ -270,14 +276,16 @@ foreach (fullmodname ${subdirlist})
endif ()
endif()

# Private statically linked dependencies
target_link_libraries(${modname} PRIVATE
mlspp
mls_vectors
bytes
tls_syntax
hpke
)
if (HAVE_VOICE)
# Private statically linked dependencies
target_link_libraries(${modname} PRIVATE
mlspp
mls_vectors
bytes
tls_syntax
hpke
)
endif()

if (HAVE_VOICE)
target_link_libraries(${modname} PUBLIC ${sodium_LIBRARY_RELEASE} ${OPUS_LIBRARIES})
Expand Down

0 comments on commit 020074a

Please sign in to comment.