2018-09-05 10:09:14 -07:00
|
|
|
set(MINGW_PREFIX /usr/x86_64-w64-mingw32/)
|
|
|
|
set(CMAKE_SYSTEM_NAME Windows)
|
|
|
|
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
2018-08-31 11:08:03 -07:00
|
|
|
# Actually a hack, w/o this will cause some strange errors
|
2018-09-05 10:09:14 -07:00
|
|
|
set(CMAKE_HOST_WIN32 TRUE)
|
2018-08-31 11:08:03 -07:00
|
|
|
|
|
|
|
|
2018-09-05 10:09:14 -07:00
|
|
|
set(CMAKE_FIND_ROOT_PATH ${MINGW_PREFIX})
|
|
|
|
set(SDL2_PATH ${MINGW_PREFIX})
|
|
|
|
set(MINGW_TOOL_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32-)
|
2018-08-31 11:08:03 -07:00
|
|
|
|
|
|
|
# Specify the cross compiler
|
2018-09-05 10:09:14 -07:00
|
|
|
set(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}gcc-posix)
|
|
|
|
set(CMAKE_CXX_COMPILER ${MINGW_TOOL_PREFIX}g++-posix)
|
|
|
|
set(CMAKE_RC_COMPILER ${MINGW_TOOL_PREFIX}windres)
|
2018-08-31 11:08:03 -07:00
|
|
|
|
|
|
|
# Mingw tools
|
2018-09-05 10:09:14 -07:00
|
|
|
set(STRIP ${MINGW_TOOL_PREFIX}strip)
|
|
|
|
set(WINDRES ${MINGW_TOOL_PREFIX}windres)
|
|
|
|
set(ENV{PKG_CONFIG} ${MINGW_TOOL_PREFIX}pkg-config)
|
2018-08-31 11:08:03 -07:00
|
|
|
|
|
|
|
# ccache wrapper
|
2018-09-05 10:09:14 -07:00
|
|
|
option(USE_CCACHE "Use ccache for compilation" OFF)
|
|
|
|
if(USE_CCACHE)
|
|
|
|
find_program(CCACHE ccache)
|
|
|
|
if(CCACHE)
|
|
|
|
message(STATUS "Using ccache found in PATH")
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
|
|
|
|
else(CCACHE)
|
|
|
|
message(WARNING "USE_CCACHE enabled, but no ccache found")
|
|
|
|
endif(CCACHE)
|
|
|
|
endif(USE_CCACHE)
|
2018-08-31 11:08:03 -07:00
|
|
|
|
|
|
|
# Search for programs in the build host directories
|
2018-09-05 10:09:14 -07:00
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
2018-08-31 11:08:03 -07:00
|
|
|
|
|
|
|
|
|
|
|
# Echo modified cmake vars to screen for debugging purposes
|
2018-09-05 10:09:14 -07:00
|
|
|
if(NOT DEFINED ENV{MINGW_DEBUG_INFO})
|
|
|
|
message("")
|
|
|
|
message("Custom cmake vars: (blank = system default)")
|
|
|
|
message("-----------------------------------------")
|
|
|
|
message("* CMAKE_C_COMPILER : ${CMAKE_C_COMPILER}")
|
|
|
|
message("* CMAKE_CXX_COMPILER : ${CMAKE_CXX_COMPILER}")
|
|
|
|
message("* CMAKE_RC_COMPILER : ${CMAKE_RC_COMPILER}")
|
|
|
|
message("* WINDRES : ${WINDRES}")
|
|
|
|
message("* ENV{PKG_CONFIG} : $ENV{PKG_CONFIG}")
|
|
|
|
message("* STRIP : ${STRIP}")
|
|
|
|
message("* USE_CCACHE : ${USE_CCACHE}")
|
|
|
|
message("")
|
|
|
|
# So that the debug info only appears once
|
|
|
|
set(ENV{MINGW_DEBUG_INFO} SHOWN)
|
|
|
|
endif()
|