From 091211a48c872ff38a3dd09026a446e529e8b704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Sun, 12 Apr 2020 01:44:12 +0100 Subject: [PATCH] Guard VS configuration in CMake file with `MSVC` The CMake file is implicitly assuming that Microsoft Visual Studio is the only compiler for Windows, which is of course false. The Microsoft Visual Studio-specific configuration should be guarded with [`MSVC`](https://cmake.org/cmake/help/latest/variable/MSVC.html). This change makes it possible to build YAJL with MinGW for example, see [this patch](https://github.com/msys2/MINGW-packages/blob/11cf0665cfd6a4cf70fea61f60374a5dc07ee5f3/mingw-w64-yajl/01-fix-compiler.patch) in the MINGW-packages repository. --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 471eee13..42043fd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ ENDIF (NOT CMAKE_BUILD_TYPE) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") -IF (WIN32) +IF (MSVC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") ADD_DEFINITIONS(-DWIN32) SET(linkFlags "/PDB:NONE /INCREMENTAL:NO /OPT:NOREF /OPT:NOICF") @@ -46,7 +46,7 @@ IF (WIN32) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996 /wd4255 /wd4130 /wd4100 /wd4711") SET(CMAKE_C_FLAGS_DEBUG "/D DEBUG /Od /Z7") SET(CMAKE_C_FLAGS_RELEASE "/D NDEBUG /O2") -ELSE (WIN32) +ELSE (MSVC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") IF(CMAKE_COMPILER_IS_GNUCC) INCLUDE(CheckCCompilerFlag) @@ -60,7 +60,7 @@ ELSE (WIN32) SET(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g") SET(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -Wuninitialized") -ENDIF (WIN32) +ENDIF (MSVC) ADD_SUBDIRECTORY(src)