aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenjiro Nakayama <nakayamakenjiro@gmail.com>2026-06-15 07:58:06 +0900
committerKenjiro Nakayama <nakayamakenjiro@gmail.com>2026-06-15 10:36:32 +0900
commitc85e07d0d68129fc1b1c9039b266099c8d735c3d (patch)
treeb492957ab6a8f828d083cda10fdde58918eea012
parent00b7d56c290e4cdceeddbb98497c9ff23c49dc32 (diff)
downloadportable-c85e07d0d68129fc1b1c9039b266099c8d735c3d.tar.gz
portable-c85e07d0d68129fc1b1c9039b266099c8d735c3d.tar.bz2
portable-c85e07d0d68129fc1b1c9039b266099c8d735c3d.zip
Allow overriding TLS_DEFAULT_CA_FILE in CMake builds
The CMake build unconditionally defined `TLS_DEFAULT_CA_FILE` as `${OPENSSLDIR}/cert.pem`, so a value supplied with `-DTLS_DEFAULT_CA_FILE` was ignored. Add `TLS_DEFAULT_CA_FILE` as a cache variable and use it for the libtls definition, falling back to `${OPENSSLDIR}/cert.pem` when unset.
-rw-r--r--CMakeLists.txt5
-rw-r--r--tls/CMakeLists.txt2
2 files changed, 6 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7ab04ab..d3424c7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,6 +55,7 @@ option(ENABLE_ASM "Enable assembly" ON)
55option(ENABLE_EXTRATESTS "Enable extra tests that may be unreliable on some platforms" OFF) 55option(ENABLE_EXTRATESTS "Enable extra tests that may be unreliable on some platforms" OFF)
56option(ENABLE_NC "Enable installing TLS-enabled nc(1)" OFF) 56option(ENABLE_NC "Enable installing TLS-enabled nc(1)" OFF)
57set(OPENSSLDIR ${OPENSSLDIR} CACHE PATH "Set the default openssl directory" FORCE) 57set(OPENSSLDIR ${OPENSSLDIR} CACHE PATH "Set the default openssl directory" FORCE)
58set(TLS_DEFAULT_CA_FILE ${TLS_DEFAULT_CA_FILE} CACHE PATH "Set the default CA file" FORCE)
58set(LIBRESSL_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/LibreSSL" CACHE STRING "Installation directory for the CMake targets") 59set(LIBRESSL_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/LibreSSL" CACHE STRING "Installation directory for the CMake targets")
59 60
60option(USE_STATIC_MSVC_RUNTIMES "Use /MT instead of /MD in MSVC" OFF) 61option(USE_STATIC_MSVC_RUNTIMES "Use /MT instead of /MD in MSVC" OFF)
@@ -506,6 +507,10 @@ else()
506 set(CONF_DIR "${OPENSSLDIR}") 507 set(CONF_DIR "${OPENSSLDIR}")
507endif() 508endif()
508 509
510if(TLS_DEFAULT_CA_FILE STREQUAL "")
511 set(TLS_DEFAULT_CA_FILE "${OPENSSLDIR}/cert.pem")
512endif()
513
509add_subdirectory(include) 514add_subdirectory(include)
510add_subdirectory(crypto) 515add_subdirectory(crypto)
511add_subdirectory(ssl) 516add_subdirectory(ssl)
diff --git a/tls/CMakeLists.txt b/tls/CMakeLists.txt
index a1b244a..258cd95 100644
--- a/tls/CMakeLists.txt
+++ b/tls/CMakeLists.txt
@@ -41,7 +41,7 @@ if(WIN32)
41 set(TLS_COMPAT_SRC ${TLS_COMPAT_SRC} compat/pwrite.c) 41 set(TLS_COMPAT_SRC ${TLS_COMPAT_SRC} compat/pwrite.c)
42endif() 42endif()
43 43
44add_definitions(-DTLS_DEFAULT_CA_FILE=\"${OPENSSLDIR}/cert.pem\") 44add_definitions(-DTLS_DEFAULT_CA_FILE=\"${TLS_DEFAULT_CA_FILE}\")
45 45
46file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/tls.sym DESTINATION 46file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/tls.sym DESTINATION
47 ${CMAKE_CURRENT_BINARY_DIR}) 47 ${CMAKE_CURRENT_BINARY_DIR})