From 11c3f95c692cd15cada16153c903ee92f83334b4 Mon Sep 17 00:00:00 2001 From: TimePath Date: Fri, 19 Feb 2016 16:48:54 +1100 Subject: [PATCH] Cmake cleanup --- CMakeLists.txt | 2 +- README.md | 16 +++++++--------- libs/CMakeLists.txt | 3 +-- libs/_.cpp | 0 libs/container/hashfunc.h | 4 ++-- libs/gtkutil/image.cpp | 4 ++-- libs/l_net/l_net.c | 2 +- libs/math/CMakeLists.txt | 2 +- libs/math/_.cpp | 0 libs/os/CMakeLists.txt | 3 +-- libs/os/_.cpp | 0 libs/picomodel/pm_fm.c | 2 +- libs/picomodel/pm_md2.c | 2 +- libs/script/CMakeLists.txt | 2 +- libs/script/_.cpp | 0 libs/splines/math_quaternion.h | 2 +- libs/stream/CMakeLists.txt | 2 +- libs/stream/_.cpp | 0 radiant/CMakeLists.txt | 4 ++++ radiant/build.cpp | 4 ++-- radiant/console.cpp | 2 +- radiant/entitylist.cpp | 8 ++++---- radiant/groupdialog.cpp | 2 +- radiant/mainframe.cpp | 2 +- radiant/patchdialog.cpp | 12 ++++++------ radiant/qgl.cpp | 2 ++ radiant/scenegraph.h | 2 +- radiant/server.cpp | 1 + 28 files changed, 44 insertions(+), 41 deletions(-) create mode 100644 libs/_.cpp create mode 100644 libs/math/_.cpp create mode 100644 libs/os/_.cpp create mode 100644 libs/script/_.cpp create mode 100644 libs/stream/_.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index edd4f254..74e26787 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(NetRadiant C CXX) diff --git a/README.md b/README.md index c0fb8671..ff836cc3 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ See also https://gitlab.com/xonotic/netradiant/ for a source browser, issues and This project uses the usual CMake workflow: - mkdir build && cd build && cmake .. && make + mkdir build && cd build && cmake .. && cmake --build . ## linux @@ -44,13 +44,12 @@ cmake --build . -- -j$(nproc) ## msys2 -`base-devel` +`pacman -S --needed base-devel` ### 32 bit: ``` -pacman -S mingw-w64-i686-{toolchain,cmake} -pacman -S mingw-w64-i686-{gtk2,gtkglext} +pacman -S --needed mingw-w64-i686-{toolchain,cmake,gtk2,gtkglext} mkdir build && cd build cmake -G "MSYS Makefiles" .. -DGTK2_GLIBCONFIG_INCLUDE_DIR=/mingw32/lib/glib-2.0/include -DGTK2_GDKCONFIG_INCLUDE_DIR=/mingw32/lib/gtk-2.0/include cmake --build . -- -j$(nproc) @@ -59,8 +58,7 @@ cmake --build . -- -j$(nproc) ### 64 bit: ``` -pacman -S mingw-w64-x86_64-{toolchain,cmake} -pacman -S mingw-w64-x86_64-{gtk2,gtkglext} +pacman -S mingw-w64-x86_64-{toolchain,cmake,gtk2,gtkglext} mkdir build && cd build cmake -G "MSYS Makefiles" .. -DGTK2_GLIBCONFIG_INCLUDE_DIR=/mingw64/lib/glib-2.0/include -DGTK2_GDKCONFIG_INCLUDE_DIR=/mingw64/lib/gtk-2.0/include cmake --build . -- -j$(nproc) @@ -77,13 +75,13 @@ options: targets: * `radiant` Compiles the radiant core binary - * `plugins` Compiles all plugins (each plugin has its own target as well) * `modules` Compiles all modules (each module has its own target as well) + * `plugins` Compiles all plugins (each plugin has its own target as well) * `game_packs` Downloads the game pack data * `quake3` Compiles all the Quake3 tools - - `q3map2` Quake3 map compiler + - `q3map2` Quake3 map compiler - `q3data` * `quake2` Compiles all the Quake2 tools (Note: needs to be compiled explicitly) - - `q2map` Quake2 map compiler + - `q2map` Quake2 map compiler - `q2data` - `h2data` diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index cb751a0f..c5434fc8 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -29,6 +29,7 @@ add_subdirectory(uilib) add_subdirectory(xml) add_library(libs + _.cpp archivelib.h bytebool.h bytestreamutils.h @@ -44,7 +45,6 @@ add_library(libs instancelib.h maplib.h moduleobservers.h - picomodel/picomodel.h pivot.h render.h scenelib.h @@ -60,7 +60,6 @@ add_library(libs uniquenames.h versionlib.h ) -set_target_properties(libs PROPERTIES LINKER_LANGUAGE CXX) find_package(GLIB REQUIRED) target_include_directories(libs PRIVATE ${GLIB_INCLUDE_DIRS}) diff --git a/libs/_.cpp b/libs/_.cpp new file mode 100644 index 00000000..e69de29b diff --git a/libs/container/hashfunc.h b/libs/container/hashfunc.h index 59a34c7d..a9790b49 100644 --- a/libs/container/hashfunc.h +++ b/libs/container/hashfunc.h @@ -182,7 +182,7 @@ inline ub4 hash( const UB1Traits& ub1traits, const UB4x1Traits& ub4x1traits ){ - register ub4 a,b,c,len; + ub4 a,b,c,len; /* Set up the internal state */ len = length; @@ -240,7 +240,7 @@ inline ub4 hash2( ub4 initval, /* the previous hash, or an arbitrary value */ const UB4Traits& ub4traits ){ - register ub4 a,b,c,len; + ub4 a,b,c,len; /* Set up the internal state */ len = length; diff --git a/libs/gtkutil/image.cpp b/libs/gtkutil/image.cpp index dd723bfe..f1f9b8b1 100644 --- a/libs/gtkutil/image.cpp +++ b/libs/gtkutil/image.cpp @@ -45,7 +45,7 @@ GdkPixbuf* pixbuf_new_from_file_with_mask( const char* filename ){ else { GdkPixbuf* rgba = gdk_pixbuf_add_alpha( rgb, FALSE, 255, 0, 255 ); - gdk_pixbuf_unref( rgb ); + g_object_unref( rgb ); return rgba; } } @@ -58,7 +58,7 @@ GtkImage* image_new_from_file_with_mask( const char* filename ){ else { GtkImage* image = GTK_IMAGE( gtk_image_new_from_pixbuf( rgba ) ); - gdk_pixbuf_unref( rgba ); + g_object_unref( rgba ); return image; } } diff --git a/libs/l_net/l_net.c b/libs/l_net/l_net.c index caf6c422..7f50d054 100644 --- a/libs/l_net/l_net.c +++ b/libs/l_net/l_net.c @@ -51,7 +51,7 @@ void WinPrint( const char *str, ... ){ vsprintf( text, str, argptr ); va_end( argptr ); - printf( text ); + printf( "%s", text ); } #else void WinPrint( const char *str, ... ){ diff --git a/libs/math/CMakeLists.txt b/libs/math/CMakeLists.txt index 1520e48b..d070db1b 100644 --- a/libs/math/CMakeLists.txt +++ b/libs/math/CMakeLists.txt @@ -1,4 +1,5 @@ add_library(math + _.cpp aabb.h curve.h # expression.cpp expression.h @@ -10,4 +11,3 @@ add_library(math quaternion.h vector.h ) -set_target_properties(math PROPERTIES LINKER_LANGUAGE CXX) diff --git a/libs/math/_.cpp b/libs/math/_.cpp new file mode 100644 index 00000000..e69de29b diff --git a/libs/os/CMakeLists.txt b/libs/os/CMakeLists.txt index 5978d980..cba5ec01 100644 --- a/libs/os/CMakeLists.txt +++ b/libs/os/CMakeLists.txt @@ -1,10 +1,9 @@ add_library(os + _.cpp dir.h file.h path.h ) -set_target_properties(os PROPERTIES LINKER_LANGUAGE CXX) find_package(GLIB REQUIRED) target_include_directories(os PRIVATE ${GLIB_INCLUDE_DIRS}) - diff --git a/libs/os/_.cpp b/libs/os/_.cpp new file mode 100644 index 00000000..e69de29b diff --git a/libs/picomodel/pm_fm.c b/libs/picomodel/pm_fm.c index eefee2e7..2d6e3e8e 100644 --- a/libs/picomodel/pm_fm.c +++ b/libs/picomodel/pm_fm.c @@ -447,7 +447,7 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){ #endif continue; } - else if ( ( p_index_LUT[triangle->index_xyz[j]].next == NULL ) ) { // Not equal to Main entry, and no LL entry + else if ( p_index_LUT[triangle->index_xyz[j]].next == NULL ) { // Not equal to Main entry, and no LL entry // Add first entry of LL from Main p_index_LUT2 = (index_LUT_t *)_pico_alloc( sizeof( index_LUT_t ) ); if ( p_index_LUT2 == NULL ) { diff --git a/libs/picomodel/pm_md2.c b/libs/picomodel/pm_md2.c index 28cf384e..e6459914 100644 --- a/libs/picomodel/pm_md2.c +++ b/libs/picomodel/pm_md2.c @@ -499,7 +499,7 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){ continue; } - else if ( ( p_index_LUT[p_md2Triangle->index_xyz[j]].next == NULL ) ) { // Not equal to Main entry, and no LL entry + else if ( p_index_LUT[p_md2Triangle->index_xyz[j]].next == NULL ) { // Not equal to Main entry, and no LL entry // Add first entry of LL from Main p_index_LUT2 = (index_LUT_t *)_pico_alloc( sizeof( index_LUT_t ) ); if ( p_index_LUT2 == NULL ) { diff --git a/libs/script/CMakeLists.txt b/libs/script/CMakeLists.txt index b3fd7140..6e49527d 100644 --- a/libs/script/CMakeLists.txt +++ b/libs/script/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(script + _.cpp scripttokeniser.h scripttokenwriter.h ) -set_target_properties(script PROPERTIES LINKER_LANGUAGE CXX) diff --git a/libs/script/_.cpp b/libs/script/_.cpp new file mode 100644 index 00000000..e69de29b diff --git a/libs/splines/math_quaternion.h b/libs/splines/math_quaternion.h index 8632661d..b33f4425 100644 --- a/libs/splines/math_quaternion.h +++ b/libs/splines/math_quaternion.h @@ -157,7 +157,7 @@ inline int operator==( quat_t a, quat_t b ) { } inline int operator!=( quat_t a, quat_t b ) { - return ( ( a.x != b.x ) || ( a.y != b.y ) || ( a.z != b.z ) && ( a.w != b.w ) ); + return ( ( a.x != b.x ) || ( a.y != b.y ) || (( a.z != b.z ) && ( a.w != b.w )) ); } inline float quat_t::Length( void ) { diff --git a/libs/stream/CMakeLists.txt b/libs/stream/CMakeLists.txt index a37c4591..6ce79395 100644 --- a/libs/stream/CMakeLists.txt +++ b/libs/stream/CMakeLists.txt @@ -1,8 +1,8 @@ add_library(stream + _.cpp filestream.h memstream.h stringstream.h textfilestream.h textstream.h ) -set_target_properties(stream PROPERTIES LINKER_LANGUAGE CXX) diff --git a/libs/stream/_.cpp b/libs/stream/_.cpp new file mode 100644 index 00000000..e69de29b diff --git a/radiant/CMakeLists.txt b/radiant/CMakeLists.txt index 452407e1..b0032207 100644 --- a/radiant/CMakeLists.txt +++ b/radiant/CMakeLists.txt @@ -189,6 +189,7 @@ target_link_libraries(radiant ${LIBXML2_LIBRARIES} ${OPENGL_gl_LIBRARY} ${GTK2_LIBRARIES} + ${GTK2_PANGO_LIBRARY} ${GTKGL_LIBRARIES} includes cmdlib @@ -216,3 +217,6 @@ target_link_libraries(radiant uilib xmllib ) +if (X11_LIBRARIES) + target_link_libraries(radiant ${X11_LIBRARIES}) +endif () diff --git a/radiant/build.cpp b/radiant/build.cpp index 0e85d942..f6826353 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -877,7 +877,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi auto renderer = ui::CellRendererText(); object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE ); - g_signal_connect( renderer, "edited", G_CALLBACK( project_cell_edited ), &projectList ); + g_signal_connect( G_OBJECT(renderer), "edited", G_CALLBACK( project_cell_edited ), &projectList ); GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); @@ -914,7 +914,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi auto renderer = ui::CellRendererText(); object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE ); - g_signal_connect( renderer, "edited", G_CALLBACK( commands_cell_edited ), store ); + g_signal_connect( G_OBJECT(renderer), "edited", G_CALLBACK( commands_cell_edited ), store ); GtkTreeViewColumn* column = ui::TreeViewColumn( "", renderer, {{"text", 0}} ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); diff --git a/radiant/console.cpp b/radiant/console.cpp index ad169054..8ca6f2ef 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -145,7 +145,7 @@ public: GtkTextBufferOutputStream( GtkTextBuffer* textBuffer, GtkTextIter* iter, GtkTextTag* tag ) : textBuffer( textBuffer ), iter( iter ), tag( tag ){ } std::size_t write( const char* buffer, std::size_t length ){ - gtk_text_buffer_insert_with_tags( textBuffer, iter, buffer, gint( length ), tag, 0 ); + gtk_text_buffer_insert_with_tags( textBuffer, iter, buffer, gint( length ), tag, nullptr ); return length; } }; diff --git a/radiant/entitylist.cpp b/radiant/entitylist.cpp index a9b9a668..60b3e357 100644 --- a/radiant/entitylist.cpp +++ b/radiant/entitylist.cpp @@ -116,22 +116,22 @@ void entitylist_treeviewcolumn_celldatafunc( GtkTreeViewColumn* column, GtkCellR if ( node != 0 ) { gtk_cell_renderer_set_fixed_size( renderer, -1, -1 ); char* name = const_cast( node_get_name( *node ) ); - g_object_set( G_OBJECT( renderer ), "text", name, "visible", TRUE, 0 ); + g_object_set( G_OBJECT( renderer ), "text", name, "visible", TRUE, nullptr ); //globalOutputStream() << "rendering cell " << makeQuoted(name) << "\n"; GtkStyle* style = gtk_widget_get_style( GTK_WIDGET( getEntityList().m_tree_view ) ); if ( instance->childSelected() ) { - g_object_set( G_OBJECT( renderer ), "cell-background-gdk", &style->base[GTK_STATE_ACTIVE], 0 ); + g_object_set( G_OBJECT( renderer ), "cell-background-gdk", &style->base[GTK_STATE_ACTIVE], nullptr ); } else { - g_object_set( G_OBJECT( renderer ), "cell-background-gdk", &style->base[GTK_STATE_NORMAL], 0 ); + g_object_set( G_OBJECT( renderer ), "cell-background-gdk", &style->base[GTK_STATE_NORMAL], nullptr ); } } else { gtk_cell_renderer_set_fixed_size( renderer, -1, 0 ); - g_object_set( G_OBJECT( renderer ), "text", "", "visible", FALSE, 0 ); + g_object_set( G_OBJECT( renderer ), "text", "", "visible", FALSE, nullptr ); } } diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index f6e1d28b..7b954535 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -118,7 +118,7 @@ void GroupDlg::Create( ui::Window parent ){ gtk_notebook_set_tab_pos( GTK_NOTEBOOK( notebook ), GTK_POS_BOTTOM ); m_pNotebook = notebook; - g_signal_connect( notebook, "switch_page", G_CALLBACK( switch_page ), window ); + g_signal_connect( G_OBJECT(notebook), "switch_page", G_CALLBACK( switch_page ), (gpointer) window ); } } diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 9b7ac01f..a8e1e22a 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -2714,7 +2714,7 @@ void MainFrame::Create(){ GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask( "bitmaps/icon.png" ); if ( pixbuf != 0 ) { gtk_window_set_icon( window, pixbuf ); - gdk_pixbuf_unref( pixbuf ); + g_object_unref( pixbuf ); } } #endif diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index 660face4..3e49e818 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -895,8 +895,8 @@ ui::Window PatchInspector::BuildDialog(){ entry_set_float( entry, g_pi_globals.shift[0] ); auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 ); - g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "hshift_adj", adj ); + g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), (gpointer) entry ); + g_object_set_data( G_OBJECT( window ), "hshift_adj", (gpointer) adj ); auto spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); @@ -917,7 +917,7 @@ ui::Window PatchInspector::BuildDialog(){ auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "vshift_adj", adj ); + g_object_set_data( G_OBJECT( window ), "vshift_adj", (gpointer) adj ); auto spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); @@ -938,7 +938,7 @@ ui::Window PatchInspector::BuildDialog(){ auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "hscale_adj", adj ); + g_object_set_data( G_OBJECT( window ), "hscale_adj", (gpointer) adj ); auto spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); @@ -959,7 +959,7 @@ ui::Window PatchInspector::BuildDialog(){ auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "vscale_adj", adj ); + g_object_set_data( G_OBJECT( window ), "vscale_adj", (gpointer) adj ); auto spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); @@ -980,7 +980,7 @@ ui::Window PatchInspector::BuildDialog(){ auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); // NOTE: Arnout - this really should be 360 but can't change it anymore as it could break existing maps g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry ); - g_object_set_data( G_OBJECT( window ), "rotate_adj", adj ); + g_object_set_data( G_OBJECT( window ), "rotate_adj", (gpointer) adj ); auto spin = ui::SpinButton( adj, 1, 0 ); gtk_widget_show( GTK_WIDGET( spin ) ); diff --git a/radiant/qgl.cpp b/radiant/qgl.cpp index 645af34d..6d4e248c 100644 --- a/radiant/qgl.cpp +++ b/radiant/qgl.cpp @@ -71,7 +71,9 @@ void QGL_Shutdown( OpenGLBinding& table ){ #if defined( WIN32 ) qwglGetProcAddress = 0; #elif defined( XWINDOWS ) + #ifndef __APPLE__ qglXQueryExtension = glXQueryExtension; + #endif qglXGetProcAddressARB = 0; #else #error "unsupported platform" diff --git a/radiant/scenegraph.h b/radiant/scenegraph.h index 48fb08b3..759c34c0 100644 --- a/radiant/scenegraph.h +++ b/radiant/scenegraph.h @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#if !defined( INCLUDEDE_SCENEGRAPH_H ) +#if !defined( INCLUDED_SCENEGRAPH_H ) #define INCLUDED_SCENEGRAPH_H #endif diff --git a/radiant/server.cpp b/radiant/server.cpp index c9f0e7c6..4f83e0ac 100644 --- a/radiant/server.cpp +++ b/radiant/server.cpp @@ -24,6 +24,7 @@ #include "debugging/debugging.h" #include +#include #include "os/path.h" #include "modulesystem.h" -- 2.39.2