Add support for MinGW cross compiling
This commit is contained in:
@@ -2,4 +2,5 @@ build/current
|
||||
build/gba
|
||||
build/debug
|
||||
build/release
|
||||
build/windows
|
||||
tags
|
||||
|
||||
@@ -26,6 +26,8 @@ devenv:
|
||||
--name ${DEVENV} -t wombatant/devenv bash
|
||||
devenv-destroy:
|
||||
docker rm -f ${DEVENV}
|
||||
devenv-shell:
|
||||
docker exec -i --user $(shell id -u ${USER}) ${DEVENV} ls /usr/bin/x86_64-w64-mingw32-g++
|
||||
|
||||
native:
|
||||
${ENV_RUN} rm -rf build/release
|
||||
@@ -39,6 +41,12 @@ native_debug:
|
||||
${ENV_RUN} rm -f build/current
|
||||
${ENV_RUN} ln -s debug build/current
|
||||
|
||||
windows:
|
||||
${ENV_RUN} rm -rf build/windows
|
||||
${ENV_RUN} ./scripts/setup_build windows
|
||||
${ENV_RUN} rm -f build/current
|
||||
${ENV_RUN} ln -s windows build/current
|
||||
|
||||
gba:
|
||||
${ENV_RUN} rm -rf build/gba
|
||||
${ENV_RUN} ./scripts/setup_build_gba
|
||||
|
||||
+6
-1
@@ -1,4 +1,4 @@
|
||||
all: gba_build native_build native_debug_build
|
||||
all: gba_build native_build native_debug_build windows_build
|
||||
|
||||
gba_build:
|
||||
@if [ -d gba ]; then \
|
||||
@@ -14,3 +14,8 @@ native_debug_build:
|
||||
@if [ -d debug ]; then \
|
||||
make -C debug ${ARGS}; \
|
||||
fi
|
||||
|
||||
windows_build:
|
||||
@if [ -d windows ]; then \
|
||||
make -C windows ${ARGS}; \
|
||||
fi
|
||||
|
||||
@@ -39,5 +39,3 @@ find_path(GBA_INCLUDE_DIR gba.h
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GBA DEFAULT_MSG GBA_LIBRARY)
|
||||
|
||||
set(CMAKE_INSTALL_PREFIX ${DEVKITARM})
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
|
||||
|
||||
# cross compilers to use for C and C++
|
||||
set(CMAKE_C_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-gcc)
|
||||
set(CMAKE_CXX_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-g++)
|
||||
set(CMAKE_RC_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-windres)
|
||||
|
||||
# target environment on the build host system
|
||||
# set 1st to dir with the cross compiler's C/C++ headers/libs
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
|
||||
# modify default behavior of FIND_XXX() commands to
|
||||
# search for headers/libs in the target environment and
|
||||
# search for programs in the build host environment
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
+12
-2
@@ -1,8 +1,18 @@
|
||||
#! /usr/bin/env bash
|
||||
project=$(pwd)/
|
||||
buildDir="build/release"
|
||||
|
||||
TARGET=$1
|
||||
|
||||
if [[ $TARGET == windows ]]; then
|
||||
toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/Mingw.cmake"
|
||||
buildDir="build/windows"
|
||||
else
|
||||
buildDir="build/release"
|
||||
fi
|
||||
|
||||
mkdir -p $buildDir
|
||||
pushd $buildDir
|
||||
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release $project
|
||||
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release \
|
||||
$toolchain \
|
||||
$project
|
||||
popd
|
||||
|
||||
@@ -14,7 +14,7 @@ typedef unsigned short uint16_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned uint_t;
|
||||
#if defined(_MSC_VER) || defined(__APPLE__)
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user