Skip to content

Commit 1d26d3a

Browse files
committed
Update CMakeLists.txt with a slightly better way of handling things.
1 parent f7a7f21 commit 1d26d3a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.21)
33
set(PROJECT_NAME EnigmaFix)
44
# Set the name of the target operating system.
55
set(CMAKE_SYSTEM_NAME Windows)
6+
set(MINGW_TOOLCHAIN_PREFIX x86_64-w64-mingw32)
67

78
if (UNIX) # If compiling on Linux, manually configure MingW-64.
89
# Try to get NAME by checking for NixOS in /etc/os-release
@@ -19,12 +20,14 @@ if (UNIX) # If compiling on Linux, manually configure MingW-64.
1920
# NOTE: We might not even need to adjust the CMAKE_FIND_ROOT_PATH on NixOS, at least with development toolchains.
2021
else()
2122
# Set the Toolchain to MinGW on Linux.
22-
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
23+
set(CMAKE_FIND_ROOT_PATH /usr/${MINGW_TOOLCHAIN_PREFIX})
2324
link_directories(${CMAKE_FIND_ROOT_PATH}/sys-root/mingw/lib) # TODO: Fix to also work with MinGW on Windows.
2425
message(STATUS "This system is not NixOS. It is: ${NAME}. Root Path declaration is necessary.")
2526
endif()
26-
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
27-
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
27+
28+
set(CMAKE_C_COMPILER ${MINGW_TOOLCHAIN_PREFIX}-gcc)
29+
set(CMAKE_CXX_COMPILER ${MINGW_TOOLCHAIN_PREFIX}-g++)
30+
set(CMAKE_RC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}-windres)
2831
# adjust the default behavior of the FIND_XXX() commands:
2932
# Never search for programs in the host environment
3033
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

0 commit comments

Comments
 (0)