Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ include(CheckCXXCompilerFlag)

project(msgpack2json)

# compat with cmake > 3.0, this should be autodetected with the git command (tag) or a released file
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 3)
set(PROJECT_VERSION_PATCH 1)
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")

set(CONTRIB_DIR ${CMAKE_BINARY_DIR}/contrib)
file(MAKE_DIRECTORY ${CONTRIB_DIR})

Expand Down Expand Up @@ -54,6 +60,11 @@ endif()
set(MPACK_FILE "mpack-amalgamation-${MPACK_VERSION}.tar.gz")
set(MPACK_DIR "${CONTRIB_DIR}/mpack-amalgamation-${MPACK_VERSION}")

file(DOWNLOAD
"https://github.com/ludocode/mpack/releases/download/v${MPACK_VERSION}/${MPACK_FILE}"
"${CMAKE_SOURCE_DIR}/contrib/${MPACK_FILE}"
)

if(NOT EXISTS "${CMAKE_SOURCE_DIR}/contrib/${MPACK_FILE}")
message(FATAL_ERROR "\nMPack source is missing: contrib/${MPACK_FILE}\nTo build from the repository, you need to fetch dependencies with tools/fetch.sh")
endif()
Expand All @@ -72,6 +83,11 @@ include_directories(SYSTEM ${CMAKE_BINARY_DIR} ${MPACK_DIR}/src)
set(RAPIDJSON_FILE "rapidjson-${RAPIDJSON_COMMIT}.tar.gz")
set(RAPIDJSON_DIR "${CONTRIB_DIR}/rapidjson-${RAPIDJSON_COMMIT}")

file(DOWNLOAD
"https://github.com/miloyip/rapidjson/archive/${RAPIDJSON_COMMIT}.tar.gz"
"${CMAKE_SOURCE_DIR}/contrib/${RAPIDJSON_FILE}"
)

if(NOT EXISTS "${CMAKE_SOURCE_DIR}/contrib/${RAPIDJSON_FILE}")
message(FATAL_ERROR "\nRapidJSON source is missing: contrib/${RAPIDJSON_FILE}\nTo build from the repository, you need to fetch dependencies with tools/fetch.sh")
endif()
Expand All @@ -86,6 +102,11 @@ include_directories(SYSTEM ${RAPIDJSON_DIR}/include)
set(LIBB64_FILE "libb64-${LIBB64_VERSION}.zip")
set(LIBB64_DIR "${CONTRIB_DIR}/libb64-${LIBB64_VERSION}")

file(DOWNLOAD
"http://downloads.sourceforge.net/project/libb64/libb64/libb64/${LIBB64_FILE}?use_mirror=autoselect"
"${CMAKE_SOURCE_DIR}/contrib/${LIBB64_FILE}"
)

if(NOT EXISTS "${CMAKE_SOURCE_DIR}/contrib/${LIBB64_FILE}")
message(FATAL_ERROR "\nlibb64 source is missing: contrib/${LIBB64_FILE}\nTo build from the repository, you need to fetch dependencies with tools/fetch.sh")
endif()
Expand All @@ -109,14 +130,18 @@ add_executable(json2msgpack src/json2msgpack.cpp ${MPACK_SRCS} ${LIBB64_SRCS})

install(TARGETS msgpack2json json2msgpack DESTINATION bin)

install(FILES ${CMAKE_SOURCE_DIR}/docs/msgpack2json.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1)
install(FILES ${CMAKE_SOURCE_DIR}/docs/json2msgpack.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1)
# Man pages

if(NOT EXISTS "${CMAKE_SOURCE_DIR}/docs/msgpack2json.1")
message(FATAL_ERROR "\nmsgpack2json man page is missing: docs/msgpack2json.1\nTo build from the repository, you need to generate manpages with tools/man.sh")
message(WARNING "\nmsgpack2json man page is missing: docs/msgpack2json.1\nTo build from the repository, you need to generate manpages with tools/man.sh")
else()
install(FILES ${CMAKE_SOURCE_DIR}/docs/msgpack2json.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1)
endif()

