A cross-platform CMake module for building OpenSSL from source using FetchContent and ExternalProject.
- Cross-platform support: Windows, macOS, and Linux (x86_64 and ARM64)
- Automatic dependency management: Uses CMake's FetchContent to download OpenSSL source
- Static and shared library builds: Configurable via
OPENSSL_SHAREDoption - Parallel builds: Automatically detects CPU cores for faster compilation
- Standard CMake targets: Provides
OpenSSL::SSLandOpenSSL::Cryptoimported targets - CI/CD tested: GitHub Actions workflow tests builds across all supported platforms
# REQUIRED: Set the OpenSSL version
set(OPENSSL_VERSION "openssl-3.5.1") # or any other version tag
# Include the CMake module
include(path/to/CMakeLists.txt)
# Your targets can now link against OpenSSL
target_link_libraries(your_target OpenSSL::SSL OpenSSL::Crypto)The OPENSSL_VERSION variable must be set before including the CMakeLists.txt. There is no default fallback:
set(OPENSSL_VERSION "openssl-3.4.0") # Required - no default
include(path/to/CMakeLists.txt)Control whether to build static or shared libraries using the OPENSSL_SHARED option:
set(OPENSSL_SHARED OFF) # Default: OFF (static libraries)
# or
set(OPENSSL_SHARED ON) # Build shared libraries (.dll/.so/.dylib)
set(OPENSSL_VERSION "openssl-3.5.1")
include(path/to/CMakeLists.txt)Control whether to see OpenSSL build output in real-time:
set(OPENSSL_VERBOSE ON) # Default: ON (shows real-time output)
# or
set(OPENSSL_VERBOSE OFF) # Quiet mode (logs to files only)
set(OPENSSL_VERSION "openssl-3.5.1")
include(path/to/CMakeLists.txt)When OPENSSL_VERBOSE is ON (default), output is displayed directly to the console as the build progresses.
When OFF, build output is logged to files in the build directory for later review.
Note: This doesn't work on Windows yet.
- CMake 3.14+
- Perl (required for OpenSSL configuration)
- NASM (Netwide Assembler) - required for OpenSSL builds
- Platform-specific build tools:
- Windows: Visual Studio with nmake (install jom for parallel builds)
- macOS: Xcode Command Line Tools
- Linux: GCC/Clang and make
- The
OPENSSL_VERSIONvariable is required and must be set before including the CMake module - Default build type is static libraries. Use
OPENSSL_SHARED=ONfor shared libraries - On Windows, shared builds will produce both .lib (import libraries) and .dll files
- Install jom to parallelize the OpenSSL build step (nmake is single-threaded):
choco install jom -y - After install, reconfigure your build. Our CMake will auto-detect jom and use
jom -j<N>(where N is the detected core count orOPENSSL_JOBSif set). - For live output during builds, prefer the Ninja generator; MSBuild buffers ExternalProject output.
BSD 3-Clause License - see LICENSE file for details.