Skip to content

Commit

Permalink
DAVE
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis committed Sep 25, 2024
1 parent 39eeece commit 97eebb4
Show file tree
Hide file tree
Showing 112 changed files with 26,692 additions and 6 deletions.
21 changes: 18 additions & 3 deletions library-vcpkg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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")
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")

set(LIB_NAME "${PROJECT_NAME}")

Expand Down Expand Up @@ -40,8 +40,8 @@ target_compile_options(
PRIVATE
"$<$<PLATFORM_ID:Windows>:$<$<CONFIG:Debug>:/sdl;/Od;/DEBUG;/MP;/DFD_SETSIZE=1024>>"
"$<$<PLATFORM_ID:Windows>:$<$<CONFIG:Release>:/O2;/Oi;/Oy;/GL;/Gy;/sdl;/MP;/DFD_SETSIZE=1024>>"
"$<$<PLATFORM_ID:Linux>:$<$<CONFIG:Debug>:-Wall;-Wempty-body;-Wno-psabi;-Wunknown-pragmas;-Wignored-qualifiers;-Wimplicit-fallthrough;-Wmissing-field-initializers;-Wsign-compare;-Wtype-limits;-Wuninitialized;-Wshift-negative-value;-pthread;-g;-Og;-fPIC>>"
"$<$<PLATFORM_ID:Linux>:$<$<CONFIG:Release>:-Wall;-Wempty-body;-Wno-psabi;-Wunknown-pragmas;-Wignored-qualifiers;-Wimplicit-fallthrough;-Wmissing-field-initializers;-Wsign-compare;-Wtype-limits;-Wuninitialized;-Wshift-negative-value;-pthread;-O3;-fPIC>>"
"$<$<PLATFORM_ID:Linux>:$<$<CONFIG:Debug>:-fPIC;-Wall;-Wempty-body;-Wno-psabi;-Wunknown-pragmas;-Wignored-qualifiers;-Wimplicit-fallthrough;-Wmissing-field-initializers;-Wsign-compare;-Wtype-limits;-Wuninitialized;-Wshift-negative-value;-pthread;-g;-Og;-fPIC>>"
"$<$<PLATFORM_ID:Linux>:$<$<CONFIG:Release>:-fPIC;-Wall;-Wempty-body;-Wno-psabi;-Wunknown-pragmas;-Wignored-qualifiers;-Wimplicit-fallthrough;-Wmissing-field-initializers;-Wsign-compare;-Wtype-limits;-Wuninitialized;-Wshift-negative-value;-pthread;-O3;-fPIC>>"
"${AVX_FLAG}"
)

Expand All @@ -60,6 +60,11 @@ 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")

set_target_properties(
"${LIB_NAME}" PROPERTIES
OUTPUT_NAME "dpp"
Expand Down Expand Up @@ -90,6 +95,16 @@ 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
)

set(CONFIG_FILE_NAME "${PROJECT_NAME}Config.cmake")
set(EXPORTED_TARGETS_NAME "${PROJECT_NAME}Targets")
set(EXPORTED_TARGETS_FILE_NAME "${EXPORTED_TARGETS_NAME}.cmake")
Expand Down
23 changes: 20 additions & 3 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ if(MSVC)
endif()
string(REGEX REPLACE "/W[1|2|3|4]" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-private-field -Wno-psabi -Wempty-body -Wignored-qualifiers -Wimplicit-fallthrough -Wmissing-field-initializers -Wsign-compare -Wtype-limits -Wuninitialized -Wshift-negative-value -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wno-unused-private-field -Wno-psabi -Wempty-body -Wignored-qualifiers -Wimplicit-fallthrough -Wmissing-field-initializers -Wsign-compare -Wtype-limits -Wuninitialized -Wshift-negative-value -pthread")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")

if (NOT MINGW)
Expand All @@ -209,11 +209,16 @@ 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")

