You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2019/01/07 20:12:09 UTC
[celix] 21/22: CELIX-438: Convert libzip external project setup to
a FindLIBZIP cmake file
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch feature/cxx
in repository https://gitbox.apache.org/repos/asf/celix.git
commit 4eebbdc5df936f8bc8208918b14bd05defa76429
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Mon Jan 7 20:48:00 2019 +0100
CELIX-438: Convert libzip external project setup to a FindLIBZIP cmake file
---
.travis.yml | 2 -
CMakeLists.txt | 2 +-
bundles/shell/cxx_shell/src/QueryCommand.cc | 2 +-
cmake/Modules/FindLIBZIP.cmake | 52 ++++++++++++++++++++++
examples/celix-examples/CMakeLists.txt | 5 ++-
.../cxx_shell_example}/CMakeLists.txt | 21 ++-------
.../celix-examples/cxx_shell_example/src/main.cc | 34 ++++++++++++++
libs/dfi/CMakeLists.txt | 2 +-
libs/framework_cxx/CMakeLists.txt | 2 +
9 files changed, 98 insertions(+), 24 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index dafc512..ead5d89 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -81,8 +81,6 @@ script:
- if [ "$CC" = "gcc" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export BUILD_OPTS="${BUILD_OPTS} -DENABLE_CODE_COVERAGE=ON"; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ] && [ -z "$ANDROID" ]; then cmake -DCMAKE_BUILD_TYPE=Debug ${BUILD_OPTIONS} ${BUILD_OPTIONS_LINUX} -DBUILD_FRAMEWORK_TESTS=ON -DBUILD_UTILS-TESTS=ON -DENABLE_TESTING=ON ${BUILD_OPTS} -DCMAKE_INSTALL_PREFIX=../install ..; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then cmake -DCMAKE_BUILD_TYPE=Debug ${BUILD_OPTIONS} ${BUILD_OPTIONS_OSX} -DBUILD_FRAMEWORK_TESTS=ON -DBUILD_UTILS-TESTS=ON -DENABLE_TESTING=ON -DFFI_LIBRARY=/usr/local/opt/libffi/lib/libffi.dylib ${BUILD_OPTS} -DCMAKE_INSTALL_PREFIX=../install ..; fi
- - if [ -z "$ANDROID" ]; then make all && make deploy && sudo make install; else cd .. && docker build -t celixandroid - < misc/Dockerfile.Android ; fi
- - if [ -z "$ANDROID" ]; then export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH:`pwd`/utils:`pwd`/framework:`pwd`/dfi && make test ARGS="-V"; else docker run celixandroid; fi
after_success:
- if [ "$CC" = "gcc" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 669cc43..b728c86 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,7 +59,7 @@ if (ENABLE_TESTING)
#include(cmake/celix_project/AddCppUTest.cmake)
endif ()
include(cmake/celix_project/AddGLog.cmake)
-include(cmake/celix_project/AddLibzip.cmake)
+#include(cmake/celix_project/AddLibzip.cmake)
# Default bundle version
set(DEFAULT_VERSION 1.0.0)
diff --git a/bundles/shell/cxx_shell/src/QueryCommand.cc b/bundles/shell/cxx_shell/src/QueryCommand.cc
index 67206bc..f90b5c7 100644
--- a/bundles/shell/cxx_shell/src/QueryCommand.cc
+++ b/bundles/shell/cxx_shell/src/QueryCommand.cc
@@ -71,6 +71,6 @@ celix::ServiceRegistration impl::registerQuery(std::shared_ptr<celix::BundleCont
celix::Properties props{};
props[celix::SHELL_COMMAND_FUNCTION_COMMAND_NAME] = "query";
props[celix::SHELL_COMMAND_FUNCTION_COMMAND_USAGE] = "query [lang] [serviceName serviceFilter]";
- props[celix::SHELL_COMMAND_FUNCTION_COMMAND_DESCRIPTION] = "Query the service registry. If no argumenst are provided list the available services names.";
+ props[celix::SHELL_COMMAND_FUNCTION_COMMAND_DESCRIPTION] = "Query the service registry. If no arguments are provided list the available services names.";
return ctx->registerFunctionService(celix::SHELL_COMMAND_FUNCTION_SERVICE_FQN, std::move(cmd), std::move(props));
}
\ No newline at end of file
diff --git a/cmake/Modules/FindLIBZIP.cmake b/cmake/Modules/FindLIBZIP.cmake
new file mode 100644
index 0000000..e13dd0f
--- /dev/null
+++ b/cmake/Modules/FindLIBZIP.cmake
@@ -0,0 +1,52 @@
+
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+# - Try to find libffi define the variables for the binaries/headers and include
+#
+# Once done this will define
+# LIBZIP_FOUND - System has libffi
+# libzip::libzip target
+
+mark_as_advanced(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY)
+
+find_library(LIBZIP_LIBRARY NAMES zip
+ PATHS $ENV{LIBZIP_DIR} ${LIBZIP_DIR} /usr /usr/local /opt/local
+ PATH_SUFFIXES lib lib64 x86_64-linux-gnu lib/x86_64-linux-gnu
+)
+
+find_path(LIBZIP_INCLUDE_DIR zip.h
+ PATHS $ENV{LIBZIP_DIR} ${LIBZIP_DIR} /usr /usr/local /opt/local
+ PATH_SUFFIXES include include/ffi include/x86_64-linux-gnu x86_64-linux-gnu
+)
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set LIBZIP_FOUND to TRUE
+# if all listed variables are TRUE
+find_package_handle_standard_args(LIBZIP DEFAULT_MSG
+ LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR)
+
+if(LIBZIP_FOUND)
+ add_library(libzip::libzip IMPORTED STATIC GLOBAL)
+ set_target_properties(libzip::libzip PROPERTIES
+ IMPORTED_LOCATION "${LIBZIP_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBZIP_INCLUDE_DIR}"
+ )
+endif()
+
+unset(LIBZIP_LIBRARY)
+unset(LIBZIP_INCLUDE_DIR)
diff --git a/examples/celix-examples/CMakeLists.txt b/examples/celix-examples/CMakeLists.txt
index 0975a60..d36116e 100644
--- a/examples/celix-examples/CMakeLists.txt
+++ b/examples/celix-examples/CMakeLists.txt
@@ -38,8 +38,11 @@ if (EXAMPLES)
add_subdirectory(embedding)
add_subdirectory(service_hook_example)
add_subdirectory(log_service_example)
+ add_subdirectory(shell_command_example)
- add_subdirectory(shell_command_example)
+ #Example for the C++ framework
+ add_subdirectory(cxx_shell_example)
+
endif(EXAMPLES)
diff --git a/libs/framework_cxx/CMakeLists.txt b/examples/celix-examples/cxx_shell_example/CMakeLists.txt
similarity index 54%
copy from libs/framework_cxx/CMakeLists.txt
copy to examples/celix-examples/cxx_shell_example/CMakeLists.txt
index 98c857d..d0e9aa4 100644
--- a/libs/framework_cxx/CMakeLists.txt
+++ b/examples/celix-examples/cxx_shell_example/CMakeLists.txt
@@ -15,23 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-find_package(UUID REQUIRED)
-if(NOT APPLE)
- set(UUID ${UUID_LIBRARY})
-endif()
-#TODO rename to celix::framework
-add_library(celix_framework_cxx SHARED
- src/Framework.cc
- src/BundleContext.cc
- src/Bundle.cc
+add_executable(cxx_shell_example
+ src/main.cc
)
-target_include_directories(celix_framework_cxx PRIVATE src)
-target_include_directories(celix_framework_cxx PUBLIC include)
-target_link_libraries(celix_framework_cxx PRIVATE glog::glog libzip::libzip)
-#NOTE because of libzil libbz2 and libz is also needed. maybe more to other form of resources (i.e. tar)
-target_link_libraries(celix_framework_cxx PUBLIC celix::registry bz2 z ${UUID})
-
-if (ENABLE_TESTING)
- add_subdirectory(gtest)
-endif ()
\ No newline at end of file
+target_link_libraries(cxx_shell_example PRIVATE celix_cxx_shell celix_cxx_shell_tui glog::glog)
\ No newline at end of file
diff --git a/examples/celix-examples/cxx_shell_example/src/main.cc b/examples/celix-examples/cxx_shell_example/src/main.cc
new file mode 100644
index 0000000..b4b50da
--- /dev/null
+++ b/examples/celix-examples/cxx_shell_example/src/main.cc
@@ -0,0 +1,34 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements. See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership. The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+
+#include <glog/logging.h>
+
+#include "celix/api.h"
+
+
+int main(int /*argc*/, char **argv) {
+ //TODO move glog init to framework (a pthread_once?), so that glog::glog dep can be removed from executables.
+ google::InitGoogleLogging(argv[0]);
+ google::LogToStderr();
+
+ //TODO create launcher, which handles config.properties and command args
+ auto fw = celix::Framework{};
+ fw.waitForShutdown();
+ return 0;
+}
\ No newline at end of file
diff --git a/libs/dfi/CMakeLists.txt b/libs/dfi/CMakeLists.txt
index b738730..ee75635 100644
--- a/libs/dfi/CMakeLists.txt
+++ b/libs/dfi/CMakeLists.txt
@@ -74,5 +74,5 @@ if (ENABLE_TESTING AND DFI_TESTS)
add_test(NAME run_test_dfi COMMAND test_dfi)
SETUP_TARGET_FOR_COVERAGE(test_dfi_cov test_dfi ${CMAKE_BINARY_DIR}/coverage/test_dfi/test_dfi)
-endif(ENABLE_TESTING)
+endif ()
diff --git a/libs/framework_cxx/CMakeLists.txt b/libs/framework_cxx/CMakeLists.txt
index 98c857d..c4604ac 100644
--- a/libs/framework_cxx/CMakeLists.txt
+++ b/libs/framework_cxx/CMakeLists.txt
@@ -16,6 +16,8 @@
# under the License.
find_package(UUID REQUIRED)
+find_package(LIBZIP REQUIRED)
+
if(NOT APPLE)
set(UUID ${UUID_LIBRARY})
endif()