if(NOT EXISTS "${CMAKE_SOURCE_DIR}/docs/json2msgpack.1")
message(FATAL_ERROR "\njson2msgpack man page is missing: docs/json2msgpack.1\nTo build from the repository, you need to generate manpages with tools/man.sh")
message(WARNING "\njson2msgpack man page is missing: docs/json2msgpack.1\nTo build from the repository, you need to generate manpages with tools/man.sh")
else()
install(FILES ${CMAKE_SOURCE_DIR}/docs/json2msgpack.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1)
endif()


Expand Down Expand Up @@ -153,3 +178,7 @@ add_test("json2msgpack-base64-mixed-bin" ${COMPARE} ${TESTS_DIR}/base64-bin

#add_test("json2msgpack-base64-bin" ${COMPARE_SCRIPT} ${TESTS_DIR}/base64-bin.mp valgrind ./json2msgpack -bi ${TESTS_DIR}/base64-prefix.json)
#add_test("json2msgpack-base64-bin-lax" ${COMPARE_SCRIPT} ${TESTS_DIR}/base64-bin.mp valgrind ./json2msgpack -lbi ${TESTS_DIR}/base64-prefix-lax.json)

include(cmake/OSDetection.txt)
include(cmake/CPackConfig.txt)
include(CPack)
39 changes: 39 additions & 0 deletions cmake/CPackConfig.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
set(CPACK_STRIP_FILES True)
set(CPACK_CMAKE_GENERATOR "Unix Makefiles")
if(${CMAKE_SYSTEM_VARIANT} STREQUAL "Debian")
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "msgpack-tools")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
string(TOLOWER "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}" CPACK_SYSTEM_NAME)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}-${CPACK_SYSTEM_NAME}" )
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ludocode/msgpack-tools")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Jerry Jacobs")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Command-line tools for converting between MessagePack and JSON")
endif()
#SET(CPACK_GENERATOR "STGZ;TGZ;TZ")
#SET(CPACK_INSTALL_CMAKE_PROJECTS "/home/andy/vtk/CMake-bin;CMake;ALL;/")
#SET(CPACK_NSIS_DISPLAY_NAME "CMake 2.5")
#SET(CPACK_OUTPUT_CONFIG_FILE "/home/andy/vtk/CMake-bin/CPackConfig.cmake")
#SET(CPACK_PACKAGE_DESCRIPTION_FILE "/home/andy/vtk/CMake/Copyright.txt")
#SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CMake is a build tool")
#SET(CPACK_PACKAGE_EXECUTABLES "ccmake;CMake")
#SET(CPACK_PACKAGE_FILE_NAME "cmake-2.5.0-Linux-i686")
#SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake 2.5")
#SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "CMake 2.5.0")
#SET(CPACK_PACKAGE_NAME "CMake")
#SET(CPACK_PACKAGE_VENDOR "Kitware")
#SET(CPACK_PACKAGE_VERSION "2.5.0")
#SET(CPACK_PACKAGE_VERSION_MAJOR "2")
#SET(CPACK_PACKAGE_VERSION_MINOR "5")
#SET(CPACK_PACKAGE_VERSION_PATCH "0")
#SET(CPACK_RESOURCE_FILE_LICENSE "/home/andy/vtk/CMake/Copyright.txt")
#SET(CPACK_RESOURCE_FILE_README "/home/andy/vtk/CMake/Templates/CPack.GenericDescription.txt")
#SET(CPACK_RESOURCE_FILE_WELCOME "/home/andy/vtk/CMake/Templates/CPack.GenericWelcome.txt")
#SET(CPACK_SOURCE_GENERATOR "TGZ;TZ")
#SET(CPACK_SOURCE_OUTPUT_CONFIG_FILE "/home/andy/vtk/CMake-bin/CPackSourceConfig.cmake")
#SET(CPACK_SOURCE_PACKAGE_FILE_NAME "cmake-2.5.0")
#SET(CPACK_SOURCE_STRIP_FILES "")
#SET(CPACK_STRIP_FILES "bin/ccmake;bin/cmake;bin/cpack;bin/ctest")
#SET(CPACK_SYSTEM_NAME "Linux-i686")
#SET(CPACK_TOPLEVEL_TAG "Linux-i686")
6 changes: 6 additions & 0 deletions cmake/OSDetection.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if(EXISTS "/etc/debian_version")
message(STATUS "Debian-based Linux OS detected")
set(CMAKE_SYSTEM_VARIANT "Debian")
endif()
endif()