Commit 1f12fc68 authored by Dominik Charousset's avatar Dominik Charousset

Print found version on OpenSSL version mismatch

parent e97b041b
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 2.8.12)
project(caf C CXX) project(caf CXX)
include(CheckCSourceCompiles)
include(CheckCSourceRuns)
# Set default install paths. # Set default install paths.
# See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html # See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
...@@ -601,21 +598,18 @@ elseif(NOT CAF_NO_OPENSSL) ...@@ -601,21 +598,18 @@ elseif(NOT CAF_NO_OPENSSL)
else() else()
if(NOT CMAKE_CROSSCOMPILING) if(NOT CMAKE_CROSSCOMPILING)
# Check if openssl headers and library versions match # Check if openssl headers and library versions match
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) try_run(sslRunResult sslCompileResult
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) "${CMAKE_CURRENT_BINARY_DIR}"
check_c_source_runs(" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/openssl-check.cpp"
#include <openssl/opensslv.h> CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${OPENSSL_INCLUDE_DIR}"
#include <openssl/crypto.h> LINK_LIBRARIES ${OPENSSL_LIBRARIES}
int main() { OUTPUT_VARIABLE sslOutput)
if (SSLeay() == OPENSSL_VERSION_NUMBER) { if (NOT sslCompileResult)
return 0; message(FATAL_ERROR "failed to compile/link against OpenSSL")
} endif()
return -1; if(NOT sslRunResult EQUAL 0)
}
" OPENSSL_CORRECT_VERSION_NUMBER)
if (NOT OPENSSL_CORRECT_VERSION_NUMBER)
message(FATAL_ERROR message(FATAL_ERROR
"OpenSSL library version does not match headers") "OpenSSL version does not match headers: ${sslOutput}")
endif() endif()
endif() endif()
include_directories(BEFORE ${OPENSSL_INCLUDE_DIR}) include_directories(BEFORE ${OPENSSL_INCLUDE_DIR})
......
#include <openssl/crypto.h>
#include <openssl/opensslv.h>
#include <cstdio>
#include <cstdlib>
int main() {
long have = SSLeay();
long want = OPENSSL_VERSION_NUMBER;
printf("have OpenSSL %lx, want %lx\n", have, want);
if (have == want)
return EXIT_SUCCESS;
return EXIT_FAILURE;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment