Skip to content

Commit f2620c7

Browse files
committed
extconf: Use MSYS Makefiles with CMake on Windows
On Windows, Ruby-DevKit is MSYS-based. As such we should use MSYS Makefiles with CMake. Otherwise it might happen that CMake picks a gmake.exe from somewhere instead of make.exe from Ruby-DevKit as CMake seems to prefer gmake over make. In a concrete case, when doing "gem install rugged" on Windows with Strawberry Perl installed and in PATH, CMake was picking C:/Strawberry/c/bin/gmake.exe instead of C:/Ruby-DevKit/bin/make.exe While the latter is linked against MSYS-1.0.DLL and understands Unix-style paths on Windows, the first is a native Windows executable linked against MSVCRT.DLL that does not. This resulted in path mangling issues leading to CMake's "Detecting C compiler ABI info" step to fail because the helper executable failed to build, which in turn led to CMAKE_SIZEOF_VOID_P not being set and libgit2 being unable to detect the architecture. On other platforms than Windows it should be safe to use whatever the default toolchain is that CMake detects.
1 parent e6302e0 commit f2620c7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ext/rugged/extconf.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def windows?
6767
Dir.mkdir("build") if !Dir.exists?("build")
6868

6969
Dir.chdir("build") do
70-
sys("cmake .. -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo -G \"Unix Makefiles\"")
70+
# On Windows, Ruby-DevKit is MSYS-based, so ensure to use MSYS Makefiles.
71+
generator = "-G \"MSYS Makefiles\"" if windows?
72+
sys("cmake .. -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo #{generator}")
7173
sys(MAKE)
7274

7375
# "normal" libraries (and libgit2 builds) get all these when they build but we're doing it

0 commit comments

Comments
 (0)