foreach (fullmodname ${subdirlist})
get_filename_component(modname ${fullmodname} NAME)
set (modsrc "")
file(GLOB modsrc "${modules_dir}/dpp/*.cpp" "${modules_dir}/dpp/events/*.cpp" "${modules_dir}/dpp/cluster/*.cpp" "${modules_dir}/dpp/*.rc")

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(BUILD_SHARED_LIBS)
add_library(${modname} SHARED ${modsrc})
Expand Down Expand Up @@ -241,6 +246,7 @@ foreach (fullmodname ${subdirlist})
endif()

if (WIN32 AND NOT MINGW)

if (NOT WINDOWS_32_BIT)
target_link_libraries(${modname} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libcrypto.lib"
Expand All @@ -262,13 +268,24 @@ foreach (fullmodname ${subdirlist})
endif ()
endif()

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

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

include_directories(${OPUS_INCLUDE_DIRS} ${sodium_INCLUDE_DIR})
endif()
endforeach()



target_compile_features(dpp PUBLIC cxx_std_17)
target_compile_features(dpp PRIVATE cxx_constexpr)
target_compile_features(dpp PRIVATE cxx_auto_type)
Expand Down
196 changes: 196 additions & 0 deletions mlspp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
cmake_minimum_required(VERSION 3.13)

project(mlspp
VERSION 0.1
LANGUAGES CXX
)

option(TESTING "Build tests" OFF)
option(CLANG_TIDY "Perform linting with clang-tidy" OFF)
option(SANITIZERS "Enable sanitizers" OFF)
option(MLS_NAMESPACE_SUFFIX "Namespace Suffix for CXX and CMake Export")
option(DISABLE_GREASE "Disables the inclusion of MLS protocol recommended GREASE values" OFF)
option(REQUIRE_BORINGSSL "Require BoringSSL instead of OpenSSL" OFF)

if(MLS_NAMESPACE_SUFFIX)
set(MLS_CXX_NAMESPACE "mls_${MLS_NAMESPACE_SUFFIX}" CACHE STRING "Top-level Namespace for CXX")
set(MLS_EXPORT_NAMESPACE "MLSPP${MLS_NAMESPACE_SUFFIX}" CACHE STRING "Namespace for CMake Export")
else()
set(MLS_CXX_NAMESPACE "../include/dpp/mlspp/mls" CACHE STRING "Top-level Namespace for CXX")
set(MLS_EXPORT_NAMESPACE "MLSPP" CACHE STRING "Namespace for CMake Export")
endif()
message(STATUS "CXX Namespace: ${MLS_CXX_NAMESPACE}")
message(STATUS "CMake Export Namespace: ${MLS_EXPORT_NAMESPACE}")


###
### Global Config
###
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

configure_file(
"cmake/namespace.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/include/namespace.h"
@ONLY
)

include(CheckCXXCompilerFlag)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wall -pedantic -Wextra -Werror -Wmissing-declarations)
elseif(MSVC)
add_compile_options(/W4 /WX)
add_definitions(-DWINDOWS)

# MSVC helpfully recommends safer equivalents for things like
# getenv, but they are not portable.
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()

if("$ENV{MACOSX_DEPLOYMENT_TARGET}" STREQUAL "10.11")
add_compile_options(-DVARIANT_COMPAT)
endif()

if (DISABLE_GREASE)
add_compile_options(-DDISABLE_GREASE)
endif ()

###
### Dependencies
###

# Configure vcpkg to only build release libraries
set(VCPKG_BUILD_TYPE release)

# External libraries
find_package(OpenSSL REQUIRED)
if ( OPENSSL_FOUND )
find_path(BORINGSSL_INCLUDE_DIR openssl/is_boringssl.h HINTS ${OPENSSL_INCLUDE_DIR} NO_DEFAULT_PATH)

if (BORINGSSL_INCLUDE_DIR)
message(STATUS "Found OpenSSL includes are for BoringSSL")

add_compile_definitions(WITH_BORINGSSL)

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wno-gnu-anonymous-struct -Wno-nested-anon-types)
endif ()

