Skip to content

Commit 6e7cab7

Browse files
committed
CMakeLists.txt: added an option to enable Cross-compile on windows instead of detecting. Avoid potential unwanted situation with existing build system
1 parent 8007772 commit 6e7cab7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

CMakeLists.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ cmake_minimum_required(VERSION 3.10)
44
project(openFPGALoader VERSION "1.0.0" LANGUAGES CXX)
55
add_definitions(-DVERSION=\"v${PROJECT_VERSION}\")
66

7-
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
8-
set(windows_crosscompile ON)
9-
else()
10-
set(windows_crosscompile OFF)
11-
endif()
7+
option(WINDOWS_CROSSCOMPILE "Enable cross-compile on windows" OFF)
8+
#if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
9+
# set(WINDOWS_CROSSCOMPILE ON)
10+
#else()
11+
# set(WINDOWS_CROSSCOMPILE OFF)
12+
#endif()
1213

1314
####################################################################################################
1415
# Generics Options
@@ -38,7 +39,7 @@ option(ENABLE_CABLE_ALL "Enable all cables" ON
3839
option(ENABLE_ANLOGIC_CABLE "enable Anlogic cable (requires libUSB)" ${ENABLE_CABLE_ALL})
3940
option(ENABLE_CH347 "enable CH347 cable (requires libUSB)" ${ENABLE_CABLE_ALL})
4041
# CMSIS-DAP requires hidapi which is complex to cross-compile, disable by default for cross-compilation
41-
if (NOT windows_crosscompile)
42+
if (NOT WINDOWS_CROSSCOMPILE)
4243
option(ENABLE_CMSISDAP "enable cmsis DAP interface (requires hidapi)" ${ENABLE_CABLE_ALL})
4344
else()
4445
option(ENABLE_CMSISDAP "enable cmsis DAP interface (requires hidapi)" OFF)
@@ -127,7 +128,7 @@ endif()
127128
####################################################################################################
128129

129130
# Detect cross-compilation for Windows from Linux/macOS
130-
if(windows_crosscompile)
131+
if(WINDOWS_CROSSCOMPILE)
131132
set(CROSS_COMPILING_WINDOWS TRUE)
132133
message(STATUS "Cross-compiling for Windows from ${CMAKE_HOST_SYSTEM_NAME}")
133134

@@ -233,7 +234,7 @@ if (USE_PKGCONFIG)
233234
# during cross-compilation and to allow static linking selection.
234235
find_package(ZLIB QUIET)
235236
if (NOT ZLIB_FOUND)
236-
if (windows_crosscompile)
237+
if (WINDOWS_CROSSCOMPILE)
237238
message(FATAL_ERROR
238239
"zlib for Windows target not found. Install MinGW zlib development files "
239240
"(for example: libz-mingw-w64-dev on Debian/Ubuntu or mingw64-zlib on Fedora).")

0 commit comments

Comments
 (0)