Commit d66a7c061a3b0809589de05eeac00725444db3aa

QbProg 2013-03-16T17:48:24

Fix for a cmake bug when using MSVC + Win64 + static libraries (see http://public.kitware.com/Bug/view.php?id=11240)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ab254f..dfca736 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -282,6 +282,12 @@ ADD_LIBRARY(git2 ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SR
 TARGET_LINK_LIBRARIES(git2 ${SSL_LIBRARIES})
 TARGET_OS_LIBRARIES(git2)
 
+# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
+# Win64+MSVC+static libs = linker error
+IF(MSVC AND NOT BUILD_SHARED_LIBS AND (${CMAKE_SIZEOF_VOID_P} MATCHES "8") )
+  SET_TARGET_PROPERTIES(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64")
+ENDIF()
+
 MSVC_SPLIT_SOURCES(git2)
 
 IF (SONAME)