diff --git a/Taskfile.yml b/Taskfile.yml index b10e0a4f..a270dadb 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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 @@ -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"}} diff --git a/docker-compose.yml b/docker-compose.yml index 37c459cf..bd649957 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: . @@ -65,4 +57,25 @@ services: build: context: . dockerfile: ./docker/Dockerfile.emscripten - target: build \ No newline at end of file + 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 \ No newline at end of file diff --git a/docker/Dockerfile.mingw b/docker/Dockerfile.mingw index 6bbd85e7..3aed3780 100644 --- a/docker/Dockerfile.mingw +++ b/docker/Dockerfile.mingw @@ -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"] diff --git a/src/CrossCompiler.cmake b/src/CrossCompiler.cmake index ba908eaa..56bc1404 100644 --- a/src/CrossCompiler.cmake +++ b/src/CrossCompiler.cmake @@ -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}) diff --git a/src/toolchains/i686-w64-mingw32.toolchain.cmake b/src/toolchains/i686-w64-mingw32.toolchain.cmake index 513969ad..aa124467 100644 --- a/src/toolchains/i686-w64-mingw32.toolchain.cmake +++ b/src/toolchains/i686-w64-mingw32.toolchain.cmake @@ -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) diff --git a/src/toolchains/x86_64-w64-mingw32.toolchain.cmake b/src/toolchains/x86_64-w64-mingw32.toolchain.cmake index 9e579d1a..add863d2 100644 --- a/src/toolchains/x86_64-w64-mingw32.toolchain.cmake +++ b/src/toolchains/x86_64-w64-mingw32.toolchain.cmake @@ -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)