summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-01-09 12:33:47 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2019-01-17 21:17:32 +0000
commita74dd39b232ae8c54517446089316b9643b3a84a (patch)
treeb4d6a15a17f6a45570a804331cba34eab5d7994b /CMakeLists.txt
parentb78bcbb9b1217d6aada0ab98f3053cb8f151a8a3 (diff)
downloadlibgit2-a74dd39b232ae8c54517446089316b9643b3a84a.tar.gz
Use cdecl calling conventions on Win32
The recommendation from engineers within Microsoft is that libraries should have a calling convention specified in the public API, and that calling convention should be cdecl unless there are strong reasons to use a different calling convention. We previously offered end-users the choice between cdecl and stdcall calling conventions. We did this for presumed wider compatibility: most Windows applications will use cdecl, but C# and PInvoke default to stdcall for WINAPI compatibility. (On Windows, the standard library functions are are stdcall so PInvoke also defaults to stdcall.) However, C# and PInvoke can easily call cdecl APIs by specifying an annotation. Thus, we will explicitly declare ourselves cdecl and remove the option to build as stdcall.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt14
1 files changed, 2 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eff2500d5..f1da8c9f0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,14 +74,6 @@ IF (APPLE)
ENDIF()
IF(MSVC)
- # This option is only available when building with MSVC. By default, libgit2
- # is build using the cdecl calling convention, which is useful if you're
- # writing C. However, the CLR and Win32 API both expect stdcall.
- #
- # If you are writing a CLR program and want to link to libgit2, you'll want
- # to turn this on by invoking CMake with the "-DSTDCALL=ON" argument.
- OPTION(STDCALL "Build libgit2 with the __stdcall convention" OFF)
-
# This option must match the settings used in your program, in particular if you
# are linking statically
OPTION(STATIC_CRT "Link the static CRT libraries" ON)
@@ -125,10 +117,8 @@ IF (MSVC)
# /MP - Parallel build
SET(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}")
- IF (STDCALL)
- # /Gz - stdcall calling convention
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz")
- ENDIF ()
+ # /Gd - explicitly set cdecl calling convention
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd")
IF (STATIC_CRT)
SET(CRT_FLAG_DEBUG "/MTd")