[gtkmm-documentation] input example: Don't include build/config.h



commit e947e4ecb6127670d84ef78d1cc7ddff89730cf5
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Thu Aug 6 16:58:49 2020 +0200

    input example: Don't include build/config.h
    
    The configuration with Autotools or Meson sets the compiler
    option -DDONT_HAVE_MKFIFO=1, if mkfifo() does not exist.
    Meson does not create build/config.h.
    This makes life easier for those who build with their own
    Makefile or CMake file or whatever.
    Fixes #11

 configure.ac                       |  1 +
 examples/Makefile.am               |  3 +++
 examples/book/buildapp/Makefile.am |  2 +-
 examples/book/input/main.cc        |  5 ++---
 examples/book/meson.build          |  7 ++++---
 examples/meson.build               | 21 +--------------------
 6 files changed, 12 insertions(+), 27 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index dced41c0..208e7d8e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,6 +39,7 @@ GLIB_GSETTINGS
 
 AC_LANG([C++])
 AC_CHECK_FUNCS([mkfifo])
+AM_CONDITIONAL([MKFIFO_EXISTS], [test "x$ac_cv_func_mkfifo" = xyes])
 
 MM_ARG_ENABLE_WARNINGS([EXAMPLES_WXXFLAGS],
                        [-Wall],
diff --git a/examples/Makefile.am b/examples/Makefile.am
index e7954db6..66cbeaf6 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -467,6 +467,9 @@ book_infobar_example_SOURCES =              \
 
 book_input_example_SOURCES = \
        book/input/main.cc
+if !MKFIFO_EXISTS
+book_input_example_CXXFLAGS = -DDONT_HAVE_MKFIFO=1
+endif
 
 book_keyboard_events_simple_example_SOURCES =          \
        book/keyboard_events/simple/examplewindow.cc    \
diff --git a/examples/book/buildapp/Makefile.am b/examples/book/buildapp/Makefile.am
index 69001d26..51e515c4 100644
--- a/examples/book/buildapp/Makefile.am
+++ b/examples/book/buildapp/Makefile.am
@@ -21,7 +21,7 @@ check_DATA = $(GSCHEMAS_COMPILED)
 
 dist_noinst_DATA = \
   README \
-  step1/exampleapp.desktop \
+  step1/exampleapp.desktop.in \
   step1/exampleapp.png \
   step1/Makefile.example \
   $(STEP2_RESOURCES) \
diff --git a/examples/book/input/main.cc b/examples/book/input/main.cc
index dc4b2ef8..5d45346a 100644
--- a/examples/book/input/main.cc
+++ b/examples/book/input/main.cc
@@ -1,4 +1,3 @@
-#include <build/config.h>
 #include <gtkmm/application.h>
 #include <glibmm/main.h>
 #include <glibmm/iochannel.h>
@@ -51,7 +50,7 @@ int main(int argc, char *argv[])
 
   if (access("testfifo", F_OK) == -1) {
     // fifo doesn't exist - create it
-    #ifdef HAVE_MKFIFO
+    #ifndef DONT_HAVE_MKFIFO
     if (mkfifo("testfifo", 0666) != 0) {
       std::cerr << "error creating fifo" << std::endl;
       return -1;
@@ -59,7 +58,7 @@ int main(int argc, char *argv[])
     #else
       std::cerr << "error creating fifo: This platform does not have mkfifo()"
           << std::endl;
-    #endif //HAVE_MKFIFO
+    #endif //DONT_HAVE_MKFIFO
   }
 
   // Although we will only read from the fifo, we open it in read/write mode.
diff --git a/examples/book/meson.build b/examples/book/meson.build
index bccf9859..52bcce94 100644
--- a/examples/book/meson.build
+++ b/examples/book/meson.build
@@ -1,7 +1,7 @@
 # examples/book
 
 # input: gnome, gtkmm_dep, giomm_dep, build_examples_by_default,
-#        compile_schemas, copy_to_subdir, config_include_dir, python3,
+#        compile_schemas, copy_to_subdir, has_mkfifo, python3,
 #        meson_backend, test_timeout, project_build_root
 # input and output: examples_targets
 
@@ -120,10 +120,11 @@ foreach ex : examples_book
   endforeach
 
   if ex[0][0] == 'input'
-    # input/main.cc includes build/config.h.
+    # input/main.cc must know if mkfifo() exists.
+    # input/example is not a GUI app.
     exe_file = executable(ex_name, ex_sources, resources,
       dependencies: gtkmm_dep,
-      include_directories: config_include_dir,
+      cpp_args: has_mkfifo ? [] : [ '-DDONT_HAVE_MKFIFO=1' ],
       build_by_default: build_examples_by_default
     )
   else
diff --git a/examples/meson.build b/examples/meson.build
index e747a8a5..6a900795 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -4,27 +4,8 @@
 #        project_build_root, python3
 # output: build_examples_by_default
 
-# examples/book/input/main.cc includes build/config.h.
+# examples/book/input/main.cc must know if mkfifo() exists.
 has_mkfifo = cpp_compiler.has_function('mkfifo')
-conf_data = configuration_data()
-conf_data.set('HAVE_MKFIFO', has_mkfifo)
-conf_file = configure_file(
-  output: 'config.h',
-  configuration: conf_data
-)
-custom_target('build_config',
-  input: conf_file,
-  output: 'config.stamp',
-  command: [
-    python3, copy_to_subdir,
-    '@INPUT@',
-    'build',
-    'config.h',
-    '@OUTPUT@',
-  ],
-  build_by_default: true
-)
-config_include_dir = include_directories('.')
 
 meson_backend = find_program(meson.backend(), required: true)
 build_examples_by_default = get_option('build-examples')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]