Skip to content

Commit

Permalink
fix: mingw build (aminya#140)
Browse files Browse the repository at this point in the history
* fix path in toolchain
  • Loading branch information
abeimler committed Nov 20, 2022
1 parent a85248e commit c6b44f9
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 45 deletions.
55 changes: 36 additions & 19 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,39 @@ tasks:
CWD:
sh: git rev-parse --show-toplevel

build_mingw:
cmds:
- task: build
vars:
CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "x86_64-w64-mingw32-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "x86_64-w64-mingw32-g++"}}

build_emscripten:
cmds:
- cmake ./test_emscripten -B ./test_emscripten/build -DCMAKE_BUILD_TYPE:STRING=Debug -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' -DENABLE_CROSS_COMPILING:BOOL=ON -DDEFAULT_TRIPLET=wasm32-emscripten
- cmake --build ./test_emscripten/build --config Debug

# For Testing
build_minimal_mingw:
cmds:
- task: build_minimal
vars:
CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "x86_64-w64-mingw32-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "x86_64-w64-mingw32-g++"}}

build_minimal_mingw_from_env:
env:
CC: x86_64-w64-mingw32-gcc
CXX: x86_64-w64-mingw32-g++
cmds:
- task: build_minimal
vars:
CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON

build_minimal_mingw_from_triplet:
cmds:
- task: build_minimal
vars:
CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DDEFAULT_TRIPLET=x64-mingw-dynamic

test_docker:
- docker-compose up --build build-gcc
- docker-compose up --build test-gcc
Expand All @@ -45,32 +78,16 @@ tasks:

test_docker_mingw:
- docker-compose up --build minimal-build-mingw-x64
- docker-compose up --build minimal-build-mingw-x64-from-env
- docker-compose up --build minimal-build-mingw-x64-from-triplet
- docker-compose up --build build-mingw-x64
- docker-compose up --build build-mingw-x86
- docker-compose down minimal-build-mingw-x64 build-mingw-x64 build-mingw-x86
- docker-compose down minimal-build-mingw-x64 minimal-build-mingw-x64-from-triplet minimal-build-mingw-x64-from-env build-mingw-x64 build-mingw-x86

test_docker_emscripten:
- docker-compose up --build build-emscripten
- docker-compose down build-emscripten

build_minimal_mingw:
cmds:
- task: build_minimal
vars:
CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "x86_64-w64-mingw32-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "x86_64-w64-mingw32-g++"}}

build_mingw:
cmds:
- task: build
vars:
CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "x86_64-w64-mingw32-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "x86_64-w64-mingw32-g++"}}

build_emscripten:
cmds:
- cmake ./test_emscripten -B ./test_emscripten/build -DCMAKE_BUILD_TYPE:STRING=Debug -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' -DENABLE_CROSS_COMPILING:BOOL=ON -DDEFAULT_TRIPLET=wasm32-emscripten
- cmake --build ./test_emscripten/build --config Debug


lint:
- |
{{if eq OS "windows"}}
Expand Down
31 changes: 22 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ services:
target: test
environment:
CMAKE_ARGS: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
minimal-build-mingw-x64:
build:
context: .
dockerfile: ./docker/Dockerfile.mingw
target: build-minimal
environment:
- CROSS_CC=x86_64-w64-mingw32-gcc
- CROSS_CXX=x86_64-w64-mingw32-g++
build-mingw-x64:
build:
context: .
Expand All @@ -65,4 +57,25 @@ services:
build:
context: .
dockerfile: ./docker/Dockerfile.emscripten
target: build
target: build
minimal-build-mingw-x64:
build:
context: .
dockerfile: ./docker/Dockerfile.mingw
target: build-minimal
environment:
- CROSS_CC=x86_64-w64-mingw32-gcc
- CROSS_CXX=x86_64-w64-mingw32-g++
minimal-build-mingw-x64-from-env:
build:
context: .
dockerfile: ./docker/Dockerfile.mingw
target: build-minimal-from-env
environment:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
minimal-build-mingw-x64-from-triplet:
build:
context: .
dockerfile: ./docker/Dockerfile.mingw
target: build-minimal-from-triplet
12 changes: 12 additions & 0 deletions docker/Dockerfile.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,15 @@ FROM setup AS build-minimal
COPY . /home/project_options
WORKDIR /home/project_options
CMD ["/bin/bash", "-c", "task build_minimal_mingw"]


FROM setup AS build-minimal-from-env
COPY . /home/project_options
WORKDIR /home/project_options
CMD ["/bin/bash", "-c", "task build_minimal_mingw_from_env"]


FROM setup AS build-minimal-from-triplet
COPY . /home/project_options
WORKDIR /home/project_options
CMD ["/bin/bash", "-c", "task build_minimal_mingw_from_triplet"]
4 changes: 3 additions & 1 deletion src/CrossCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ macro(enable_cross_compiler)
include("${ProjectOptions_SRC_DIR}/Utilities.cmake")
detect_architecture(_arch)

# detect_compiler()
if("${DEFAULT_TRIPLET}" STREQUAL "")
detect_compiler()
endif()
set(_cc ${CMAKE_C_COMPILER})
set(_cxx ${CMAKE_CXX_COMPILER})

Expand Down
13 changes: 5 additions & 8 deletions src/toolchains/i686-w64-mingw32.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR "i686")

if(NOT "$ENV{CROSS_ROOT}" STREQUAL "")
#set(CMAKE_SYSROOT $ENV{CROSS_ROOT})
set(CMAKE_FIND_ROOT_PATH $ENV{CROSS_ROOT})
elseif(DEFINED CROSS_ROOT)
#set(CMAKE_SYSROOT ${CROSS_ROOT})
set(CMAKE_FIND_ROOT_PATH ${CROSS_ROOT})
else()
#set(CMAKE_SYSROOT /usr/i686-w64-mingw32)
set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
set(CMAKE_SYSROOT $ENV{CROSS_ROOT})
#set(CMAKE_FIND_ROOT_PATH $ENV{CROSS_ROOT})
elseif(NOT "$ENV{CMAKE_FIND_ROOT_PATH}" STREQUAL "")
set(CMAKE_SYSROOT /usr/i686-w64-mingw32)
#set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
endif()

set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
Expand Down
13 changes: 5 additions & 8 deletions src/toolchains/x86_64-w64-mingw32.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR "x64")

if(NOT "$ENV{CROSS_ROOT}" STREQUAL "")
#set(CMAKE_SYSROOT $ENV{CROSS_ROOT})
set(CMAKE_FIND_ROOT_PATH $ENV{CROSS_ROOT})
elseif(DEFINED CROSS_ROOT)
#set(CMAKE_SYSROOT ${CROSS_ROOT})
set(CMAKE_FIND_ROOT_PATH ${CROSS_ROOT})
else()
#set(CMAKE_SYSROOT /usr/x86_64-w64-mingw32)
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
set(CMAKE_SYSROOT $ENV{CROSS_ROOT})
#set(CMAKE_FIND_ROOT_PATH $ENV{CROSS_ROOT})
elseif(NOT "$ENV{CMAKE_FIND_ROOT_PATH}" STREQUAL "")
set(CMAKE_SYSROOT /usr/x86_64-w64-mingw32)
#set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
endif()

set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
Expand Down

0 comments on commit c6b44f9

Please sign in to comment.