From 898477ca44f8b0ca2fb90b6f05118d97c606de0d Mon Sep 17 00:00:00 2001 From: zhangjipeng Date: Wed, 5 Jun 2024 20:15:50 +0800 Subject: [PATCH] update cmake build --- build/configs.cmake | 12 ++++++++---- demos/demos.cmake | 1 + demos/interface.h | 1 + demos/platform_gtk2.c | 4 ++-- test/test.cmake | 1 + third_party/zlib-1.2.8/gzlib.c | 1 + third_party/zlib-1.2.8/gzread.c | 4 ++++ third_party/zlib-1.2.8/gzwrite.c | 4 ++++ 8 files changed, 22 insertions(+), 6 deletions(-) diff --git a/build/configs.cmake b/build/configs.cmake index 465ed81..5664237 100644 --- a/build/configs.cmake +++ b/build/configs.cmake @@ -4,10 +4,14 @@ # Contact: onecoolx@gmail.com if (WIN32) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /D_DEBUG /W3 /WX /Gm- /Gd /GR- /Zc:wchar_t-") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /W3 /WX /Gm- /Gd /GR- /Zc:wchar_t-") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /W3 /WX /Ot /GF /Gm- /GL /GR- /Gy /Zc:wchar_t-") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /WX /Ot /GF /Gm- /GL /GR- /Gy /Zc:wchar_t-") elseif (UNIX AND NOT APPLE) - set(CMAKE_CXX_FLAGS_DEBUG "-O0 -Wall -g -fPIC -std=c++11 -fno-rtti -fno-exceptions -Wno-unused-result -Wno-register -Wno-attributes") - set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -fPIC -std=c++11 -fno-rtti -fno-exceptions -Wno-unused-result -Wno-register -Wno-attributes") + set(CMAKE_C_FLAGS_DEBUG "-D_DEBUG -O0 -Wall -g -Wno-unused-result") + set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -O0 -Wall -g -std=c++11 -fno-rtti -fno-exceptions -Wno-unused-result -Wno-register -Wno-attributes") + set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3 -Wall -Wno-unused-result") + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -Wall -std=c++11 -fno-rtti -fno-exceptions -Wno-unused-result -Wno-register -Wno-attributes") elseif (APPLE) endif() diff --git a/demos/demos.cmake b/demos/demos.cmake index 65072a9..1e9d71c 100644 --- a/demos/demos.cmake +++ b/demos/demos.cmake @@ -8,6 +8,7 @@ if (WIN32) set(app_type WIN32) elseif (UNIX AND NOT APPLE) find_package(GTK2 REQUIRED) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") set(plat_file ${PROJECT_ROOT}/demos/platform_gtk2.c) set(plat_gui_inc ${GTK2_INCLUDE_DIRS}) set(plat_gui_lib ${GTK2_LIBRARIES} pthread) diff --git a/demos/interface.h b/demos/interface.h index b714692..ea6680f 100644 --- a/demos/interface.h +++ b/demos/interface.h @@ -12,6 +12,7 @@ extern "C" { #endif /* __cplusplus */ typedef enum { + EVENT_TYPE_UNKNOWN = -1, LEFT_BUTTON_DOWN, LEFT_BUTTON_UP, RIGHT_BUTTON_DOWN, diff --git a/demos/platform_gtk2.c b/demos/platform_gtk2.c index 6c282e2..5f1027c 100644 --- a/demos/platform_gtk2.c +++ b/demos/platform_gtk2.c @@ -157,7 +157,7 @@ static gboolean key_release(GtkWidget *widget, GdkEventKey *event) static gboolean mouse_button_press(GtkWidget *widget, GdkEventButton *event) { - mouse_event_type type; + mouse_event_type type = EVENT_TYPE_UNKNOWN; unsigned int key = 0; switch(event->button){ case 1: @@ -183,7 +183,7 @@ static gboolean mouse_button_press(GtkWidget *widget, GdkEventButton *event) static gboolean mouse_button_release(GtkWidget *widget, GdkEventButton *event) { - mouse_event_type type; + mouse_event_type type = EVENT_TYPE_UNKNOWN; unsigned int key = 0; switch(event->button){ case 1: diff --git a/test/test.cmake b/test/test.cmake index 0dbad8e..e3b6fb7 100644 --- a/test/test.cmake +++ b/test/test.cmake @@ -19,6 +19,7 @@ if (WIN32) ) elseif (UNIX AND NOT APPLE) find_package(GTK2 REQUIRED) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") set(thread_file ${PROJECT_ROOT}/test/thr_posix.c) set(main_file ${PROJECT_ROOT}/test/testGtk2.c) set(host_gui_inc ${GTK2_INCLUDE_DIRS}) diff --git a/third_party/zlib-1.2.8/gzlib.c b/third_party/zlib-1.2.8/gzlib.c index fae202e..a3183fb 100644 --- a/third_party/zlib-1.2.8/gzlib.c +++ b/third_party/zlib-1.2.8/gzlib.c @@ -7,6 +7,7 @@ #if defined(_WIN32) && !defined(__BORLANDC__) # define LSEEK _lseeki64 +# define open _open #else #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 # define LSEEK lseek64 diff --git a/third_party/zlib-1.2.8/gzread.c b/third_party/zlib-1.2.8/gzread.c index bf4538e..cfceed7 100644 --- a/third_party/zlib-1.2.8/gzread.c +++ b/third_party/zlib-1.2.8/gzread.c @@ -4,6 +4,10 @@ */ #include "gzguts.h" +#if defined(_WIN32) && !defined(__BORLANDC__) +# define read _read +# define close _close +#endif /* Local functions */ local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); diff --git a/third_party/zlib-1.2.8/gzwrite.c b/third_party/zlib-1.2.8/gzwrite.c index aa767fb..6cc96f1 100644 --- a/third_party/zlib-1.2.8/gzwrite.c +++ b/third_party/zlib-1.2.8/gzwrite.c @@ -4,6 +4,10 @@ */ #include "gzguts.h" +#if defined(_WIN32) && !defined(__BORLANDC__) +# define write _write +# define close _close +#endif /* Local functions */ local int gz_init OF((gz_statep));