From 3b46e6eaf61a29f9bd8f8c162caa54cc2ea81fe2 Mon Sep 17 00:00:00 2001 From: Joerg Mayer Date: Thu, 18 Sep 2014 08:05:48 +0200 Subject: [PATCH] Having CmakeListsCustom.txt in git defeats the purpose of its existence: If it is used, there is a modified file in git. Fix this by only including the file if it exists. Other changes: - Rename the existing Custom files to CMakeListsCustom.txt.example. - Move the plugins custom file to the top level (same level as its including parent). - Optionally allow a list of custom includes instead of the default one. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8960eac6222f741c045055d43d1d5a2d4979caf6 Reviewed-on: https://code.wireshark.org/review/4163 Reviewed-by: Jörg Mayer --- CMakeLists.txt | 4 +++- ...Custom.txt => CMakeListsCustom.txt.example | 2 +- cmake/modules/UseCustomIncludes.cmake | 20 +++++++++++++++++++ epan/CMakeLists.txt | 2 +- ...ustom.txt => CMakeListsCustom.txt.example} | 0 ui/gtk/CMakeLists.txt | 2 +- ...ustom.txt => CMakeListsCustom.txt.example} | 0 7 files changed, 26 insertions(+), 4 deletions(-) rename plugins/CMakeListsCustom.txt => CMakeListsCustom.txt.example (99%) create mode 100644 cmake/modules/UseCustomIncludes.cmake rename epan/{CMakeListsCustom.txt => CMakeListsCustom.txt.example} (100%) rename ui/gtk/{CMakeListsCustom.txt => CMakeListsCustom.txt.example} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d546a05b07..712d895866 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,9 @@ cmake_policy(SET CMP0015 NEW) #Where to find local cmake scripts set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) +include(UseCustomIncludes) +ADD_CUSTOM_CMAKE_INCLUDE() + # This cannot be implemented via option(...) if( NOT CMAKE_BUILD_TYPE ) set( CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING @@ -772,7 +775,6 @@ ADD_CUSTOM_COMMAND( ) if(ENABLE_PLUGINS) - include(plugins/CMakeListsCustom.txt) set(HAVE_PLUGINS 1) set(PLUGIN_DIR "${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}") set(PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION}") diff --git a/plugins/CMakeListsCustom.txt b/CMakeListsCustom.txt.example similarity index 99% rename from plugins/CMakeListsCustom.txt rename to CMakeListsCustom.txt.example index f9cd0fbf83..92d28b6c6d 100644 --- a/plugins/CMakeListsCustom.txt +++ b/CMakeListsCustom.txt.example @@ -25,4 +25,4 @@ set(CUSTOM_PLUGIN_SRC_DIR # private_plugins/foo # or # plugins/foo -) \ No newline at end of file +) diff --git a/cmake/modules/UseCustomIncludes.cmake b/cmake/modules/UseCustomIncludes.cmake new file mode 100644 index 0000000000..15e93f7043 --- /dev/null +++ b/cmake/modules/UseCustomIncludes.cmake @@ -0,0 +1,20 @@ +# +# - Include a custom CMake file relative to the current source directory. +# - If no filename is provided, CMakeListsCustom.txt is used. +# +macro( ADD_CUSTOM_CMAKE_INCLUDE ) + if( ${ARGN} ) + set( _file_list ${ARGN} ) + else() + set( _file_list CMakeListsCustom.txt ) + endif() + foreach (_include ${_file_list}) + set( _include_file ${CMAKE_CURRENT_SOURCE_DIR}/${_include} ) + if( EXISTS ${_include_file} ) + message ( STATUS "Including ${_include_file}" ) + include( ${_include_file} ) + else() + message ( STATUS "No custom file found in ${CMAKE_CURRENT_SOURCE_DIR}" ) + endif() + endforeach() +endmacro() diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt index 657129aefa..5b7ff43c03 100644 --- a/epan/CMakeLists.txt +++ b/epan/CMakeLists.txt @@ -21,7 +21,7 @@ include(UseABICheck) -include(CMakeListsCustom.txt) +ADD_CUSTOM_CMAKE_INCLUDE() if (HAVE_HFI_SECTION_INIT) add_definitions( diff --git a/epan/CMakeListsCustom.txt b/epan/CMakeListsCustom.txt.example similarity index 100% rename from epan/CMakeListsCustom.txt rename to epan/CMakeListsCustom.txt.example diff --git a/ui/gtk/CMakeLists.txt b/ui/gtk/CMakeLists.txt index 3b5600445e..13878c7770 100644 --- a/ui/gtk/CMakeLists.txt +++ b/ui/gtk/CMakeLists.txt @@ -19,7 +19,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -include(CMakeListsCustom.txt) +ADD_CUSTOM_CMAKE_INCLUDE() set(WIRESHARK_GTK_SRC about_dlg.c diff --git a/ui/gtk/CMakeListsCustom.txt b/ui/gtk/CMakeListsCustom.txt.example similarity index 100% rename from ui/gtk/CMakeListsCustom.txt rename to ui/gtk/CMakeListsCustom.txt.example