2018-10-23 15:50:22 +00:00
|
|
|
set(CMAKE_SYSTEM_NAME Windows)
|
|
|
|
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
|
2019-07-28 23:31:07 +00:00
|
|
|
set(TOOLCHAIN_SUFFIX "")
|
2018-10-23 15:50:22 +00:00
|
|
|
|
|
|
|
add_definitions("-DWINNT_CROSS_COMPILE")
|
|
|
|
|
|
|
|
# target environment on the build host system
|
|
|
|
# second one is for non-root installs
|
2019-07-28 23:31:07 +00:00
|
|
|
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} /usr/local/opt/mingw-w64/toolchain-x86_64/ /opt/mingw64 /home/$ENV{USER}/mingw32 /home/$ENV{USER}/mingw64 /home/$ENV{USER}/mingw64/${TOOLCHAIN_PREFIX} /home/$ENV{USER}/mingw32/${TOOLCHAIN_PREFIX})
|
2018-10-23 15:50:22 +00:00
|
|
|
|
|
|
|
# modify default behavior of FIND_XXX() commands
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
|
|
|
|
|
|
# cross compilers to use
|
|
|
|
if($ENV{COMPILER} MATCHES "clang")
|
2019-07-22 22:20:17 +00:00
|
|
|
set(USING_CLANG ON)
|
|
|
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-clang)
|
|
|
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-clang++)
|
2018-10-23 15:50:22 +00:00
|
|
|
else()
|
2019-07-28 23:31:07 +00:00
|
|
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
|
|
|
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
|
2019-07-22 22:20:17 +00:00
|
|
|
add_compile_options("-Wa,-mbig-obj")
|
2018-10-23 15:50:22 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
|
|
|
set(WIN64_CROSS_COMPILE ON)
|