I am using a newer verion of openssl that I installed through Homebrew on my Mac and was wondering if there was a way to set a start path for CMAKE's FIND_PACKAGE function? Right now when I attempt to using FIND_PACKAGE CMAKE finds and older version of openssl that is used by my OS. I am currently using this in my CMakeLists.txt
SET(OPENSSL_LIB_DIR /usr/local/Cellar/openssl/1.0.2f/lib)
INCLUDE_DIRECTORIES(/usr/local/Cellar/openssl/1.0.2f/include)
TARGET_LINK_LIBRARIES(mangaMe ${OPENSSL_LIB_DIR}/libcrypto.dylib ${OPENSSL_LIB_DIR}/libssl.dylib)
The only issue I have with this is that if my openssl updates I have to manually update the version in the path. I have tried reading over the CMAKE FIND_PACKAGE documentation but am not sure which of the many PATH variables I would use to get the effect I am looking for.
You can either set OPENSSL_ROOT_DIR
cmake variable or OPENSSL_ROOT_DIR
env variable to the following path: /usr/local/Cellar/openssl/*
and then use find_package
. Example:
set(OPENSSL_ROOT_DIR /usr/local/Cellar/openssl/*)
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} ${OPENSSL_LIBRARIES})
You can use OPENSSL_ROOT_DIR
before calling FindOpenSSL:
set(OPENSSL_ROOT_DIR /usr/local/Cellar/openssl/1.0.2f/)
include(FindOpenSSL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With