multiarch / crossbuild

:earth_africa: multiarch cross compiling environments
MIT License
933 stars 141 forks source link

x86_64-apple-darwin cmake not functioning correctly #62

Open kmturley opened 2 years ago

kmturley commented 2 years ago

multiarch/crossbuild currently uses Debian stretch: FROM buildpack-deps:stretch-curl

This comes with cmake version 3.7.2 https://packages.debian.org/stretch/devel/cmake

Therefore I took the old CMake tutorial (which is compatible with cmake 3.3+) https://github.com/Kitware/CMake/tree/161b33f12b9a225607a4ea8339eabd4875bebbfe/Help/guide/tutorial/Complete

I placed the tutorials files inside a /src directory and added a docker-compose.yml file:

version: '3'
services:

  linux:
    image: multiarch/crossbuild
    environment:
      CROSS_TRIPLE: x86_64-linux-gnu
      FOLDER: linux
    command: >
      sh -c "mkdir -p ./build/linux &&
             cd ./build/linux &&
             cmake ../../src &&
             cmake --build . &&
            ./Tutorial 4294967296"
    working_dir: /app
    volumes:
      - ./src:/app/src
      - ./build:/app/build

  mac:
    image: multiarch/crossbuild
    environment:
      CROSS_TRIPLE: x86_64-apple-darwin
    command: >
      sh -c "mkdir -p ./build/mac &&
             cd ./build/mac &&
             cmake ../../src &&
             cmake --build . &&
            ./Tutorial 4294967296"
    working_dir: /app
    volumes:
      - ./src:/app/src
      - ./build:/app/build

  win:
    image: multiarch/crossbuild
    environment:
      CROSS_TRIPLE: x86_64-w64-mingw32
      FOLDER: win
    command: >
      sh -c "mkdir -p ./build/win &&
             cd ./build/win &&
             cmake ../../src &&
             cmake --build . &&
            ./Tutorial 4294967296"
    working_dir: /app
    volumes:
      - ./src:/app/src
      - ./build:/app/build

When running docker-compose up you get

./build/win/CMakeFiles/CMakeError.log

Determining if the C compiler works failed with the following output:
Change Dir: /app/build/win/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_731ec/fast"
/usr/bin/make -f CMakeFiles/cmTC_731ec.dir/build.make CMakeFiles/cmTC_731ec.dir/build
make[1]: Entering directory '/app/build/win/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_731ec.dir/testCCompiler.c.o
/usr/x86_64-w64-mingw32/bin/cc     -o CMakeFiles/cmTC_731ec.dir/testCCompiler.c.o   -c /app/build/win/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_731ec
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_731ec.dir/link.txt --verbose=1
/usr/x86_64-w64-mingw32/bin/cc       CMakeFiles/cmTC_731ec.dir/testCCompiler.c.o  -o cmTC_731ec -rdynamic 
cc: error: unrecognized command line option '-rdynamic'
CMakeFiles/cmTC_731ec.dir/build.make:97: recipe for target 'cmTC_731ec' failed
make[1]: *** [cmTC_731ec] Error 1
make[1]: Leaving directory '/app/build/win/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_731ec/fast' failed
make: *** [cmTC_731ec/fast] Error 2

I have a branch with the code here: https://github.com/kmturley/cmake-multiarch-docker/tree/feature/crossbuild

What is the issue?