From 4892db5b0e54affb4a4eb635220c6669acb0d5ba Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 29 Oct 2018 20:41:12 -0400 Subject: [PATCH] Discover OpenSSL engines directory The directory can be overriden by setting the CMake variable OPENSSL_ENGINES_DIR --- .gitignore | 1 - .travis.yml | 2 +- CMakeLists.txt | 15 ++++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 3558c56..567609b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -bin/ build/ diff --git a/.travis.yml b/.travis.yml index 8f023cf..ae592a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,5 +31,5 @@ before_script: - cd .. script: - - cmake -DOPENSSL_ROOT_DIR=${PREFIX} -DOPENSSL_LIBRARIES=${PREFIX}/lib && make + - cmake -DOPENSSL_ROOT_DIR=${PREFIX} -DOPENSSL_LIBRARIES=${PREFIX}/lib -DOPENSSL_ENGINES_DIR=${PREFIX}/engines && make - make test diff --git a/CMakeLists.txt b/CMakeLists.txt index 774a1a7..55b86c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,16 @@ set(OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/${BIN_DIRECTORY}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY}) +# Remove when https://gitlab.kitware.com/cmake/cmake/issues/18525 is addressed +set(OPENSSL_ENGINES_DIR "" CACHE PATH "OpenSSL Engines Directory") +if ("${OPENSSL_ENGINES_DIR}" STREQUAL "") + include(FindPkgConfig) + pkg_get_variable(OPENSSL_ENGINES_DIR libcrypto enginesdir) + if ("${OPENSSL_ENGINES_DIR}" STREQUAL "") + message( FATAL_ERROR "Unable to discover the OpenSSL engines directory. Provide the path using -DOPENSSL_ENGINES_DIR" ) + endif() +endif() + set(GOST_89_SOURCE_FILES gost89.c gost89.h @@ -164,14 +174,13 @@ add_custom_target(tags WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) # install -set(OPENSSL_ENGINES_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/engines-${OPENSSL_VERSION_MAJOR}_${OPENSSL_VERSION_MINOR}) set(OPENSSL_MAN_INSTALL_DIR ${CMAKE_INSTALL_MANDIR}/man1) install(TARGETS gost_engine gostsum gost12sum EXPORT GostEngineConfig - LIBRARY DESTINATION ${OPENSSL_ENGINES_INSTALL_DIR} + LIBRARY DESTINATION ${OPENSSL_ENGINES_DIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES gostsum.1 gost12sum.1 DESTINATION ${OPENSSL_MAN_INSTALL_DIR}) if (MSVC) - install(FILES $ DESTINATION ${OPENSSL_ENGINES_INSTALL_DIR} OPTIONAL) + install(FILES $ DESTINATION ${OPENSSL_ENGINES_DIR} OPTIONAL) install(FILES $ $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) endif() -- 2.39.5