From 30b3652a94878ef92aa34a3acffa56d8f2af80e0 Mon Sep 17 00:00:00 2001 From: Alex Damian Date: Mon, 23 Apr 2018 21:32:43 -0400 Subject: [PATCH] auto-gen main header file (#59) --- README.md | 2 +- cppkafka.h.in | 35 ++++++++++++++++++++ include/cppkafka/CMakeLists.txt | 20 +++++++++++- include/cppkafka/cppkafka.h | 58 +++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 cppkafka.h.in create mode 100644 include/cppkafka/cppkafka.h diff --git a/README.md b/README.md index b42bb2e..5658b9b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ _cppkafka_'s API is simple to use. For example, this code creates a producer tha into some partition: ```c++ -#include +#include using namespace std; using namespace cppkafka; diff --git a/cppkafka.h.in b/cppkafka.h.in new file mode 100644 index 0000000..6c1d743 --- /dev/null +++ b/cppkafka.h.in @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017, Matias Fontanini + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef CPPKAFKA_H +#define CPPKAFKA_H + +@CPPKAFKA_HEADERS@ + +#endif diff --git a/include/cppkafka/CMakeLists.txt b/include/cppkafka/CMakeLists.txt index f4c188e..ce24250 100644 --- a/include/cppkafka/CMakeLists.txt +++ b/include/cppkafka/CMakeLists.txt @@ -1,3 +1,21 @@ +# Local function to auto-generate main cppkafka.h header file +function(make_cppkafka_header) + set(CPPKAFKA_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/cppkafka.h) + file(GLOB INCLUDE_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h" "utils/*.h") + foreach(header ${INCLUDE_HEADERS}) + if (NOT ${header} MATCHES "cppkafka.h") + SET(CPPKAFKA_HEADERS "${CPPKAFKA_HEADERS}#include \n") + endif() + endforeach() + + #create file from template + configure_file(${PROJECT_SOURCE_DIR}/cppkafka.h.in ${CPPKAFKA_HEADER}) +endfunction() + +# Run file generation function +make_cppkafka_header() + +# Install headers including the auto-generated cppkafka.h file(GLOB INCLUDE_FILES "*.h") file(GLOB UTILS_INCLUDE_FILES "utils/*.h") install( @@ -9,4 +27,4 @@ install( FILES ${UTILS_INCLUDE_FILES} DESTINATION include/cppkafka/utils/ COMPONENT Headers -) \ No newline at end of file +) diff --git a/include/cppkafka/cppkafka.h b/include/cppkafka/cppkafka.h new file mode 100644 index 0000000..5bc218c --- /dev/null +++ b/include/cppkafka/cppkafka.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017, Matias Fontanini + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef CPPKAFKA_H +#define CPPKAFKA_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif