Skip to content

Commit

Permalink
Buildfix: cpack corrected, building deps
Browse files Browse the repository at this point in the history
1. Now, by default, all dependencies for dzip are buit with the project.
2. We can produce deb or rpm packages
  • Loading branch information
hoxnox committed Jun 19, 2015
1 parent 959e900 commit 1579187
Showing 1 changed file with 82 additions and 31 deletions.
113 changes: 82 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ option(WITH_DOCS "Generate docs." OFF)
option(WITH_SHARED_LIBS "Build shared libraries." OFF)
option(WITH_STATIC_LIBS "Build static libraries." ON)
option(WITH_dzip "Build dzip compress utility" ON)
option(WITH_SYSTEM_GLOG "Use system google-log" OFF)
option(WITH_SYSTEM_ZMQ "Use system zeromq" OFF)
option(CSIO_FORCE_SHARED_CRT
"Use shared run-time lib even when csio is built as static lib." OFF)

Expand All @@ -26,7 +28,7 @@ nx_configure()

set(csio_VERSION_MAJOR 0)
set(csio_VERSION_MINOR 1)
set(csio_VERSION_PATCH 0)
set(csio_VERSION_PATCH 1)
# configuration header
set(TEST_SAMPLES_DIR "${PROJECT_SOURCE_DIR}/test/samples/")
set(TEST_TMP_DIR "/tmp")
Expand All @@ -53,13 +55,63 @@ list(APPEND LIBRARIES ${ZLIB_LIBRARIES})
# dzip

if(WITH_dzip)
set(ZMQ_USE_STATIC_LIBS true)
find_package(ZMQ REQUIRED)
set(Glog_USE_STATIC_LIBS true)
find_package(Glog REQUIRED)

####################################################################
# zmq
if (WITH_SYSTEM_ZMQ)
set(ZMQ_USE_STATIC_LIBS true)
find_package(ZMQ REQUIRED)
else()
include(ExternalProject)
set(ZMQ_ROOT "${CMAKE_CURRENT_BINARY_DIR}/zmq")
ExternalProject_Add(zmq
URL "http://download.zeromq.org/zeromq-4.1.2.tar.gz"
URL_MD5 "159c0c56a895472f02668e692d122685"
CONFIGURE_COMMAND ./configure --enable-static --disable-shared --without-libsodium --without-libgssapi_krb5 --without-documentation --prefix <INSTALL_DIR>
INSTALL_DIR "${ZMQ_ROOT}"
BUILD_IN_SOURCE 1
)
set(ZMQ_INCLUDE_DIR ${ZMQ_ROOT}/include)
set(ZMQ_LIBRARIES ${ZMQ_ROOT}/lib/libzmq.a)
list(APPEND EXTERNAL_DEPS zmq)
endif()

####################################################################
# glog
if (WITH_SYSTEM_GLOG)
set(Glog_USE_STATIC_LIBS true)
find_package(Glog REQUIRED)
else()
include(ExternalProject)
set(LIBUNWIND_ROOT "${CMAKE_CURRENT_BINARY_DIR}/libunwind")
ExternalProject_Add(libunwind
URL "http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz"
URL_MD5 "fb4ea2f6fbbe45bf032cd36e586883ce"
CONFIGURE_COMMAND ./configure --disable-minidebuginfo --enable-static --disable-shared --prefix <INSTALL_DIR>
INSTALL_DIR "${LIBUNWIND_ROOT}"
BUILD_IN_SOURCE 1
)
set(LIBUNWIND_INCLUDE_DIR ${LIBUNWIND_ROOT}/include)
set(LIBUNWIND_LIBRARIES ${LIBUNWIND_ROOT}/lib/libunwind.a)

