MinGW リンカの代わりに MSVS リンカを使用するように CMake に強制するには問題があります。MSYS で MSVC をサポートするために、CMake が MSVC コンパイラを使用して NMake ファイルを作成するように強制する bash スクリプトを実装しました。
cmake -G "NMake Makefiles" -DMSVC=true -DCOMPILER_ROOT=$COMPILER_ROOT -DCMAKE_PROFILE=$CMAKE_PROFILE -DCMAKE_BUILD_TYPE=$CMAKE_DEBUG -DCMAKE_CXX_LINKER=$COMPILER_ROOT/bin/linker.exe
CMake は MSVC コンパイラを正しく使用し、期待どおりに NMake ファイルを作成します。
$ sh build.sh -msvc /c/binrev/development/vs2010/VC -p
removing CMakeCache.txt
removing temporary directory CMakeFiles
Create MSVC based NMake files.
-- The C compiler identification is MSVC
-- The CXX compiler identification is MSVC
-- Check for CL compiler version
-- Check for CL compiler version - 1600
-- Check if this is a free VC compiler
-- Check if this is a free VC compiler - no
-- Check for working C compiler: c:/binrev/development/vs2010/VC/bin/cl.exe
-- Check for working C compiler: c:/binrev/development/vs2010/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: c:/binrev/development/vs2010/VC/bin/cl.exe
-- Check for working CXX compiler: c:/binrev/development/vs2010/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Execute: brCore.cmake
Linker path CMAKE_CXX_LINKER: c:/binrev/development/vs2010/VC/bin/link.exe
ただし、nmake を呼び出すと、CMAKE は引き続き MinGW リンカーを使用します。
Linking CXX shared library bin\brCore.dll
c:\binrev\development\mingw\bin\ld.exe: unrecognized option '-Wl,--enable-auto-import'
c:\binrev\development\mingw\bin\ld.exe: use the --help option for usage information
LINK failed. with 1
NMAKE : fatal error U1077: "c:\binrev\development\cmake\bin\cmake.exe": Rückgabe-Code "0xffffffff"
Stop.
NMAKE : fatal error U1077: "c:\binrev\development\vs2010\VC\BIN\nmake.exe": Rückgabe-Code "0x2"
Stop.
NMAKE : fatal error U1077: "c:\binrev\development\vs2010\VC\BIN\nmake.exe": Rückgabe-Code "0x2"
Stop.
CMakeCache で bash シェル スクリプトを呼び出した後、MSVC リンカーの代わりに MinGW リンカーが設定されます。
//Path to a program.
CMAKE_LINKER:FILEPATH=c:/binrev/development/mingw/bin/ld.exe
わかりました、正しい依存関係を取得するには、 CMAKE_CXX_LINKER の代わりに CMAKE_LINKER 変数を設定する必要があることがわかりました。しかし今、私は別の失敗をしました:
Linking CXX shared library bin\brCore.dll
Das System kann die angegebene Datei nicht finden
mt.exe : general error c10100b1: Failed to load file "bin\brCore.dll". Das System kann die angegebene Datei nicht finden.
MT failed. with 31
私が何を間違えたのか誰にもわかりませんか?助けてくれてありがとう。
よろしく、ヘルハウンド