Skip to content

Commit

Permalink
feat: add building with pem-pack (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vollstrecker committed Mar 8, 2024
1 parent 841354c commit 5adc155
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ option(
ON
)

option(
CRYPTOPP_USE_PEM_PACK
"Include the PEM-Pack in compiliation (https://github.com/noloader/cryptopp-pem)"
)

if(CRYPTOPP_INCLUDE_PREFIX)
set(CRYPTOPP_INCLUDE_PREFIX
${CRYPTOPP_INCLUDE_PREFIX}
Expand Down
13 changes: 13 additions & 0 deletions cmake/GetCryptoppSources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ if(GIT_FOUND)
SOURCE_DIR
${CRYPTOPP_INCLUDE_PREFIX}
)
fetchcontent_declare(
cryptopp-pem
GIT_REPOSITORY "https://github.com/noloader/cryptopp-pem"
QUIET
)
else()
message(STATUS "Downloading crypto++ from URL...")
cmake_policy(SET CMP0135 NEW)
Expand All @@ -39,5 +44,13 @@ else()
cryptopp
URL "${source_location}.zip" QUIET SOURCE_DIR ${CRYPTOPP_INCLUDE_PREFIX}
)
fetchcontent_declare(
cryptopp-pem
URL "https://github.com/noloader/cryptopp-pem/archive/refs/heads/master.zip"
QUIET
)
endif()
fetchcontent_populate(cryptopp)
if(CRYPTOPP_USE_PEM_PACK)
fetchcontent_populate(cryptopp-pem)
endif()
26 changes: 26 additions & 0 deletions cryptopp/sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ set(cryptopp_SOURCES
zlib.cpp
)

set(cryptopp_SOURCES_PEM
"${cryptopp-pem_SOURCE_DIR}/pem_common.cpp"
"${cryptopp-pem_SOURCE_DIR}/pem_eol.cxx"
"${cryptopp-pem_SOURCE_DIR}/pem_read.cpp"
"${cryptopp-pem_SOURCE_DIR}/pem_write.cpp"
"${cryptopp-pem_SOURCE_DIR}/x509cert.cpp"
)

# ***** Library headers *****
set(cryptopp_HEADERS
3way.h
Expand Down Expand Up @@ -374,6 +382,11 @@ set(cryptopp_HEADERS
zlib.h
)

set(cryptopp_HEADERS_PEM
"${cryptopp-pem_SOURCE_DIR}/pem_common.h"
"${cryptopp-pem_SOURCE_DIR}/x509cert.h"
)

# ***** Test sources *****
set(cryptopp_SOURCES_TEST
# adhoc.cpp
Expand Down Expand Up @@ -448,3 +461,16 @@ if(ANDROID)
${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c
)
endif()

if(CRYPTOPP_USE_PEM_PACK)
list(
APPEND
cryptopp_SOURCES
${cryptopp_SOURCES_PEM}
)
list(
APPEND
cryptopp_HEADERS
${cryptopp_HEADERS_PEM}
)
endif()

0 comments on commit 5adc155

Please sign in to comment.