diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bea4791..da857c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,8 +22,6 @@ jobs: - name: Build using cmake env: EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON - CFLAGS: -Werror - CXXFLAGS: -Werror run: mkdir build && cd build && cmake .. && make - name: Build using makefile @@ -57,8 +55,6 @@ jobs: - name: Build using cmake env: EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON - CFLAGS: -Werror - CXXFLAGS: -Werror run: mkdir build && cd build && cmake3 .. && make - name: Build using Makefile @@ -102,8 +98,6 @@ jobs: - name: Build using cmake env: EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON - CFLAGS: -Werror - CXXFLAGS: -Werror run: mkdir build && cd build && cmake .. && make - name: Build using Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt index f9af305..431c2d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,14 @@ OPTION(ENABLE_RDMA "Build valkey_rdma for RDMA support" OFF) SET(CMAKE_C_STANDARD 99) SET(CMAKE_DEBUG_POSTFIX d) +# Set target-common flags +if(NOT WIN32) + add_compile_options(-Werror -Wall -Wextra -pedantic) + add_compile_options(-Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers) +else() + add_definitions(-D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN) +endif() + SET(valkey_sources src/adlist.c src/alloc.c @@ -45,10 +53,6 @@ SET(valkey_sources src/valkeycluster.c src/vkutil.c) -IF(WIN32) - ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN) -ENDIF() - ADD_LIBRARY(valkey ${valkey_sources}) ADD_LIBRARY(valkey::valkey ALIAS valkey) set(valkey_export_name valkey CACHE STRING "Name of the exported target") diff --git a/Makefile b/Makefile index a1593e3..350fe42 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ export VALKEY_TEST_CONFIG CC := $(if $(shell command -v $(firstword $(CC)) >/dev/null 2>&1 && echo OK),$(CC),gcc) OPTIMIZATION?=-O3 -WARNINGS=-Wall -Wextra -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers +WARNINGS=-Wall -Wextra -pedantic -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers USE_WERROR?=1 ifeq ($(USE_WERROR),1) WARNINGS+=-Werror diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6476803..81d4ed8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -53,12 +53,10 @@ find_path(LIBEVENT_INCLUDES event2/event.h) if(LIBEVENT_INCLUDES) include_directories(${LIBEVENT_INCLUDES}) endif() - if(MSVC OR MINGW) find_library(LIBEVENT_LIBRARY Libevent) else() - add_compile_options(-Wall -Wextra -pedantic -Werror) - # Debug mode for tests + # Use the Debug configuration when building tests (no -DNDEBUG) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "" FORCE) endif()