summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-06-13 11:03:38 +0200
committerPatrick Steinhardt <ps@pks.im>2017-06-13 11:14:53 +0200
commit613999534ee01c3f85046479db0d62eece6f2332 (patch)
treec4c62eb0d2a44e4cb0951a50ecd36f612e7f0ad1
parente94be4c01c5b6b2cd849a9accf80f3f93d429a76 (diff)
downloadlibgit2-613999534ee01c3f85046479db0d62eece6f2332.tar.gz
cmake: set "-D_DEBUG" on non-Windows platforms
In our code base, we have some occasions where we use the "_DEBUG" preprocessor macro to enable additional code which should not be part of release builds. While we define this flag on MSVC platforms, it is guarded by the conditional `WIN32 AND NOT CYGWIN` on other platforms since 19be3f9e6 (Improve MSVC compiler, linker flags, 2013-02-13). While this condition can be fulfilled by the MSVC platform, it is never encountered due to being part of the `ELSE` part of `IF (MSVC)`. The intention of the conditional was most likely to avoid the preprocessor macro on Cygwin platforms, but to include it on everthing else. As such, the correct condition here would be `IF (NOT CYGWIN)` instead. But digging a bit further, the condition is only ever used in two places: 1. To skip the test in "core::structinit", which should also work on Cygwin. 2. In "src/win32/git2.rc", where it is used to set additional file flags. As this file is included in MSVC builds only, it cannot cause any harm to set "_DEBUG" on Cygwin here. As such, we can simply drop the conditional and always set "-D_DEBUG" on all platforms.
-rw-r--r--CMakeLists.txt4
1 files changed, 1 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 259bd96a2..4ca6543d4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -478,9 +478,7 @@ ELSE ()
SET(CMAKE_C_FLAGS "-std=c99 -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS ${CMAKE_C_FLAGS}")
ENDIF()
- IF (WIN32 AND NOT CYGWIN)
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
- ENDIF ()
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
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}")