Skip to content

Commit 61b4eaa

Browse files
authored
Make it easier to include boringssl and lsquic via add_subdirectory() (#354)
FIND_LIBRARY will fail if boringssl didn't get build yet, so the following cmake build rule doesn't work: add_subdirectory(third_party/boringssl) set(BORINGSSL_LIB ${CMAKE_CURRENT_BINARY_DIR}/third_party/boringssl) add_subdirectory(third_party/lsquic) The patch fixed it by allow setting BORINGSSL_LIB_foo explicitly, e.g., add_subdirectory(third_party/boringssl) set(BORINGSSL_LIB_ssl ssl) set(BORINGSSL_LIB_crypto crypto) set(BORINGSSL_LIB_decrepit decrepit) add_subdirectory(third_party/lsquic)
1 parent bc20c35 commit 61b4eaa

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

CMakeLists.txt

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,23 +191,33 @@ ELSE()
191191

192192

193193
FOREACH(LIB_NAME ssl crypto decrepit)
194-
IF (CMAKE_SYSTEM_NAME STREQUAL Windows)
195-
FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME}
196-
NAMES ${LIB_NAME}
197-
PATHS ${BORINGSSL_LIB}
198-
PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo
199-
NO_DEFAULT_PATH)
200-
ELSE()
201-
FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME}
202-
NAMES lib${LIB_NAME}${LIB_SUFFIX}
203-
PATHS ${BORINGSSL_LIB}
204-
PATH_SUFFIXES ${LIB_NAME}
205-
NO_DEFAULT_PATH)
194+
# If BORINGSSL_LIB is defined, try find each lib. Otherwise, user should define BORINGSSL_LIB_ssl,
195+
# BORINGSSL_LIB_crypto and so on explicitly. For example, including boringssl and lsquic both via
196+
# add_subdirectory:
197+
# add_subdirectory(third_party/boringssl)
198+
# set(BORINGSSL_LIB_ssl ssl)
199+
# set(BORINGSSL_LIB_crypto crypto)
200+
# set(BORINGSSL_LIB_decrepit decrepit)
201+
# add_subdirectory(third_party/lsquic)
202+
IF (DEFINED BORINGSSL_LIB)
203+
IF (CMAKE_SYSTEM_NAME STREQUAL Windows)
204+
FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME}
205+
NAMES ${LIB_NAME}
206+
PATHS ${BORINGSSL_LIB}
207+
PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo
208+
NO_DEFAULT_PATH)
209+
ELSE()
210+
FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME}
211+
NAMES lib${LIB_NAME}${LIB_SUFFIX}
212+
PATHS ${BORINGSSL_LIB}
213+
PATH_SUFFIXES ${LIB_NAME}
214+
NO_DEFAULT_PATH)
215+
ENDIF()
206216
ENDIF()
207217
IF(BORINGSSL_LIB_${LIB_NAME})
208-
MESSAGE(STATUS "Found ${BORINGSSL_LIB} library: ${BORINGSSL_LIB_${LIB_NAME}}")
218+
MESSAGE(STATUS "Found ${LIB_NAME} library: ${BORINGSSL_LIB_${LIB_NAME}}")
209219
ELSE()
210-
MESSAGE(STATUS "${BORINGSSL_LIB} library not found")
220+
MESSAGE(FATAL_ERROR "BORINGSSL_LIB_${LIB_NAME} library not found")
211221
ENDIF()
212222
ENDFOREACH()
213223

0 commit comments

Comments
 (0)