Skip to content

Commit

Permalink
Added TokyoCabinet to CMake build
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremytregunna committed May 10, 2010
1 parent 8c71756 commit a2d0718
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/CMakeLists.txt
Expand Up @@ -103,7 +103,7 @@ add_subdirectory(SystemCall)
#add_subdirectory(TagLib)
#add_subdirectory(Theora)
#add_subdirectory(Thread)
#add_subdirectory(TokyoCabinet)
add_subdirectory(TokyoCabinet)
add_subdirectory(Twitter)
add_subdirectory(UUID)
add_subdirectory(User)
Expand Down
42 changes: 42 additions & 0 deletions addons/TokyoCabinet/CMakeLists.txt
@@ -0,0 +1,42 @@
# Base Io build system
# Written by Jeremy Tregunna <jeremy.tregunna@me.com>
#
# Builds the TokyoCabinet addon

# Find tokyo-cabinet
find_package(TokyoCabinet)

# Create the _build bundle hierarchy if needed.
make_build_bundle(_build)

# Did we find tokyo-cabinet? if so, set up the targets and all the support
# variables.
if(TOKYOCABINET_FOUND)
# Output our dynamic library to the top-level _build hierarchy
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/_build/dll)

# Additional include directories
include_directories(${TOKYOCABINET_INCLUDE_DIR})

# Generate the IoTokyoCabinetInit.c file.
# Argument SHOULD ALWAYS be the exact name of the addon, case is
# important.
generate_ioinit(TokyoCabinet)

# Our library sources.
set(SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/source/IoTokyoCabinet.c"
"${CMAKE_CURRENT_SOURCE_DIR}/source/IoTokyoCabinetCursor.c"
"${CMAKE_CURRENT_SOURCE_DIR}/source/IoTokyoCabinetPrefixCursor.c"
"${CMAKE_CURRENT_SOURCE_DIR}/source/IoTokyoCabinetInit.c"
)

# Now build the shared library
add_library(IoTokyoCabinet SHARED ${SRCS})
add_dependencies(IoTokyoCabinet iovmall)
target_link_libraries(IoTokyoCabinet iovmall ${TOKYOCABINET_LIBRARY})

# Install the addon to our global addons hierarchy.
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/io/addons)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_build DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/io/addons/TokyoCabinet)
endif(TOKYOCABINET_FOUND)
23 changes: 23 additions & 0 deletions modules/FindTokyoCabinet.cmake
@@ -0,0 +1,23 @@
# Base Io build system
# Written by Jeremy Tregunna <jeremy.tregunna@me.com>
#
# Find libtokyocabinet.

FIND_PATH(TOKYOCABINET_INCLUDE_DIR tcutil.h tcbdb.h)

SET(TOKYOCABINET_NAMES ${TOKYOCABINET_NAMES} tokyocabinet libtokyocabinet)
FIND_LIBRARY(TOKYOCABINET_LIBRARY NAMES ${TOKYOCABINET_NAMES} PATH)

IF(TOKYOCABINET_INCLUDE_DIR AND TOKYOCABINET_LIBRARY)
SET(TOKYOCABINET_FOUND TRUE)
ENDIF(TOKYOCABINET_INCLUDE_DIR AND TOKYOCABINET_LIBRARY)

IF(TOKYOCABINET_FOUND)
IF(NOT TokyoCabinet_FIND_QUIETLY)
MESSAGE(STATUS "Found TokyoCabinet: ${TOKYOCABINET_LIBRARY}")
ENDIF (NOT TokyoCabinet_FIND_QUIETLY)
ELSE(TOKYOCABINET_FOUND)
IF(TokyoCabinet_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find tokyocabinet")
ENDIF(TokyoCabinet_FIND_REQUIRED)
ENDIF (TOKYOCABINET_FOUND)

0 comments on commit a2d0718

Please sign in to comment.