build: add mingw64 cross-compiling

This commit is contained in:
kwkam 2017-12-09 18:06:40 +08:00
parent c639152541
commit 7b684afbc0
2 changed files with 129 additions and 39 deletions

View File

@ -34,6 +34,10 @@ SET(SOURCES
src/libui_sdl/libui/common/matrix.c
src/libui_sdl/libui/common/shouldquit.c
src/libui_sdl/libui/common/userbugs.c
)
if (UNIX)
LIST(APPEND SOURCES
src/libui_sdl/libui/unix/alloc.c
src/libui_sdl/libui/unix/area.c
src/libui_sdl/libui/unix/box.c
@ -72,9 +76,9 @@ SET(SOURCES
src/libui_sdl/libui/unix/tab.c
src/libui_sdl/libui/unix/text.c
src/libui_sdl/libui/unix/util.c
src/libui_sdl/libui/unix/window.c)
src/libui_sdl/libui/unix/window.c
)
if (UNIX)
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
@ -86,6 +90,68 @@ if (UNIX)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
LINK_LIBRARIES("dl")
endif ()
elseif (WIN32)
LIST(APPEND SOURCES
src/libui_sdl/libui/windows/alloc.cpp
src/libui_sdl/libui/windows/area.cpp
src/libui_sdl/libui/windows/areadraw.cpp
src/libui_sdl/libui/windows/areaevents.cpp
src/libui_sdl/libui/windows/areascroll.cpp
src/libui_sdl/libui/windows/areautil.cpp
src/libui_sdl/libui/windows/box.cpp
src/libui_sdl/libui/windows/button.cpp
src/libui_sdl/libui/windows/checkbox.cpp
src/libui_sdl/libui/windows/colorbutton.cpp
src/libui_sdl/libui/windows/colordialog.cpp
src/libui_sdl/libui/windows/combobox.cpp
src/libui_sdl/libui/windows/container.cpp
src/libui_sdl/libui/windows/control.cpp
src/libui_sdl/libui/windows/d2dscratch.cpp
src/libui_sdl/libui/windows/datetimepicker.cpp
src/libui_sdl/libui/windows/debug.cpp
src/libui_sdl/libui/windows/draw.cpp
src/libui_sdl/libui/windows/drawmatrix.cpp
src/libui_sdl/libui/windows/drawpath.cpp
src/libui_sdl/libui/windows/drawtext.cpp
src/libui_sdl/libui/windows/dwrite.cpp
src/libui_sdl/libui/windows/editablecombo.cpp
#src/libui_sdl/libui/windows/entry.cpp
src/libui_sdl/libui/windows/events.cpp
src/libui_sdl/libui/windows/fontbutton.cpp
src/libui_sdl/libui/windows/fontdialog.cpp
src/libui_sdl/libui/windows/form.cpp
src/libui_sdl/libui/windows/graphemes.cpp
src/libui_sdl/libui/windows/grid.cpp
src/libui_sdl/libui/windows/group.cpp
src/libui_sdl/libui/windows/init.cpp
src/libui_sdl/libui/windows/label.cpp
src/libui_sdl/libui/windows/main.cpp
src/libui_sdl/libui/windows/menu.cpp
src/libui_sdl/libui/windows/multilineentry.cpp
src/libui_sdl/libui/windows/parent.cpp
src/libui_sdl/libui/windows/progressbar.cpp
src/libui_sdl/libui/windows/radiobuttons.cpp
src/libui_sdl/libui/windows/separator.cpp
src/libui_sdl/libui/windows/sizing.cpp
src/libui_sdl/libui/windows/slider.cpp
src/libui_sdl/libui/windows/spinbox.cpp
src/libui_sdl/libui/windows/stddialogs.cpp
#src/libui_sdl/libui/windows/tab.cpp
#src/libui_sdl/libui/windows/tabpage.cpp
src/libui_sdl/libui/windows/text.cpp
src/libui_sdl/libui/windows/utf16.cpp
src/libui_sdl/libui/windows/utilwin.cpp
src/libui_sdl/libui/windows/window.cpp
src/libui_sdl/libui/windows/winpublic.cpp
src/libui_sdl/libui/windows/winutil.cpp
src/libui_sdl/libui/windows/resources.rc
)
LINK_LIBRARIES("comctl32")
LINK_LIBRARIES("d2d1")
LINK_LIBRARIES("dwrite")
LINK_LIBRARIES("usp10")
LINK_LIBRARIES("ws2_32")
endif (UNIX)
find_package(SDL2 REQUIRED)

View File

@ -0,0 +1,24 @@
# https://cmake.org/Wiki/CMake_Cross_Compiling
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)
SET(COMPILER_PREFIX "x86_64-w64-mingw32")
# which compilers to use for C and C++
find_program(CMAKE_C_COMPILER NAMES ${COMPILER_PREFIX}-gcc)
find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++)
find_program(CMAKE_RC_COMPILER NAMES ${COMPILER_PREFIX}-windres)
# pkg-config
find_program(PKG_CONFIG_EXECUTABLE NAMES ${COMPILER_PREFIX}-pkg-config)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX}/sys-root/mingw)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)