1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Date: Wed, 21 Jun 2023 14:12:26 +0200
Subject: Use system libsexpp library
cherry picked the necessary pieces from upstream commits:
3e9831ac3409095db40b7967866b9197eb36ff64
df4f24bd48b6691692379f1370fde3c12e96e3ab
f9147e72a369f1e412d2f2385cf23a3e9dd6882d
82d9747f1da36db0393c122b451a847cf561bb7c
---
CMakeLists.txt | 29 +++++++++++++++++++++++++----
src/lib/CMakeLists.txt | 28 +++++++++++++++++++---------
src/librekey/g23_sexp.hpp | 4 ++--
src/tests/CMakeLists.txt | 3 ++-
4 files changed, 48 insertions(+), 16 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb6d40c..1d75f1a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,6 +58,8 @@ option(ENABLE_COVERAGE "Enable code coverage testing.")
option(ENABLE_SANITIZERS "Enable ASan and other sanitizers.")
option(ENABLE_FUZZERS "Enable fuzz targets.")
option(DOWNLOAD_GTEST "Download Googletest" On)
+option(SYSTEM_LIBSEXPP "Use system sexpp library" OFF)
+
# crypto components
function(tristate_feature_auto NAME DESCRIPTION)
set(${NAME} Auto CACHE STRING ${DESCRIPTION})
@@ -176,10 +178,29 @@ if (ENABLE_FUZZERS)
endif()
add_subdirectory(src/common)
-set(WITH_SEXP_CLI OFF)
-set(WITH_SEXP_TESTS OFF)
-set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME development)
-add_subdirectory(src/libsexp EXCLUDE_FROM_ALL)
+if (SYSTEM_LIBSEXPP)
+ find_package(PkgConfig QUIET)
+ pkg_check_modules(REQUIRED sexpp>=0.8.7)
+ find_library(SEXPP_LIBRARY
+ NAMES
+ "libsexpp"
+ "sexpp"
+ HINTS
+ "${SEXPP_LIBRARY_DIRS}"
+ )
+ add_library(sexpp UNKNOWN IMPORTED)
+ set_target_properties(sexpp
+ PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${SEXPP_INCLUDE_DIR}"
+ IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
+ IMPORTED_LOCATION "${SEXPP_LIBRARY}"
+ )
+else (SYSTEM_LIBSEXPP)
+ set(WITH_SEXP_CLI OFF)
+ set(WITH_SEXP_TESTS OFF)
+ set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME development)
+ add_subdirectory(src/libsexp EXCLUDE_FROM_ALL)
+endif(SYSTEM_LIBSEXPP)
add_subdirectory(src/lib)
add_subdirectory(src/rnp)
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index 086ac57..e05d1c1 100755
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -320,6 +320,7 @@ target_include_directories(librnp-obj
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/src"
+ "${SEXPP_INCLUDE_DIRS}"
)
target_link_libraries(librnp-obj PRIVATE JSON-C::JSON-C)
if (CRYPTO_BACKEND_BOTAN)
@@ -328,7 +329,7 @@ elseif (CRYPTO_BACKEND_OPENSSL)
target_link_libraries(librnp-obj PRIVATE OpenSSL::Crypto)
endif()
-target_link_libraries(librnp-obj PRIVATE sexp)
+target_link_libraries(librnp-obj PRIVATE sexpp)
set_target_properties(librnp-obj PROPERTIES CXX_VISIBILITY_PRESET hidden)
if (TARGET BZip2::BZip2)
@@ -384,7 +385,7 @@ foreach (prop LINK_LIBRARIES INTERFACE_LINK_LIBRARIES INCLUDE_DIRECTORIES INTERF
get_target_property(val librnp-obj ${prop})
if (BUILD_SHARED_LIBS)
set_property(TARGET librnp-static PROPERTY ${prop} ${val})
- list(REMOVE_ITEM val "$<LINK_ONLY:sexp>")
+ list(REMOVE_ITEM val "$<LINK_ONLY:sexpp>")
set_property(TARGET librnp PROPERTY ${prop} ${val})
else()
set_property(TARGET librnp PROPERTY ${prop} ${val})
@@ -417,8 +418,8 @@ endif()
# On Unix like systems we will build/install/pack shared and static libraries librnp.so and librnp.a
# On Windows we will build/install/pack dynamic, import and static libraries rnp.dll, rnp.lib and rnp-static.lib
-# If a client application uses shared rnp library, sexp is statically linked to librnp.so
-# If a client application uses static rnp library, it still needs libsexp.a
+# If a client application uses shared rnp library, sexpp is statically linked to librnp.so
+# If a client application uses static rnp library, it still needs libsexpp.a
if (BUILD_SHARED_LIBS)
# both static and shared libraries
@@ -432,21 +433,30 @@ install(TARGETS librnp
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT development
)
-
- install(TARGETS librnp-static sexp
+ install(TARGETS librnp-static
EXPORT rnp-targets
ARCHIVE
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT development
)
else(BUILD_SHARED_LIBS)
-# static libraries only
-install(TARGETS librnp sexp
+# static libraries
+# install libsexpp unless system-installed libsexpp is used
+ if (SYSTEM_LIBSEXPP)
+ install(TARGETS librnp
+ EXPORT rnp-targets
+ ARCHIVE
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ COMPONENT development
+ )
+ else (SYSTEM_LIBSEXPP)
+ install(TARGETS librnp sexpp
EXPORT rnp-targets
ARCHIVE
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT development
-)
+ )
+ endif (SYSTEM_LIBSEXPP)
endif(BUILD_SHARED_LIBS)
# install dll only for windows
diff --git a/src/librekey/g23_sexp.hpp b/src/librekey/g23_sexp.hpp
index b888680..b062c52 100644
--- a/src/librekey/g23_sexp.hpp
+++ b/src/librekey/g23_sexp.hpp
@@ -27,8 +27,8 @@
#ifndef RNP_G23_SEXP_HPP
#define RNP_G23_SEXP_HPP
-#include "sexp/sexp.h"
-#include "sexp/ext-key-format.h"
+#include "sexpp/sexp.h"
+#include "sexpp/ext-key-format.h"
#define SXP_MAX_DEPTH 30
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 7d2a6b0..16d30fb 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -171,12 +171,13 @@ target_include_directories(rnp_tests
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/src/lib"
"${BOTAN2_INCLUDE_DIRS}"
+ "${SEXPP_INCLUDE_DIRS}"
)
target_link_libraries(rnp_tests
PRIVATE
librnp-static
JSON-C::JSON-C
- sexp
+ sexpp
${GTestMain}
)
if (CRYPTO_BACKEND_LOWERCASE STREQUAL "openssl")
|