file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/crypto.h" boringssl_version_str
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_TEXT[\t ]+\"OpenSSL ([0-9])+\\.([0-9])+\\.([0-9])+ .+")

string(REGEX REPLACE "^.*OPENSSL_VERSION_TEXT[\t ]+\"OpenSSL ([0-9]+\\.[0-9]+\\.[0-9])+ .+$"
"\\1" OPENSSL_VERSION "${boringssl_version_str}")

elseif (REQUIRE_BORINGSSL)
message(FATAL_ERROR "BoringSSL required but not found")
endif ()

if (${OPENSSL_VERSION} VERSION_GREATER_EQUAL 3)
add_compile_definitions(WITH_OPENSSL3)
elseif(${OPENSSL_VERSION} VERSION_LESS 1.1.1)
message(FATAL_ERROR "OpenSSL 1.1.1 or greater is required")
endif()
message(STATUS "OpenSSL Found: ${OPENSSL_VERSION}")
message(STATUS "OpenSSL Include: ${OPENSSL_INCLUDE_DIR}")
message(STATUS "OpenSSL Libraries: ${OPENSSL_LIBRARIES}")
else()
message(FATAL_ERROR "No OpenSSL library found")
endif()

# Internal libraries
add_subdirectory(lib)

# Third-Party libraries in tree
add_subdirectory(third_party)


###
### Library Config
###

set(LIB_NAME "${PROJECT_NAME}")

file(GLOB_RECURSE LIB_HEADERS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
file(GLOB_RECURSE LIB_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")

add_library(${LIB_NAME} STATIC ${LIB_HEADERS} ${LIB_SOURCES})
add_dependencies(${LIB_NAME} bytes tls_syntax hpke)
target_link_libraries(${LIB_NAME} bytes tls_syntax hpke)
target_include_directories(${LIB_NAME}
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
PRIVATE
${OPENSSL_INCLUDE_DIR}
)

install(TARGETS ${LIB_NAME} EXPORT mlspp-targets)


###
### Exports
###
set(CMAKE_EXPORT_PACKAGE_REGISTRY ON)
export(
EXPORT
mlspp-targets
NAMESPACE
${MLS_EXPORT_NAMESPACE}::
FILE
${MLS_EXPORT_NAMESPACE}Targets.cmake)
export(PACKAGE ${MLS_EXPORT_NAMESPACE})

configure_package_config_file(cmake/config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${MLS_EXPORT_NAMESPACE}Config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/${MLS_EXPORT_NAMESPACE}
NO_SET_AND_CHECK_MACRO)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${MLS_EXPORT_NAMESPACE}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)

###
### Install
###

install(
EXPORT
mlspp-targets
NAMESPACE
${MLS_EXPORT_NAMESPACE}::
FILE
${MLS_EXPORT_NAMESPACE}Targets.cmake
DESTINATION
${CMAKE_INSTALL_DATADIR}/${MLS_EXPORT_NAMESPACE})

install(
DIRECTORY
include
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${MLS_EXPORT_NAMESPACE}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${MLS_EXPORT_NAMESPACE}ConfigVersion.cmake
DESTINATION
${CMAKE_INSTALL_DATADIR}/${MLS_EXPORT_NAMESPACE})

install(
FILES
LICENSE
DESTINATION
${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
RENAME
copyright)

include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/bytes/include")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/hpke/include")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/mls_vectors/include")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/tls_syntax/include")
25 changes: 25 additions & 0 deletions mlspp/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BSD 2-Clause License

Copyright (c) 2018, Cisco Systems
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4 changes: 4 additions & 0 deletions mlspp/cmake/config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@PACKAGE_INIT@

include(${CMAKE_CURRENT_LIST_DIR}/@[email protected])
check_required_components(mlspp)
4 changes: 4 additions & 0 deletions mlspp/cmake/namespace.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

// Configurable top-level MLS namespace
#define MLS_NAMESPACE @MLS_CXX_NAMESPACE@
Loading

0 comments on commit 97eebb4

Please sign in to comment.