Skip to content

Commit

Permalink
expose c interface to lucene++
Browse files Browse the repository at this point in the history
  • Loading branch information
pcmoritz committed Jul 20, 2018
1 parent b7baba5 commit 889ee48
Show file tree
Hide file tree
Showing 10 changed files with 342 additions and 3,569 deletions.
16 changes: 9 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ project(lucene++)

cmake_minimum_required(VERSION 2.8.6)

set (CMAKE_CXX_STANDARD 11)

set(lucene++_VERSION_MAJOR 3)
set(lucene++_VERSION_MINOR 0)
set(lucene++_VERSION_PATCH 7)
Expand All @@ -15,11 +17,6 @@ set(lucene++_VERSION
# include specific modules
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

####################################
# pre-compiled headers support
####################################
include(cotire)

# if setup using the Toolchain-llvm.cmake file, then use llvm...
if(ENABLE_LLVM)
include(Toolchain-llvm)
Expand Down Expand Up @@ -50,11 +47,11 @@ option(ENABLE_CYCLIC_CHECK
)
option(ENABLE_TEST
"Enable the tests"
ON
OFF
)
option(ENABLE_DEMO
"Enable building demo applications"
ON
OFF
)

####################################
Expand Down Expand Up @@ -87,6 +84,10 @@ set(lucene_boost_libs
include(Lucene++Docs)
include(TestCXXAcceptsFlag)
include(GNUInstallDirs)
include(ExternalProject)

set(PROTOBUF_HOME "/usr/local/Cellar/protobuf/3.6.0")
find_package(Protobuf REQUIRED)

set(LIB_DESTINATION
"${CMAKE_INSTALL_FULL_LIBDIR}" CACHE STRING "Define lib output directory name"
Expand Down Expand Up @@ -154,6 +155,7 @@ include_directories(

add_subdirectory(src/core)
add_subdirectory(src/contrib)
add_subdirectory(src/lib)

if(ENABLE_DEMO)
add_subdirectory(src/demo)
Expand Down
101 changes: 101 additions & 0 deletions cmake/FindProtobuf.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Licensed 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.

# PROTOBUF_HOME environmental variable is used to check for Protobuf headers and static library

# PROTOBUF_INCLUDE_DIR: directory containing headers
# PROTOBUF_LIBS: directory containing Protobuf libraries
# PROTOBUF_STATIC_LIB: location of protobuf.a
# PROTOC_STATIC_LIB: location of protoc.a
# PROTOBUF_EXECUTABLE: location of protoc
# PROTOBUF_FOUND is set if Protobuf is found


if( NOT "${PROTOBUF_HOME}" STREQUAL "")
file (TO_CMAKE_PATH "${PROTOBUF_HOME}" _protobuf_path)
endif()

message (STATUS "PROTOBUF_HOME: ${PROTOBUF_HOME}")

find_path (PROTOBUF_INCLUDE_DIR google/protobuf/io/zero_copy_stream.h HINTS
${_protobuf_path}
NO_DEFAULT_PATH
PATH_SUFFIXES "include")

find_path (PROTOBUF_INCLUDE_DIR google/protobuf/io/coded_stream.h HINTS
${_protobuf_path}
NO_DEFAULT_PATH
PATH_SUFFIXES "include")

set (lib_dirs "lib")
if (EXISTS "${_protobuf_path}/lib64")
set (lib_dirs "lib64" ${lib_dirs})
endif ()
if (EXISTS "${_protobuf_path}/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
set (lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}" ${lib_dirs})
endif ()

find_library (PROTOBUF_LIBRARY NAMES protobuf PATHS
${_protobuf_path}
NO_DEFAULT_PATH
PATH_SUFFIXES ${lib_dirs})

find_library (PROTOC_LIBRARY NAMES protoc PATHS
${_protobuf_path}
NO_DEFAULT_PATH
PATH_SUFFIXES ${lib_dirs})

find_program(PROTOBUF_EXECUTABLE protoc HINTS
${_protobuf_path}
NO_DEFAULT_PATH
PATH_SUFFIXES "bin")

if (PROTOBUF_INCLUDE_DIR AND PROTOBUF_LIBRARY AND PROTOC_LIBRARY AND PROTOBUF_EXECUTABLE)
set (PROTOBUF_FOUND TRUE)
set (PROTOBUF_SHARED_LIB ${PROTOBUF_LIBRARY})
set (PROTOC_SHARED_LIB ${PROTOC_LIBRARY})
get_filename_component (PROTOBUF_LIBS ${PROTOBUF_LIBRARY} PATH)
set (PROTOBUF_LIB_NAME protobuf)
set (PROTOC_LIB_NAME protoc)
set (PROTOBUF_STATIC_LIB ${PROTOBUF_LIBS}/${CMAKE_STATIC_LIBRARY_PREFIX}${PROTOBUF_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
set (PROTOC_STATIC_LIB ${PROTOBUF_LIBS}/${CMAKE_STATIC_LIBRARY_PREFIX}${PROTOC_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
else ()
set (PROTOBUF_FOUND FALSE)
endif ()

if (PROTOBUF_FOUND)
message (STATUS "Found the Protobuf headers: ${PROTOBUF_INCLUDE_DIR}")
message (STATUS "Found the Protobuf shared library: ${PROTOBUF_SHARED_LIB}")
message (STATUS "Found the Protobuf library: ${PROTOBUF_STATIC_LIB}")
message (STATUS "Found the Protoc shared library: ${PROTOC_SHARED_LIB}")
message (STATUS "Found the Protoc library: ${PROTOC_STATIC_LIB}")
message (STATUS "Found the Protoc executable: ${PROTOBUF_EXECUTABLE}")
else()
if (_protobuf_path)
set (PROTOBUF_ERR_MSG "Could not find Protobuf. Looked in ${_protobuf_path}.")
else ()
set (PROTOBUF_ERR_MSG "Could not find Protobuf in system search paths.")
endif()

if (Protobuf_FIND_REQUIRED)
message (FATAL_ERROR "${PROTOBUF_ERR_MSG}")
else ()
message (STATUS "${PROTOBUF_ERR_MSG}")
endif ()
endif()

mark_as_advanced (
PROTOBUF_INCLUDE_DIR
PROTOBUF_LIBS
PROTOBUF_STATIC_LIB
PROTOC_STATIC_LIB
)
Loading

0 comments on commit 889ee48

Please sign in to comment.