Skip to content

Commit ee5c3e1

Browse files
Andrey Borisovichlgirdwood
Andrey Borisovich
authored andcommitted
Added handling of OpenSSL on Windows with MSYS2
Added new MSYS_INSTALL_DIR variable that points to MSYS2 installation for Windows users. It is used to include POSIX native headers from /usr/include also required openssl headers. Signed-off-by: Andrey Borisovich <[email protected]>
1 parent 1589641 commit ee5c3e1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

CMakeLists.txt

+21
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,27 @@ if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 9.1)
3434
target_compile_options(rimage PRIVATE -Wno-char-subscripts)
3535
endif()
3636

37+
# Windows builds use MSYS2 https://www.msys2.org/ to get linux tools and headers.
38+
# MSYS_INSTALL_DIR variable points to MSYS2 installation directory.
39+
# You may pass it as environmental or cmake configure variable.
40+
if(${CMAKE_HOST_WIN32})
41+
cmake_minimum_required(VERSION 3.20)
42+
if(DEFINED ENV{MSYS_INSTALL_DIR} AND NOT MSYS_INSTALL_DIR)
43+
set(MSYS_INSTALL_DIR $ENV{MSYS_INSTALL_DIR})
44+
endif()
45+
46+
if(MSYS_INSTALL_DIR)
47+
cmake_path(IS_ABSOLUTE MSYS_INSTALL_DIR IS_MSYS_INSTALL_DIR_ABSOLUTE)
48+
if(NOT IS_MSYS_INSTALL_DIR_ABSOLUTE)
49+
message(FATAL_ERROR "Please provide absolute path to MSYS2 installation
50+
setting MSYS_INSTALL_DIR env variable")
51+
endif()
52+
# Include standard posix headers. Requires pacman openssl-devel package.
53+
cmake_path(APPEND MSYS_INSTALL_DIR "usr" "include" OUTPUT_VARIABLE MSYS_SYSTEM_INCLUDE_PATH)
54+
target_include_directories(rimage PRIVATE "${MSYS_SYSTEM_INCLUDE_PATH}")
55+
endif()
56+
endif()
57+
3758
target_link_libraries(rimage PRIVATE crypto)
3859

3960
target_include_directories(rimage PRIVATE

0 commit comments

Comments
 (0)