From d573e356eacf9481163fbe361860af6cc407ad63 Mon Sep 17 00:00:00 2001 From: Jeremy Dyer Date: Tue, 29 Nov 2016 21:09:37 -0500 Subject: [PATCH 1/2] MINIFI-139 - Resolved OS X 10.12 build failures by introducing Cmake find modules for LevelDB and UUID for both includes and libraries. --- NOTICE | 8 ++++++- cmake/FindLeveldb.cmake | 50 ++++++++++++++++++++++++++++++++++++++++ cmake/FindUUID.cmake | 37 +++++++++++++++++++++++++++++ libminifi/CMakeLists.txt | 11 +++++++++ main/CMakeLists.txt | 9 +++++--- 5 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 cmake/FindLeveldb.cmake create mode 100644 cmake/FindUUID.cmake diff --git a/NOTICE b/NOTICE index e1743a6620..3badb13194 100644 --- a/NOTICE +++ b/NOTICE @@ -2,4 +2,10 @@ Apache NiFi MiNiFi Copyright 2016 The Apache Software Foundation This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file +The Apache Software Foundation (http://www.apache.org/). + +This includes derived works from the Apache Celix (ASLv2 licensed) project (https://github.com/apache/celix): +Copyright 2015 The Apache Software Foundation +The derived work is adapted from + celix/cmake/FindUUID.cmake +and can be found in cmake/FindUUID.cmake \ No newline at end of file diff --git a/cmake/FindLeveldb.cmake b/cmake/FindLeveldb.cmake new file mode 100644 index 0000000000..73ac693a31 --- /dev/null +++ b/cmake/FindLeveldb.cmake @@ -0,0 +1,50 @@ +# 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 qrequired 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. + + +# Find module for Leveldb library and includes +# LEVELDB_FOUND - if system found LEVELDB library +# LEVELDB_INCLUDE_DIRS - The LEVELDB include directories +# LEVELDB_LIBRARIES - The libraries needed to use LEVELDB +# LEVELDB_DEFINITIONS - Compiler switches required for using LEVELDB + +# For OS X do not attempt to use the OS X application frameworks or bundles. +set (CMAKE_FIND_FRAMEWORK NEVER) +set (CMAKE_FIND_APPBUNDLE NEVER) + +find_path(LEVELDB_INCLUDE_DIR + NAMES leveldb/db.h + PATHS /usr/local/include /usr/include + DOC "LevelDB include header" +) + +find_library(LEVELDB_LIBRARY + NAMES libleveldb.dylib libleveldb.so + PATHS /usr/local/lib /usr/lib/x86_64-linux-gnu + DOC "LevelDB library" +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LEVELDB DEFAULT_MSG LEVELDB_INCLUDE_DIR LEVELDB_LIBRARY) + +if (LEVELDB_FOUND) + set(LEVELDB_LIBRARIES ${LEVELDB_LIBRARY} ) + set(LEVELDB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIR} ) + set(LEVELDB_DEFINITIONS ) +endif() + +mark_as_advanced(LEVELDB_ROOT_DIR LEVELDB_INCLUDE_DIR LEVELDB_LIBRARY) \ No newline at end of file diff --git a/cmake/FindUUID.cmake b/cmake/FindUUID.cmake new file mode 100644 index 0000000000..2402d08e50 --- /dev/null +++ b/cmake/FindUUID.cmake @@ -0,0 +1,37 @@ +# 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. + + +find_path(UUID_INCLUDE_DIR + NAMES uuid/uuid.h + HINTS ${UUID_DIR}/include + $ENV{UUID_DIR}/include + PATHS /usr/include + /usr/local/include ) + +find_library(UUID_LIBRARY NAMES uuid + PATHS /usr/lib /usr/local/lib /usr/local/lib64 /lib/i386-linux-gnu /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu) + +set(UUID_INCLUDE_DIRS ${UUID_INCLUDE_DIR}) +set(UUID_LIBRARIES ${UUID_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(UUID DEFAULT_MSG + UUID_LIBRARY UUID_INCLUDE_DIR) + + +mark_as_advanced(UUID_INCLUDE_DIRS UUID_LIBRARIES) diff --git a/libminifi/CMakeLists.txt b/libminifi/CMakeLists.txt index 2d6b84b2cd..8d6f5d14d7 100644 --- a/libminifi/CMakeLists.txt +++ b/libminifi/CMakeLists.txt @@ -39,6 +39,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include_directories(../include) include_directories(../thirdparty/yaml-cpp-yaml-cpp-0.5.3/include) include_directories(include) +include_directories(/usr/local/include) file(GLOB SOURCES "src/*.cpp") file(GLOB SPD_SOURCES "../include/spdlog/*") @@ -56,3 +57,13 @@ if (LIBXML2_FOUND) else () # Build from our local version endif (LIBXML2_FOUND) + +# Include LevelDB +find_package (Leveldb REQUIRED) +if (LEVELDB_FOUND) + include_directories(${LEVELDB_INCLUDE_DIRS}) + target_link_libraries (minifi ${LEVELDB_LIBRARIES}) +else () + message( FATAL_ERROR "LevelDB was not found. Please install LevelDB" ) +endif (LEVELDB_FOUND) + diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 0f66cdae3f..5542b6325d 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -23,7 +23,7 @@ IF(POLICY CMP0048) CMAKE_POLICY(SET CMP0048 OLD) ENDIF(POLICY CMP0048) -include_directories(../include ../libminifi/include ../thirdparty/yaml-cpp-yaml-cpp-0.5.3/include ../thirdparty/leveldb-1.18/include ../thirdparty/) +include_directories(../include ../libminifi/include ../thirdparty/yaml-cpp-yaml-cpp-0.5.3/include ../thirdparty/leveldb-1.18/include ../thirdparty/ /usr/local/include) # Include libxml2 find_package(LibXml2) @@ -41,8 +41,11 @@ if(CMAKE_THREAD_LIBS_INIT) target_link_libraries(minifiexe "${CMAKE_THREAD_LIBS_INIT}") endif() -# Link against minifi, yaml-cpp and uuid -target_link_libraries(minifiexe minifi yaml-cpp uuid leveldb) +# Include UUID +find_package(UUID REQUIRED) + +# Link against minifi, yaml-cpp, uuid, and leveldb +target_link_libraries(minifiexe minifi yaml-cpp ${UUID_LIBRARIES} ${LEVELDB_LIBRARIES}) set_target_properties(minifiexe PROPERTIES OUTPUT_NAME minifi) From 746a9d6c4a2f5c90ab34e16130a243dd79ac0a4a Mon Sep 17 00:00:00 2001 From: Jeremy Dyer Date: Mon, 5 Dec 2016 14:54:26 -0500 Subject: [PATCH 2/2] MINIFI-139: Removed hardcoded /usr/local/include references in favor of find_package(Boost REQUIRED) approach --- libminifi/CMakeLists.txt | 1 - main/CMakeLists.txt | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libminifi/CMakeLists.txt b/libminifi/CMakeLists.txt index 8d6f5d14d7..7c36799b84 100644 --- a/libminifi/CMakeLists.txt +++ b/libminifi/CMakeLists.txt @@ -39,7 +39,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include_directories(../include) include_directories(../thirdparty/yaml-cpp-yaml-cpp-0.5.3/include) include_directories(include) -include_directories(/usr/local/include) file(GLOB SOURCES "src/*.cpp") file(GLOB SPD_SOURCES "../include/spdlog/*") diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 5542b6325d..3e0bbc441f 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -23,7 +23,10 @@ IF(POLICY CMP0048) CMAKE_POLICY(SET CMP0048 OLD) ENDIF(POLICY CMP0048) -include_directories(../include ../libminifi/include ../thirdparty/yaml-cpp-yaml-cpp-0.5.3/include ../thirdparty/leveldb-1.18/include ../thirdparty/ /usr/local/include) +include_directories(../include ../libminifi/include ../thirdparty/yaml-cpp-yaml-cpp-0.5.3/include ../thirdparty/leveldb-1.18/include ../thirdparty/) + +find_package(Boost REQUIRED) +include_directories(${Boost_INCLUDE_DIRS}) # Include libxml2 find_package(LibXml2)