Rename dissectors.c.in and fix CMake on removals
authorPeter Wu <peter@lekensteyn.nl>
Thu, 30 Nov 2017 02:05:07 +0000 (02:05 +0000)
committerPeter Wu <peter@lekensteyn.nl>
Sun, 24 Dec 2017 13:30:06 +0000 (13:30 +0000)
"dissectors.c.in" is an input file for "make-dissectors" which outputs
"dissectors.c", but does not contain C code. Rename it to
"dissectors.in.txt" instead.

When a dissector is removed from the list, the dissectors.c file was not
properly generated even if CMake was re-run. Fix this by adding an
additional dependency on the input file. autotools likely suffers from
the same problem with removed files, I have not tried to fix that.

Restore's João's original approach using file(GENERATE) to avoid using
configure_file, this requires CMake 2.8.12.

Change-Id: Id07cd8ef502186a90d41b3bb77ed0d9c94845af9
Fixes: v2.5.0rc0-1763-gfe0c2b0485 ("Rewrite make-dissector-reg.py in C")
Reviewed-on: https://code.wireshark.org/review/24659
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
.gitignore
CMakeLists.txt
epan/dissectors/CMakeLists.txt
epan/dissectors/Makefile.am

index 3f38a852bb9b510731cca635687f93e1e4cad41c..e599d6074c37882740604454fcd8ef66e165d40e 100644 (file)
@@ -32,7 +32,7 @@ epan/dissectors/mesa
 epan/dissectors/xcbproto
 epan/dissectors/packet-ncp2222.c
 epan/dissectors/dissectors.c
-epan/dissectors/dissectors.c.in
+epan/dissectors/dissectors.in.txt
 epan/dissectors/make-dissectors
 epan/dtd_parse.c
 epan/dtd_preparse.c
index e3bd66d4ea2519a48fe81e7502a117b85de48630..14b53d61f481632febb3bc9e97de0e71b73b6ba1 100644 (file)
@@ -50,7 +50,7 @@ if(WIN32)
        # Needed for GREATER_EQUAL operator
        cmake_minimum_required(VERSION 3.7)
 else()
-       cmake_minimum_required(VERSION 2.8.11)
+       cmake_minimum_required(VERSION 2.8.12)
 endif()
 
 #Where to find local cmake scripts
index 480b40eae084d6fc2bef583df152c2eedb071ca6..9f4eff5cbe9eadd8ac9584e11d2267ec7e25488b 100644 (file)
@@ -1871,15 +1871,15 @@ target_link_libraries(make-dissectors ${GLIB2_LIBRARIES})
 # We pass the arguments to make-dissectors in a file to avoid limitations
 # with the number of arguments handled by main().
 #
-string(REPLACE ";" "\n" dissectors_c_in_contents "${ALL_DISSECTOR_SRC}\n")
-file(WRITE
-       "${CMAKE_CURRENT_BINARY_DIR}/dissectors.c.in"
-       "${dissectors_c_in_contents}"
+file(GENERATE
+       OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/dissectors.in.txt"
+       CONTENT "$<JOIN:${ALL_DISSECTOR_SRC},\n>\n"
 )
 add_custom_command(
        OUTPUT dissectors.c
-       COMMAND make-dissectors dissectors.c @dissectors.c.in
+       COMMAND make-dissectors dissectors.c @dissectors.in.txt
        DEPENDS make-dissectors ${ALL_DISSECTOR_SRC}
+               "${CMAKE_CURRENT_BINARY_DIR}/dissectors.in.txt"
        COMMENT "Making dissectors.c"
 )
 
index 28982e65738779321336a997e0b1aa4d4bb120a1..86aa69f1d33c671254cfeb513e359d758c43e9c6 100644 (file)
@@ -1946,11 +1946,11 @@ x11-dissector: $(top_srcdir)/tools/process-x11-fields.pl $(srcdir)/x11-fields $(
 #
 dissectors.c: make-dissectors $(ALL_DISSECTORS_SRC)
        @echo Making dissectors.c
-       @echo $^ | tr ' ' '\n' | $(GREP) '\.c$$' > $@.in && \
-           $(builddir)/make-dissectors $@ @$@.in
+       @echo $^ | tr ' ' '\n' | $(GREP) '\.c$$' > dissectors.in.txt && \
+           $(builddir)/make-dissectors $@ @dissectors.in.txt
 
 MOSTLYCLEANFILES = \
-       dissectors.c.in
+       dissectors.in.txt
 
 DISTCLEANFILES = \
        $(NODIST_GENERATED_FILES)