Skip to content

Commit

Permalink
minor cleanup of MinGW-related scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
FyiurAmron committed Jun 19, 2024
1 parent 68ea3f5 commit 5f895c8
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 131 deletions.
27 changes: 27 additions & 0 deletions cmake/build_mingw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [ -z "$ARCH" ]; then
ARCH=64
fi
MINGW=mingw$ARCH

if [ -n "$MSYSCON" ]; then
MINGW_PATH=/$MINGW
TOOLCHAIN_NAME="MSYS-$ARCH"
else
MINGW_PATH=/opt/$MINGW
TOOLCHAIN_NAME="MinGW-W64-$ARCH"
fi

export PATH=$MINGW_PATH/bin:$PATH

if [ "$ARCH" == "32" ]; then
export CFLAGS="-march=pentium4 -mtune=generic -mpreferred-stack-boundary=5 -mfpmath=sse"
fi
export CXXFLAGS="$CFLAGS"

CMAKE_OPTS="-DCMAKE_PREFIX_PATH=$MINGW_PATH $CMAKE_OPTS"

# shellcheck disable=SC2086
cmake "$DIR/.." -DCMAKE_TOOLCHAIN_FILE="$DIR/toolchains/$TOOLCHAIN_NAME.cmake" $CMAKE_OPTS
39 changes: 1 addition & 38 deletions cmake/build_win32.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Accomodate both linux windows mingw locations
if [ -z "$ARCH" ]; then
ARCH=32
fi

MINGW=/mingw$ARCH

if [ -z "$MSYSCON" ]; then
MINGW=/opt$MINGW

DISTRO=$(lsb_release -si)
DISTRO_VERSION=$(lsb_release -sr)

if [ "$DISTRO" != "Ubuntu" ]; then
echo "This script only supports Ubuntu"
exit 1
fi

if [ "$DISTRO_VERSION" == "14.04" ]; then
TOOLCHAIN="$DIR/toolchains/Ubuntu-MinGW-X-Trusty-$ARCH.cmake"
else
TOOLCHAIN="$DIR/toolchains/Ubuntu-MinGW-W64-$ARCH.cmake"
fi
else
TOOLCHAIN="$DIR/toolchains/MSYS-$ARCH.cmake"
fi

export PATH=$MINGW/bin:$PATH
export CXXFLAGS="$CFLAGS"
if [ "$ARCH" == "32" ]; then
export CFLAGS="-march=pentium4 -mtune=generic -mpreferred-stack-boundary=5 -mfpmath=sse"
fi

CMAKE_OPTS="-DCMAKE_PREFIX_PATH=$MINGW $CMAKE_OPTS"

# shellcheck disable=SC2086
cmake "$DIR/.." -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" $CMAKE_OPTS
ARCH=32 "$DIR/build_mingw.sh"
2 changes: 1 addition & 1 deletion cmake/build_win64.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ARCH=64 "$DIR/build_win32.sh"
ARCH=64 "$DIR/build_mingw.sh"
2 changes: 2 additions & 0 deletions cmake/toolchains/MinGW-W64-32.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/common/Win32.cmake)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/common/MinGW-W64.cmake)
4 changes: 4 additions & 0 deletions cmake/toolchains/MinGW-W64-64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SET(CMAKE_TOOLCHAIN_FILE_32 "${CMAKE_CURRENT_LIST_DIR}/MinGW-W64-32.cmake")

INCLUDE(${CMAKE_CURRENT_LIST_DIR}/common/Win64.cmake)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/common/MinGW-W64.cmake)
2 changes: 0 additions & 2 deletions cmake/toolchains/Ubuntu-MinGW-W64-32.cmake

This file was deleted.

4 changes: 0 additions & 4 deletions cmake/toolchains/Ubuntu-MinGW-W64-64.cmake

This file was deleted.

3 changes: 0 additions & 3 deletions cmake/toolchains/Ubuntu-MinGW-X-Trusty-32.cmake

This file was deleted.

9 changes: 0 additions & 9 deletions cmake/toolchains/Ubuntu-MinGW-X-Trusty-64.cmake

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Toolchain for Ubuntu MinGw compiler shipped with the mingw-w64 and
# g++-mingw-w64 packages

SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_SYSTEM_VERSION 1)

# Toolchain for MinGW compiler
SET(TOOLCHAIN_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
Expand All @@ -14,4 +17,8 @@ IF(WIN64)
SET(CMAKE_CXX_COMPILER32 ${TOOLCHAIN_PREFIX32}-g++)
ENDIF()

INCLUDE(${CMAKE_CURRENT_LIST_DIR}/WinCrossCompile.cmake)
# Search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Search for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
58 changes: 0 additions & 58 deletions cmake/toolchains/common/Ubuntu-MinGW-X-Trusty.cmake

This file was deleted.

2 changes: 0 additions & 2 deletions cmake/toolchains/common/Win32.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_SYSTEM_VERSION 1)

SET(CMAKE_SYSTEM_PROCESSOR i686)

Expand Down
2 changes: 0 additions & 2 deletions cmake/toolchains/common/Win64.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_SYSTEM_VERSION 1)

SET(CMAKE_SYSTEM_PROCESSOR x86_64)
SET(CMAKE_SYSTEM_PROCESSOR32 i686)
Expand Down
9 changes: 0 additions & 9 deletions cmake/toolchains/common/WinCrossCompile.cmake

This file was deleted.

0 comments on commit 5f895c8

Please sign in to comment.