Skip to content

Commit

Permalink
Merge pull request #10 from tarantool/fix-cmake
Browse files Browse the repository at this point in the history
Static build: Do not make install into system directories
  • Loading branch information
RepentantGopher authored Jun 6, 2019
2 parents be20dc8 + 81fb4ba commit 2428e81
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.idea
.rocks
tests/venv
tests/.pytest_cache
tests/__*
cmake-build-debug
cmake-build-debug
build.luarocks/
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(kafka C)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)

# Set CFLAGS
set(MY_C_FLAGS "-Wall -Wextra -Werror -std=gnu11 -fno-strict-aliasing -Wno-deprecated-declarations")
Expand All @@ -18,8 +19,21 @@ if(${tntver} VERSION_LESS 1.7.4.291)
endif()

if("${STATIC_BUILD}" STREQUAL "ON" OR "$ENV{STATIC_BUILD}" STREQUAL "ON")
include(buildRdKafka)
buildrdkafka()
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/librdkafka/lib/librdkafka.a
COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/librdkafka
COMMAND make -j
COMMAND make install
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/librdkafka
COMMENT "Building librdkafka"
VERBATIM
)
add_custom_target(librdkafka.a ALL
DEPENDS ${CMAKE_BINARY_DIR}/librdkafka/lib/librdkafka.a
)

set(RDKAFKA_LIBRARY ${CMAKE_BINARY_DIR}/librdkafka/lib/librdkafka.a)
set(RDKAFKA_INCLUDE_DIR ${CMAKE_BINARY_DIR}/librdkafka/include)
else()
set(RDKAFKA_FIND_REQUIRED ON)
find_package(RdKafka)
Expand Down
10 changes: 0 additions & 10 deletions cmake/buildRdKafka.cmake

This file was deleted.

11 changes: 3 additions & 8 deletions kafka/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include_directories(${CMAKE_SOURCE_DIR}/kafka)
include_directories(${RDKAFKA_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

add_library(tntkafka SHARED tnt_kafka.c callbacks.c consumer.c consumer_msg.c producer.c queue.c common.c)

Expand All @@ -9,13 +10,7 @@ endif(APPLE)

target_link_libraries(tntkafka pthread)

if("${STATIC_BUILD}" STREQUAL "ON" OR "$ENV{STATIC_BUILD}" STREQUAL "ON")
add_dependencies(tntkafka rdkafka)
target_link_libraries(tntkafka ${CMAKE_SOURCE_DIR}/librdkafka/src/librdkafka.a)
else()
target_link_libraries(tntkafka ${RDKAFKA_LIBRARY})
endif()

target_link_libraries(tntkafka ${RDKAFKA_LIBRARY})
set_target_properties(tntkafka PROPERTIES PREFIX "" OUTPUT_NAME "tntkafka")

install(TARGETS tntkafka LIBRARY DESTINATION ${TARANTOOL_INSTALL_LIBDIR}/kafka)
Expand Down

0 comments on commit 2428e81

Please sign in to comment.