set(Glog_ROOT "${CMAKE_CURRENT_BINARY_DIR}/glog")
ExternalProject_Add(glog
URL "https://github.com/google/glog/archive/v0.3.4.tar.gz"
URL_MD5 "df92e05c9d02504fb96674bc776a41cb"
CONFIGURE_COMMAND ./configure --enable-static --disable-shared --prefix <INSTALL_DIR>
INSTALL_DIR "${Glog_ROOT}"
BUILD_IN_SOURCE 1
)
set(Glog_INCLUDE_DIR ${Glog_ROOT}/include)
set(Glog_LIBRARIES ${Glog_ROOT}/lib/libglog.a ${LIBUNWIND_LIBRARIES})
add_dependencies(glog libunwind)
message(STATUS "Found external dependency GLOG: " ${Glog_INCLUDE_DIR})
list(APPEND EXTERNAL_DEPS glog)
endif()

include_directories(${ZMQ_INCLUDE_DIR})
include_directories(${Glog_INCLUDE_DIR})
list(APPEND LIBRARIES ${ZMQ_LIBRARIES} ${Glog_LIBRARIES} pthread rt)
list(APPEND LIBRARIES ${Glog_LIBRARIES} ${ZMQ_LIBRARIES} pthread rt)
find_package(Threads REQUIRED)
if (NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR "dzip utility needs pthreads")
Expand All @@ -80,6 +132,7 @@ if(WITH_dzip)
)
set(DZIP_SRC ./src/dzip.cpp)
add_executable(dzip ${DZIP_SRC})
add_dependencies(dzip_internal ${EXTERNAL_DEPS})
target_link_libraries(dzip dzip_internal ${LIBRARIES})
set_target_properties(dzip PROPERTIES COMPILE_FLAGS "-std=c++0x")
set_target_properties(dzip_internal PROPERTIES COMPILE_FLAGS "-std=c++0x")
Expand Down Expand Up @@ -138,31 +191,29 @@ endif()
########################################################################
# installation

set(CPACK_SET_DESTDIR ON)

install(TARGETS ${TARGETS} DESTINATION bin)
#install(FILES <files> DESTINATION <dest>)

INCLUDE(InstallRequiredSystemLibraries)

SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "csio DESC")
SET(CPACK_PACKAGE_VENDOR "ORG")
SET(CPACK_PACKAGE_DESCRIPTION_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/README.markdown")
SET(CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_PACKAGE_VERSION_MAJOR ${csio_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${csio_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${csio_VERSION_PATCH})
SET(CPACK_PACKAGE_INSTALL_DIRECTORY
"CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
IF(WIN32 AND NOT UNIX)
# NOT IMPLEMENTED
ELSE(WIN32 AND NOT UNIX)
SET(CPACK_STRIP_FILES ${TARGETS})
SET(CPACK_SOURCE_STRIP_FILES "")
ENDIF(WIN32 AND NOT UNIX)
#SET(CPACK_PACKAGE_EXECUTABLES "null" "null desc")

INSTALL(TARGETS csio DESTINATION lib)
if (WITH_dzip)
INSTALL(TARGETS dzip DESTINATION bin)
endif()
INSTALL(FILES
./include/csio.h
./include/csio_config.h
DESTINATION include)
SET(CPACK_PACKAGE_NAME "csio")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libz-dev")
SET(CPACK_RPM_PACKAGE_REQUIRES "zlib-devel")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Compressed Input Output Library")
SET(CPACK_PACKAGE_VENDOR "Merder Kim <hoxnox@gmail.com>")
SET(CPACK_PACKAGE_CONTACT ${CPACK_PACKAGE_VENDOR})
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.markdown")
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
SET(CPACK_PACKAGE_VERSION_MAJOR ${CSIO_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${CSIO_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${CSIO_VERSION_PATCH})
SET(CPACK_DEBIAN_PACKAGE_SECTION "Utilities")
SET(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
SET(CPACK_RPM_PACKAGE_LICENSE "MIT")
SET(CPACK_STRIP_FILES TRUE)
INCLUDE(CPack)

0 comments on commit 1579187

Please sign in to comment.