summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2016-06-20 11:09:49 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2016-10-01 17:40:40 +0200
commitc7a033690e5ec8469f296103f35278602033363b (patch)
treee7945825101384c23ce2f3e3756f06973b0661f2
parentcc43d185e319cf7ce9946574f16611cab1d6d1e0 (diff)
downloadlibgit2-c7a033690e5ec8469f296103f35278602033363b.tar.gz
cmake: do not use -fPIC for MSYS2
The MSYS2 build system automatically compiles all code with position-independent code. When we manually add the -fPIC flag to the compiler flags, MSYS2 will loudly complain about PIC being the default and thus not required. Fix the annoyance by stripping -fPIC in MSYS2 enviroments like it is already done for MinGW.
-rw-r--r--CMakeLists.txt14
1 files changed, 8 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd683073b..7baf68b5d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -473,19 +473,21 @@ ELSE ()
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
ENDIF ()
- IF (MINGW) # MinGW always does PIC and complains if we tell it to
+ IF (MINGW OR MSYS) # MinGW and MSYS always do PIC and complain if we tell them to
STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
- # MinGW >= 3.14 uses the C99-style stdio functions
- # automatically, but forks like mingw-w64 still want
- # us to define this in order to use them
- ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1)
-
ELSEIF (BUILD_SHARED_LIBS)
ADD_C_FLAG_IF_SUPPORTED(-fvisibility=hidden)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
ENDIF ()
+ IF (MINGW)
+ # MinGW >= 3.14 uses the C99-style stdio functions
+ # automatically, but forks like mingw-w64 still want
+ # us to define this in order to use them
+ ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1)
+ ENDIF ()
+
ADD_C_FLAG_IF_SUPPORTED(-Wdocumentation)
ADD_C_FLAG_IF_SUPPORTED(-Wno-missing-field-initializers)
ADD_C_FLAG_IF_SUPPORTED(-Wstrict-aliasing=2)