Skip to content

Commit

Permalink
Enable linking against BoringSSL
Browse files Browse the repository at this point in the history
  • Loading branch information
bifurcation committed Jul 17, 2023
1 parent 68c3244 commit a05b0d7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
30 changes: 18 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,25 @@ endif()
###

# External libraries

set(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../boringssl/")
set(OPENSSL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../boringssl/include")
set(OPENSSL_CRYPTO_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/../boringssl/build/crypto/libcrypto.a")
find_package(OpenSSL REQUIRED)
if ( OPENSSL_FOUND )
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()

#find_package(OpenSSL REQUIRED)
#if ( OPENSSL_FOUND )
# 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)
Expand Down
8 changes: 5 additions & 3 deletions lib/hpke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ set(CURRENT_LIB_NAME hpke)
###
### Dependencies
###
find_package(OpenSSL 1.1 REQUIRED)

###
### Library Config
Expand All @@ -14,9 +13,12 @@ file(GLOB_RECURSE LIB_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src

add_library(${CURRENT_LIB_NAME} ${LIB_HEADERS} ${LIB_SOURCES})
add_dependencies(${CURRENT_LIB_NAME} bytes tls_syntax)
target_link_libraries(${CURRENT_LIB_NAME} PRIVATE bytes tls_syntax OpenSSL::Crypto)
target_link_libraries(${CURRENT_LIB_NAME} PRIVATE bytes tls_syntax crypto)
target_include_directories(${CURRENT_LIB_NAME}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE
${OPENSSL_INCLUDE_DIR}
)

###
Expand Down
2 changes: 1 addition & 1 deletion lib/hpke/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ file(GLOB TEST_SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

add_executable(${TEST_APP_NAME} ${TEST_SOURCES})
add_dependencies(${TEST_APP_NAME} ${CURRENT_LIB_NAME} bytes tls_syntax)
target_link_libraries(${TEST_APP_NAME} ${CURRENT_LIB_NAME} bytes tls_syntax doctest::doctest OpenSSL::Crypto)
target_link_libraries(${TEST_APP_NAME} ${CURRENT_LIB_NAME} bytes tls_syntax doctest::doctest crypto)

# Enable CTest
include(doctest)
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ add_dependencies(${TEST_APP_NAME} ${LIB_NAME} bytes tls_syntax mls_vectors)
target_include_directories(${TEST_APP_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(${TEST_APP_NAME} ${LIB_NAME}
bytes tls_syntax mls_vectors
doctest::doctest OpenSSL::Crypto)
doctest::doctest crypto)

# Enable CTest
include(doctest)
Expand Down

0 comments on commit a05b0d7

Please sign in to comment.