From dcd62cb2e9fb9370f5eb17b9984f6dcf8d2598c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Tue, 11 Oct 2011 16:11:40 +0200 Subject: [PATCH 1/3] CMake: Only add the STDCALL option when using MSVC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This option is only ever used with MSVC. Signed-off-by: Carlos Martín Nieto --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 795a5851a..5c4de8023 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,10 +47,14 @@ SET(INSTALL_INC include CACHE PATH "Where to install headers to.") # Build options OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON) OPTION (THREADSAFE "Build libgit2 as threadsafe" OFF) -OPTION (STDCALL "Buildl libgit2 with the __stdcall convention (Windows)" ON) OPTION (BUILD_TESTS "Build Tests" ON) OPTION (BUILD_CLAY "Build Tests using the Clay suite" OFF) +# Not using __stdcall with the CRT causes problems +IF (MSVC) + OPTION (STDCALL "Buildl libgit2 with the __stdcall convention" ON) +ENDIF () + # Platform specific compilation flags IF (MSVC) SET(CMAKE_C_FLAGS "/W4 /nologo /Zi") From 5b216d1a6fc2968fa9f6524663b7647cb1c2a3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Tue, 11 Oct 2011 18:08:54 +0200 Subject: [PATCH 2/3] CMake: don't overwrite the user's CFLAGS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If either CFLAGS is defined or the user passes -DCMAKE_C_FLAGS to cmake, the variable already contains flags. Don't overwrite them, but append them to our settings. Signed-off-by: Carlos Martín Nieto --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c4de8023..ed1054225 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ ENDIF () # Platform specific compilation flags IF (MSVC) - SET(CMAKE_C_FLAGS "/W4 /nologo /Zi") + SET(CMAKE_C_FLAGS "/W4 /nologo /Zi ${CMAKE_C_FLAGS}") IF (STDCALL) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz") ENDIF () @@ -65,7 +65,7 @@ IF (MSVC) SET(CMAKE_C_FLAGS_DEBUG "/Od /DEBUG /MTd") SET(CMAKE_C_FLAGS_RELEASE "/MT /O2") ELSE () - SET(CMAKE_C_FLAGS "-O2 -g -Wall -Wextra -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes") + SET(CMAKE_C_FLAGS "-O2 -g -Wall -Wextra -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes ${CMAKE_C_FLAGS}") IF (NOT MINGW) # MinGW always does PIC and complains if we tell it to SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") ENDIF () From 5cb7a1addfa9015f834e5a95d88c0e7a40920d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Tue, 11 Oct 2011 18:12:36 +0200 Subject: [PATCH 3/3] Explain how to build universal OSX binaries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Martín Nieto --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b5c76a6be..82517bc48 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,10 @@ To install the library you can specify the install prefix by setting: $ cmake .. -DCMAKE_INSTALL_PREFIX=/install/prefix $ cmake --build . --target install +If you want to build a universal binary for Mac OS X, CMake sets it +all up for you if you use `-DCMAKE_OSX_ARCHITECTURES="i386;x86_64"` +when configuring. + For more advanced use or questions about CMake please read . The following CMake variables are declared: