LoginSignup
0

More than 3 years have passed since last update.

msys2でPKGBUILDを書くときにcmakeを使う際は引数展開にご注意を。

Last updated at Posted at 2018-08-13

問題

PKGBUILDを書いてmakepkgしてパッケージをインストールしたら、/msys64/msys64/mingw64がinstall prefixになってしまった。/msys64/msys64/とは一体・・・。

ビルド出力より抜粋
-- Install configuration: ""
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/msys64/mingw64/lib/liblpsolve55.dll.a
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/msys64/mingw64/bin/liblpsolve55.dll
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/msys64/mingw64/include/lpsolve/lp_bit.h
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/msys64/mingw64/include/lpsolve/lp_crash.h
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/msys64/mingw64/include/lpsolve/lp_explicit.h
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/msys64/mingw64/include/lpsolve/lp_fortify.h
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/msys64/mingw64/include/lpsolve/lp_Hash.h

原因

PKGBUILDのbuild()でcmakeを呼び出していたが、

PKGBUILD_build()
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DLIB_TYPE=SHARED \
    ../lp_solve_5.5

のように呼び出していた。このときMINGW_PREFIX/mingw64である。

しかし、

にもあるように、msys2は引数展開を行うため、CMAKE_INSTALL_PREFIXC:\msys2\mingw64になってしまう(msys2の場所依存)。

解決策

PKGBUILD_build()
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DLIB_TYPE=SHARED \
    ../lp_solve_5.5

展開を阻止しましょう。

ビルド出力より抜粋
-- Install configuration: ""
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/mingw64/lib/liblpsolve55.dll.a
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/mingw64/bin/liblpsolve55.dll
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/mingw64/include/lpsolve/lp_bit.h
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/mingw64/include/lpsolve/lp_crash.h
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/mingw64/include/lpsolve/lp_explicit.h
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/mingw64/include/lpsolve/lp_fortify.h
-- Installing: C:/msys64/home/yumetodo/patches/mingw-w64-lpsolve/pkg/mingw-w64-x86_64-lpsolve/mingw64/include/lpsolve/lp_Hash.h

License

CC BY 4.0

CC-BY icon.svg

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0