From 4c04b9b613003bd3320faace87fa4729ee1fd0fb Mon Sep 17 00:00:00 2001 From: zmatsuo <6488847+zmatsuo@users.noreply.github.com> Date: Sun, 21 Jul 2024 01:18:49 +0900 Subject: [PATCH] =?UTF-8?q?mingw,=20arm64=E3=81=A7=E3=81=AE=E3=83=93?= =?UTF-8?q?=E3=83=AB=E3=83=89=E3=82=92=E8=80=83=E6=85=AE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - experimental - cmakeビルド時、libs/ で arm64 を考慮するようにした - ci_scripts を整理した --- ci_scripts/appveyor.md | 56 ++++++- ci_scripts/appveyor_linux.md | 56 ------- ci_scripts/build_appveyor.bat | 8 +- ci_scripts/build_local_appveyor.bat | 152 ++++++++++++++++++ .../build_local_appveyor_mingw_clang.bat | 14 -- ci_scripts/build_local_appveyor_mingw_gcc.bat | 14 -- .../build_local_appveyor_mingw_x64_clang.bat | 14 -- .../build_local_appveyor_mingw_x64_gcc.bat | 14 -- ci_scripts/build_local_appveyor_vs2019.bat | 13 -- .../build_local_appveyor_vs2019_x64.bat | 13 -- ci_scripts/build_local_appveyor_vs2022.bat | 15 -- .../build_local_appveyor_vs2022_x64.bat | 15 -- libs/lib_SFMT.cmake | 3 - libs/lib_libressl.cmake | 3 - libs/lib_oniguruma.cmake | 3 - libs/lib_zlib.cmake | 3 - libs/script_support.cmake | 18 ++- mingw.toolchain.cmake | 24 ++- 18 files changed, 247 insertions(+), 191 deletions(-) delete mode 100644 ci_scripts/appveyor_linux.md create mode 100644 ci_scripts/build_local_appveyor.bat delete mode 100644 ci_scripts/build_local_appveyor_mingw_clang.bat delete mode 100644 ci_scripts/build_local_appveyor_mingw_gcc.bat delete mode 100644 ci_scripts/build_local_appveyor_mingw_x64_clang.bat delete mode 100644 ci_scripts/build_local_appveyor_mingw_x64_gcc.bat delete mode 100644 ci_scripts/build_local_appveyor_vs2019.bat delete mode 100644 ci_scripts/build_local_appveyor_vs2019_x64.bat delete mode 100644 ci_scripts/build_local_appveyor_vs2022.bat delete mode 100644 ci_scripts/build_local_appveyor_vs2022_x64.bat diff --git a/ci_scripts/appveyor.md b/ci_scripts/appveyor.md index d70a41a5c..fc56343db 100644 --- a/ci_scripts/appveyor.md +++ b/ci_scripts/appveyor.md @@ -1,8 +1,6 @@ AppVeyorの使用 ============== -git(GitHubも含む)リポジトリからのビルド - ## プロジェクト作成 / 設定 - Select repository for your new project @@ -61,7 +59,59 @@ appveyor_mix.yml 最近使用していない -## build_local_appveyor_* +build_local_appveyor_* +====================== - ローカルで build_appveyor.bat をテストするための bat ファイル - Visual Studio と msys2 を使用 + +ローカルでのテスト(Linux) +======================= + +## ビルド準備/WSL + +- ストアで debian をインストールする + - 21-05-02時点で debian 10(buster) +- debian を起動 +- 次のコマンドを実行 + +``` +sudo apt-get update +sudo apt-get -y upgrade +sudo apt-get -y install cmake perl subversion +sudo apt-get -y install g++-mingw-w64 +sudo apt-get -y install fp-utils +cd /path/to/teraterm +``` + +## ビルド準備/debian + +- WSLと同じ +- 次のディストリビューション/バージョンに含まれているmingwでのビルドは確認した + +``` +$ cat /etc/os-release +PRETTY_NAME="Debian GNU/Linux bookworm/sid" +NAME="Debian GNU/Linux" +VERSION_CODENAME=bookworm +ID=debian +HOME_URL="https://www.debian.org/" +SUPPORT_URL="https://www.debian.org/support" +BUG_REPORT_URL="https://bugs.debian.org/" +``` + +## ビルド + +gcc 32bit + +``` +cmake -DCMAKE_GENERATOR="Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../mingw.toolchain.cmake -P buildall.cmake +cmake -P ci_scripts/build_local_appveyor_mingw.cmake +``` + + +gcc 64bit +- `cmake -DCOMPILER_64BIT=ON -P ci_scripts/build_local_appveyor_mingw.cmake` + +msys64 +- [build_local_appveyor_mingw_cmake.bat](build_local_appveyor_mingw_cmake.bat)参照 diff --git a/ci_scripts/appveyor_linux.md b/ci_scripts/appveyor_linux.md deleted file mode 100644 index 0953f3e0e..000000000 --- a/ci_scripts/appveyor_linux.md +++ /dev/null @@ -1,56 +0,0 @@ -AppVeyor Linux build -==================== - -linux上の MinGW を利用したビルド - -## プロジェクト作成 / 設定 - -- appveyor.yml の代わりに appveyor_linux.yml を使用する - -# ローカルでのテスト - -## ビルド準備/WSL - -- ストアで debian をインストールする - - 21-05-02時点で debian 10(buster) -- debian を起動 -- 次のコマンドを実行 - -``` -sudo apt-get update -sudo apt-get -y upgrade -sudo apt-get -y install cmake perl subversion -sudo apt-get -y install g++-mingw-w64 -sudo apt-get -y install fp-utils -cd /path/to/teraterm -``` - -## ビルド準備/debian - -- WSLと同じ -- 次のディストリビューション/バージョンに含まれているmingwでのビルドは確認した - -debian buster - -``` -$ cat /etc/debian_version -10.9 -``` - -debian bullseye/sid - -``` -$ cat /etc/debian_version -bullseye/sid -``` - -## ビルド - -gcc 32bit -- `cmake -P ci_scripts/build_local_appveyor_mingw.cmake` - -gcc 64bit -- `cmake -DCOMPILER_64BIT=ON -P ci_scripts/build_local_appveyor_mingw.cmake` - -msys64 -- [build_local_appveyor_mingw_cmake.bat](build_local_appveyor_mingw_cmake.bat)参照 diff --git a/ci_scripts/build_appveyor.bat b/ci_scripts/build_appveyor.bat index c59899e6a..2758dcfc7 100644 --- a/ci_scripts/build_appveyor.bat +++ b/ci_scripts/build_appveyor.bat @@ -1,10 +1,15 @@ cd /d %~dp0.. if exist teraterm\ttpdlg\svnversion.h del teraterm\ttpdlg\svnversion.h if exist buildtools\svnrev\sourcetree_info.bat del buildtools\svnrev\sourcetree_info.bat -call ci_scripts\install.bat +rem call ci_scripts\install_mycygwin.bat cd /d %~dp0.. call buildtools\svnrev\svnrev.bat call buildtools\svnrev\sourcetree_info.bat +echo GENERATOR=%GENERATOR% +echo CMAKE_OPTION_LIBS=%CMAKE_OPTION_LIBS% +echo CMAKE_COMMAND=%CMAKE_COMMAND% +echo BUILD_DIR=%BUILD_DIR% +pause if "%COMPILER%" == "mingw" ( set PATH=C:\msys64\mingw32\bin;C:\msys64\usr\bin pacman -S --noconfirm --needed mingw-w64-i686-cmake mingw-w64-i686-gcc make @@ -13,6 +18,7 @@ if "%COMPILER%" == "mingw" ( ) set CC=%MINGW_CC% set CXX=%MINGW_CXX% + set CMAKE=C:\msys64\mingw64\bin\cmake.exe set CMAKE_OPTION_BUILD=-- -s -j set CMAKE_OPTION_GENERATE=%CMAKE_OPTION_GENERATE% -DCMAKE_BUILD_TYPE=Release ) diff --git a/ci_scripts/build_local_appveyor.bat b/ci_scripts/build_local_appveyor.bat new file mode 100644 index 000000000..d7961c199 --- /dev/null +++ b/ci_scripts/build_local_appveyor.bat @@ -0,0 +1,152 @@ +@echo off +setlocal +set CUR=%~dp0 +cd /d %CUR% + +echo ======= +echo 1. vs2022 win32 +echo 2. vs2022 x64 +echo b. vs2022 arm64 +echo 3. vs2019 win32 +echo 4. vs2019 x64 +echo 5. mingw gcc win32 +echo 6. mingw gcc x64 +echo 7. mingw clang win32 +echo 8. mingw clang x64 +echo 9. exit +rem echo a. vs2005 + +if "%1" == "" ( + set /p no="select no " +) else ( + set no=%1 +) +echo %no% + +if not "%no%" == "1" goto pass_1 + set COMPILER=VS_143 + set COMPILER_FRIENDLY=vs2022 + set GENERATOR=Visual Studio 17 2022 + set CMAKE_COMMAND=cmake + set CMAKE_OPTION_LIBS=-DARCHITECTURE=win32 + set CMAKE_OPTION_GENERATE=-A Win32 + set CMAKE_OPTION_BUILD=--config Release + set BUILD_DIR=build_%COMPILER_FRIENDLY%_win32 + call :build +:pass_1 +if not "%no%" == "2" goto pass_2 + set COMPILER=VS_143_x64 + set COMPILER_FRIENDLY=vs2022_x64 + set GENERATOR=Visual Studio 17 2022 + set CMAKE_COMMAND=cmake + set CMAKE_OPTION_LIBS=-DARCHITECTURE=x64 + set CMAKE_OPTION_GENERATE=-A x64 + set CMAKE_OPTION_BUILD=--config Release + set BUILD_DIR=build_%COMPILER_FRIENDLY% + call :build +:pass_2 +if not "%no%" == "b" goto pass_a + set COMPILER=VS_143_arm64 + set COMPILER_FRIENDLY=vs2022_arm64 + set GENERATOR=Visual Studio 17 2022 + set CMAKE_COMMAND=cmake + set CMAKE_OPTION_LIBS=-DARCHITECTURE=arm64 + set CMAKE_OPTION_GENERATE=-A arm64 + set CMAKE_OPTION_BUILD=--config Release + set BUILD_DIR=build_%COMPILER_FRIENDLY% + call :build +:pass_a +if not "%no%" == "3" goto pass_3 + set COMPILER=VS_142 + set COMPILER_FRIENDLY=vs2019 + set GENERATOR=Visual Studio 16 2019 + set CMAKE_COMMAND=cmake + set CMAKE_OPTION_LIBS=-DARCHITECTURE=win32 + set CMAKE_OPTION_GENERATE=-A Win32 + set CMAKE_OPTION_BUILD=--config Release + set BUILD_DIR=build_%COMPILER_FRIENDLY% + call :build +:pass_3 +if not "%no%" == "4" goto pass_4 + set COMPILER=VS_142_x64 + set COMPILER_FRIENDLY=vs2019_x64 + set GENERATOR=Visual Studio 16 2019 + set CMAKE_COMMAND=cmake + set CMAKE_OPTION_LIBS=-DARCHITECTURE=x64 + set CMAKE_OPTION_GENERATE=-A x64 + set CMAKE_OPTION_BUILD=--config Release + set BUILD_DIR=build_%COMPILER_FRIENDLY% + call :build +:pass_4 +if not "%no%" == "a" goto pass_a + set COMPILER=VS_80 + set COMPILER_FRIENDLY=vs2005 + set GENERATOR=Visual Studio 8 2005 + set CMAKE_COMMAND=..\libs\cmake-3.11.4-win32-x86\bin\cmake.exe + set CMAKE_OPTION_LIBS=-DARCHITECTURE=win32 + set CMAKE_OPTION_GENERATE= + set CMAKE_OPTION_BUILD=--config Release + set BUILD_DIR=build_%COMPILER_FRIENDLY% +:pass_a +if not "%no%" == "5" goto pass_5 + set COMPILER=mingw + set COMPILER_FRIENDLY=mingw_gcc + set GENERATOR=Unix Makefiles + set CMAKE_COMMAND=cmake + set CMAKE_OPTION_LIBS=-DARCHITECTURE=i686 + set CMAKE_OPTION_GENERATE=-DCMAKE_BUILD_TYPE=Release + set CMAKE_OPTION_BUILD= + set MINGW_CC=gcc + set MINGW_CXX=g++ + set BUILD_DIR=build_%COMPILER_FRIENDLY%_msys2 + call :build +:pass_5 +if not "%no%" == "6" goto pass_6 + set COMPILER=mingw_x64 + set COMPILER_FRIENDLY=mingw_x64_gcc + set GENERATOR=Unix Makefiles + set CMAKE_COMMAND=cmake + set CMAKE_OPTION_LIBS=-DARCHITECTURE=x86_64 + set CMAKE_OPTION_GENERATE=-DCMAKE_BUILD_TYPE=Release + set CMAKE_OPTION_BUILD= + set MINGW_CC=gcc + set MINGW_CXX=g++ + set BUILD_DIR=build_%COMPILER_FRIENDLY%_msys2 + call :build +:pass_6 +if not "%no%" == "7" goto pass_7 + set COMPILER=mingw + set COMPILER_FRIENDLY=mingw_clang + set GENERATOR=Unix Makefiles + set CMAKE_COMMAND=cmake + set CMAKE_OPTION_LIBS=-DARCHITECTURE=i686 + set CMAKE_OPTION_GENERATE=-DCMAKE_BUILD_TYPE=Release + set CMAKE_OPTION_BUILD= + set MINGW_CC=clang + set MINGW_CXX=clang++ + set BUILD_DIR=build_%COMPILER_FRIENDLY%_msys2 + call :build +:pass_7 +if not "%no%" == "8" goto pass_8 + set COMPILER=mingw_x64 + set COMPILER_FRIENDLY=mingw_x64_clang + set GENERATOR=Unix Makefiles + set CMAKE_COMMAND=cmake + set CMAKE_OPTION_LIBS=-DARCHITECTURE=x86_64 + set CMAKE_OPTION_GENERATE=-DCMAKE_BUILD_TYPE=Release + set CMAKE_OPTION_BUILD= + set MINGW_CC=clang + set MINGW_CXX=clang++ + set BUILD_DIR=build_%COMPILER_FRIENDLY%_msys2 + call :build +:pass_8 + +if not "%NOPAUSE%" == "1" pause +exit /b 0 + +rem #################### +:build +cd /d %~dp0.. +call ci_scripts\find_cmake.bat +call ci_scripts\build_appveyor.bat +exit /b 0 diff --git a/ci_scripts/build_local_appveyor_mingw_clang.bat b/ci_scripts/build_local_appveyor_mingw_clang.bat deleted file mode 100644 index a3f12140b..000000000 --- a/ci_scripts/build_local_appveyor_mingw_clang.bat +++ /dev/null @@ -1,14 +0,0 @@ -setlocal -set COMPILER=mingw -set COMPILER_FRIENDLY=mingw_clang -set GENERATOR=Unix Makefiles -set CMAKE_COMMAND=cmake -set CMAKE_OPTION_LIBS= -set CMAKE_OPTION_GENERATE=-DCMAKE_BUILD_TYPE=Release -set CMAKE_OPTION_BUILD= -set MINGW_CC=clang -set MINGW_CXX=clang++ -set BUILD_DIR=build_%COMPILER_FRIENDLY%_msys2 - -cd /d %~dp0.. -call ci_scripts\build_appveyor.bat diff --git a/ci_scripts/build_local_appveyor_mingw_gcc.bat b/ci_scripts/build_local_appveyor_mingw_gcc.bat deleted file mode 100644 index 7572f810c..000000000 --- a/ci_scripts/build_local_appveyor_mingw_gcc.bat +++ /dev/null @@ -1,14 +0,0 @@ -setlocal -set COMPILER=mingw -set COMPILER_FRIENDLY=mingw_gcc -set GENERATOR=Unix Makefiles -set CMAKE_COMMAND=cmake -set CMAKE_OPTION_LIBS= -set CMAKE_OPTION_GENERATE=-DCMAKE_BUILD_TYPE=Release -set CMAKE_OPTION_BUILD= -set MINGW_CC=gcc -set MINGW_CXX=g++ -set BUILD_DIR=build_%COMPILER_FRIENDLY%_msys2 - -cd /d %~dp0.. -call ci_scripts\build_appveyor.bat diff --git a/ci_scripts/build_local_appveyor_mingw_x64_clang.bat b/ci_scripts/build_local_appveyor_mingw_x64_clang.bat deleted file mode 100644 index 3aed9f227..000000000 --- a/ci_scripts/build_local_appveyor_mingw_x64_clang.bat +++ /dev/null @@ -1,14 +0,0 @@ -setlocal -set COMPILER=mingw_x64 -set COMPILER_FRIENDLY=mingw_x64_clang -set GENERATOR=Unix Makefiles -set CMAKE_COMMAND=cmake -set CMAKE_OPTION_LIBS= -set CMAKE_OPTION_GENERATE=-DCMAKE_BUILD_TYPE=Release -set CMAKE_OPTION_BUILD= -set MINGW_CC=clang -set MINGW_CXX=clang++ -set BUILD_DIR=build_%COMPILER_FRIENDLY%_msys2 - -cd /d %~dp0.. -call ci_scripts\build_appveyor.bat diff --git a/ci_scripts/build_local_appveyor_mingw_x64_gcc.bat b/ci_scripts/build_local_appveyor_mingw_x64_gcc.bat deleted file mode 100644 index 23bde61df..000000000 --- a/ci_scripts/build_local_appveyor_mingw_x64_gcc.bat +++ /dev/null @@ -1,14 +0,0 @@ -setlocal -set COMPILER=mingw_x64 -set COMPILER_FRIENDLY=mingw_x64_gcc -set GENERATOR=Unix Makefiles -set CMAKE_COMMAND=cmake -set CMAKE_OPTION_LIBS= -set CMAKE_OPTION_GENERATE=-DCMAKE_BUILD_TYPE=Release -set CMAKE_OPTION_BUILD= -set MINGW_CC=gcc -set MINGW_CXX=g++ -set BUILD_DIR=build_%COMPILER_FRIENDLY%_msys2 - -cd /d %~dp0.. -call ci_scripts\build_appveyor.bat diff --git a/ci_scripts/build_local_appveyor_vs2019.bat b/ci_scripts/build_local_appveyor_vs2019.bat deleted file mode 100644 index c6b008836..000000000 --- a/ci_scripts/build_local_appveyor_vs2019.bat +++ /dev/null @@ -1,13 +0,0 @@ -setlocal -set COMPILER=VS_142 -set COMPILER_FRIENDLY=vs2019 -set GENERATOR=Visual Studio 16 2019 -set CMAKE_COMMAND=cmake -set CMAKE_OPTION_LIBS=-DARCHITECTURE=32 -set CMAKE_OPTION_GENERATE=-A Win32 -set CMAKE_OPTION_BUILD=--config Release -set BUILD_DIR=build_%COMPILER_FRIENDLY% - -cd /d %~dp0.. -call ci_scripts\find_cmake.bat -call ci_scripts\build_appveyor.bat diff --git a/ci_scripts/build_local_appveyor_vs2019_x64.bat b/ci_scripts/build_local_appveyor_vs2019_x64.bat deleted file mode 100644 index 037c9e5ed..000000000 --- a/ci_scripts/build_local_appveyor_vs2019_x64.bat +++ /dev/null @@ -1,13 +0,0 @@ -setlocal -set COMPILER=VS_142_x64 -set COMPILER_FRIENDLY=vs2019_x64 -set GENERATOR=Visual Studio 16 2019 -set CMAKE_COMMAND=cmake -set CMAKE_OPTION_LIBS=-DARCHITECTURE=64 -set CMAKE_OPTION_GENERATE=-A x64 -set CMAKE_OPTION_BUILD=--config Release -set BUILD_DIR=build_%COMPILER_FRIENDLY% - -cd /d %~dp0.. -call ci_scripts\find_cmake.bat -call ci_scripts\build_appveyor.bat diff --git a/ci_scripts/build_local_appveyor_vs2022.bat b/ci_scripts/build_local_appveyor_vs2022.bat deleted file mode 100644 index 1041a63c4..000000000 --- a/ci_scripts/build_local_appveyor_vs2022.bat +++ /dev/null @@ -1,15 +0,0 @@ -setlocal -set PATH= -set COMPILER=VS_143 -set COMPILER_FRIENDLY=vs2022 -set GENERATOR=Visual Studio 17 2022 -set CMAKE_COMMAND=cmake -set CMAKE_OPTION_LIBS=-DARCHITECTURE=32 -set CMAKE_OPTION_GENERATE=-A Win32 -set CMAKE_OPTION_BUILD=--config Release -set BUILD_DIR=build_%COMPILER_FRIENDLY% - -cd /d %~dp0.. -call ci_scripts\find_cmake.bat -call ci_scripts\build_appveyor.bat -pause diff --git a/ci_scripts/build_local_appveyor_vs2022_x64.bat b/ci_scripts/build_local_appveyor_vs2022_x64.bat deleted file mode 100644 index 3f899f1a4..000000000 --- a/ci_scripts/build_local_appveyor_vs2022_x64.bat +++ /dev/null @@ -1,15 +0,0 @@ -setlocal -set PATH= -set COMPILER=VS_143_x64 -set COMPILER_FRIENDLY=vs2022_x64 -set GENERATOR=Visual Studio 17 2022 -set CMAKE_COMMAND=cmake -set CMAKE_OPTION_LIBS=-DARCHITECTURE=64 -set CMAKE_OPTION_GENERATE=-A x64 -set CMAKE_OPTION_BUILD=--config Release -set BUILD_DIR=build_%COMPILER_FRIENDLY% - -cd /d %~dp0.. -call ci_scripts\find_cmake.bat -call ci_scripts\build_appveyor.bat -pause diff --git a/libs/lib_SFMT.cmake b/libs/lib_SFMT.cmake index c691dca31..8a134083b 100644 --- a/libs/lib_SFMT.cmake +++ b/libs/lib_SFMT.cmake @@ -5,9 +5,6 @@ if(MSVC) set(SFMT_ROOT "${CMAKE_CURRENT_LIST_DIR}/SFMT_vs_${CMAKE_VS_PLATFORM_TOOLSET}_${CMAKE_GENERATOR_PLATFORM}") else() set(SFMT_ROOT ${CMAKE_CURRENT_LIST_DIR}/SFMT_${TOOLSET}) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(SFMT_ROOT "${SFMT_ROOT}_x64") - endif() endif() set(SFMT_INCLUDE_DIRS "${SFMT_ROOT}/include") diff --git a/libs/lib_libressl.cmake b/libs/lib_libressl.cmake index dd52df1b3..a86349059 100644 --- a/libs/lib_libressl.cmake +++ b/libs/lib_libressl.cmake @@ -5,9 +5,6 @@ if(MSVC) set(LIBRESSL_ROOT "${CMAKE_CURRENT_LIST_DIR}/libressl_vs_${CMAKE_VS_PLATFORM_TOOLSET}_${CMAKE_GENERATOR_PLATFORM}") else() set(LIBRESSL_ROOT ${CMAKE_CURRENT_LIST_DIR}/libressl_${TOOLSET}) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(LIBRESSL_ROOT "${LIBRESSL_ROOT}_x64") - endif() endif() set(LIBRESSL_INCLUDE_DIRS ${LIBRESSL_ROOT}/include) diff --git a/libs/lib_oniguruma.cmake b/libs/lib_oniguruma.cmake index 4b580fcff..7c004d889 100644 --- a/libs/lib_oniguruma.cmake +++ b/libs/lib_oniguruma.cmake @@ -5,9 +5,6 @@ if(MSVC) set(ONIGURUMA_ROOT "${CMAKE_CURRENT_LIST_DIR}/oniguruma_vs_${CMAKE_VS_PLATFORM_TOOLSET}_${CMAKE_GENERATOR_PLATFORM}") else() set(ONIGURUMA_ROOT ${CMAKE_CURRENT_LIST_DIR}/oniguruma_${TOOLSET}) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(ONIGURUMA_ROOT "${ONIGURUMA_ROOT}_x64") - endif() endif() #set(ONIGURUMA_DIR "${ONIGURUMA_ROOT}/lib/cmake/oniguruma") diff --git a/libs/lib_zlib.cmake b/libs/lib_zlib.cmake index fcbf72819..902401e57 100644 --- a/libs/lib_zlib.cmake +++ b/libs/lib_zlib.cmake @@ -5,9 +5,6 @@ if(MSVC) set(ZLIB_ROOT "${CMAKE_CURRENT_LIST_DIR}/zlib_vs_${CMAKE_VS_PLATFORM_TOOLSET}_${CMAKE_GENERATOR_PLATFORM}") else() set(ZLIB_ROOT ${CMAKE_CURRENT_LIST_DIR}/zlib_${TOOLSET}) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(ZLIB_ROOT "${ZLIB_ROOT}_x64") - endif() endif() set(ZLIB_INCLUDE_DIRS ${ZLIB_ROOT}/include) diff --git a/libs/script_support.cmake b/libs/script_support.cmake index 21b2c35fc..dea0e6a44 100644 --- a/libs/script_support.cmake +++ b/libs/script_support.cmake @@ -29,10 +29,22 @@ elseif((${CMAKE_GENERATOR} MATCHES "Unix Makefiles") OR (${CMAKE_GENERATOR} MATCHES "MSYS Makefiles") OR (${CMAKE_GENERATOR} MATCHES "MinGW Makefiles") OR (${CMAKE_GENERATOR} MATCHES "Ninja")) - if(${ARCHITECTURE} EQUAL 64) - set(TOOLSET "mingw_x64") + if(DEFINED ARCHITECTURE) + # for script + if((${ARCHITECTURE} EQUAL 64) OR (${ARCHITECTURE} STREQUAL "x86_64")) + set(TOOLSET "mingw_x86_64") + elseif((${ARCHITECTURE} EQUAL 32) OR (${ARCHITECTURE} STREQUAL "i686")) + set(TOOLSET "mingw_i686") + else() + message(FATAL_ERROR "check ARCHITECTURE ${ARCHITECTURE}") + endif() else() - set(TOOLSET "mingw") + # for generate/build + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(TOOLSET "mingw_x86_64") + else() + set(TOOLSET "mingw_i686") + endif() endif() elseif(${CMAKE_GENERATOR} MATCHES "NMake Makefiles") set(TOOLSET "VS_NMake") diff --git a/mingw.toolchain.cmake b/mingw.toolchain.cmake index de89e60e6..689255c0e 100644 --- a/mingw.toolchain.cmake +++ b/mingw.toolchain.cmake @@ -2,6 +2,7 @@ # mkdir build; cd build # cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../mingw.toolchain.cmake # cmake --build . +cmake_policy(SET CMP0053 NEW) # target set(CMAKE_SYSTEM_NAME Windows) @@ -12,10 +13,19 @@ option(USE_GCC_64 "use gcc 64bit compiler" OFF) option(USE_CLANG_32 "use clang 32bit compiler" OFF) option(USE_CLANG_64 "use clang 64bit compiler" OFF) +# option auto select if((NOT USE_GCC_32) AND (NOT USE_GCC_64) AND (NOT USE_CLANG_32) AND (NOT USE_CLANG_64)) - # default compiler - set(USE_GCC_32 ON) + if(${CMAKE_COMMAND} MATCHES "mingw32") + # MSYS2 MinGW x86 + set(USE_GCC_32 ON) + elseif(${CMAKE_COMMAND} MATCHES "mingw64") + # MSYS2 MinGW x64 + set(USE_GCC_64 ON) + else() + # default compiler + set(USE_GCC_32 ON) + endif() endif() if(USE_GCC_32 OR USE_CLANG_32) @@ -31,10 +41,13 @@ endif() set(THREAD_MODEL "-win32") #set(THREAD_MODEL "-posix") -if(${CMAKE_COMMAND} MATCHES "msys2") +message("msys=${MSYS}") +message("msys2=${MSYS2}") +message("CMAKE_COMMAND=${CMAKE_COMMAND}") +if(MSYS OR (${CMAKE_COMMAND} MATCHES "msys2") OR (${CMAKE_COMMAND} MATCHES "mingw") OR (${CMAKE_COMMAND} MATCHES "clang64")) # msys2はposix版のみ unset(THREAD_MODEL) -elseif(${CMAKE_HOST_SYSTEM_NAME} MATCHES "CYGWIN") +elseif(CYGWIN OR (${CMAKE_HOST_SYSTEM_NAME} MATCHES "CYGWIN")) # Cygwinはposix版のみ unset(THREAD_MODEL) endif() @@ -50,6 +63,9 @@ elseif(USE_CLANG_32 OR USE_CLANG_64) else() message(FATAL_ERROR "check compiler") endif() +if(MSYS OR (${CMAKE_COMMAND} MATCHES "msys2") OR (${CMAKE_COMMAND} MATCHES "mingw") OR (${CMAKE_COMMAND} MATCHES "clang64")) + set(CMAKE_RC_COMPILER windres) +endif() set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)