CMake 3.28 cannot find OpenSSL with MinGW Makefile generator
Hey there:
I tried to generate a MinGW Makefile for my project using OpenSSL, therefore I have the following code in my CMakeLists:
find_package(OpenSSL REQUIRED)
if(NOT OPENSSL_FOUND)
message(FATAL "Cannot find OpenSSL, please check environment")
endif()
On my local dev environment (with CMake 3.24.2 installed) it works perfectly, but when I tried to pack my codes on GitHub Action runners (Windows Server 2022, CMake 3.28.0 & OpenSSL 1.1.1w installed), CMake cannot find OpenSSL when using MinGW Makefile generator.
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/mingw64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at C:/Program Files/CMake/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
OPENSSL_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.28/Modules/FindOpenSSL.cmake:668 (find_package_handle_standard_args)
CMakeLists.txt:33 (find_package)
-- Configuring incomplete, errors occurred!
This bug ONLY occurs by MinGW generator and CMake 3.28. Version 3.27 doesn't have this problem, and version 3.29 isn't tested.
I've already reported this issue to the GitHub Actions team, and they said it's not a thing they could fix, therefore I'm reporting this issue here.