From dbe46fbdfdee05b6d41e9a420e1e196e877588df Mon Sep 17 00:00:00 2001 From: Alexander Zhylin Date: Tue, 10 Feb 2026 14:24:32 +0200 Subject: [PATCH] CMake: updates compiler definitions --- src/CMakeLists.txt | 42 +++++++++++++++++++++--------------------- src/main.h | 13 ------------- src/query.c | 1 + 3 files changed, 22 insertions(+), 34 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d7378ba..219d1c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,26 @@ add_executable(zbbs-client-tui) set_property(TARGET zbbs-client-tui PROPERTY C_STANDARD 23) +if( + (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") OR + (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") +) + if (ZBBS_DEBUG) + target_compile_options(zbbs-client-tui PRIVATE /W3) + message("Include debug info (Microsoft)") + endif() +elseif( + (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR + (CMAKE_CXX_COMPILER_ID MATCHES "Clang") +) + add_compile_definitions(_GNU_SOURCE) + # target_compile_definitions(zbbs-client-tui PRIVATE _GNU_SOURCE) -> doesn't work + if (ZBBS_DEBUG) + target_compile_options(zbbs-client-tui PRIVATE -Wall -ggdb -pedantic) + message("Include debug info (GNU/Clang)") + endif() +endif() + file(GLOB M_HEADERS "*.h") file(GLOB M_SOURCES "*.c") @@ -28,24 +48,4 @@ target_link_libraries(zbbs-client-tui widget modals ${CURSES_LIBRARIES} -) - -if (ZBBS_DEBUG) -if( - (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") OR - (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") -) - - target_compile_options(zbbs-client-tui PRIVATE /W3) - message("Include debug info (Microsoft)") - -elseif( - (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR - (CMAKE_CXX_COMPILER_ID MATCHES "Clang") -) - - target_compile_options(zbbs-client-tui PRIVATE -Wall -ggdb -pedantic) - message("Include debug info (GNU/Clang)") - -endif() -endif() \ No newline at end of file +) \ No newline at end of file diff --git a/src/main.h b/src/main.h index 14a938b..af03d2f 100644 --- a/src/main.h +++ b/src/main.h @@ -3,7 +3,6 @@ #include #include -#include "types.h" #define LOCAL_PORT 1999 #define SERVER_PORT 2000 @@ -14,18 +13,6 @@ #define DIALOGUE_TEXT 4096 #define INPUT_TEXT DIALOGUE_TITLE -#ifndef __USE_GNU -#define __USE_GNU 1 -#endif - -#ifndef __USE_MISC -#define __USE_MISC 1 -#endif - -#ifndef __USE_XOPEN_EXTENDED -#define __USE_XOPEN_EXTENDED 1 -#endif - typedef struct params { unsigned short port; unsigned addr; diff --git a/src/query.c b/src/query.c index 1e81ea4..b140df2 100644 --- a/src/query.c +++ b/src/query.c @@ -22,6 +22,7 @@ #include "server.h" #include "app.h" #include "draw-modal.h" +#include "types.h" static void wait_side(query_args_t *q_args); void user_request_description(query_args_t *q_args);