4 Commits

3 changed files with 59 additions and 88 deletions

View File

@ -1,14 +1,15 @@
#set(Qt5Core_DIR "/opt/Qt5.6.0/5.6/gcc_64/lib/cmake/Qt5Core")
#set(Qt5Test_DIR "/opt/Qt5.6.0/5.6/gcc_64/lib/cmake/Qt5Test")
#set(Qt5_DIR "/opt/Qt5.6.0/5.6/gcc_64/lib/cmake/Qt5Core")
#set(QT_QMAKE_EXECUTABLE "/opt/Qt5.6.0/5.6/gcc_64/bin/qmake")
#set(Qt6Core_DIR "/opt/Qt6.6.0/5.6/gcc_64/lib/cmake/Qt6Core")
#set(Qt6Test_DIR "/opt/Qt6.6.0/5.6/gcc_64/lib/cmake/Qt6Test")
#set(Qt6_DIR "/opt/Qt6.6.0/5.6/gcc_64/lib/cmake/Qt6Core")
#set(QT_QMAKE_EXECUTABLE "/opt/Qt6.6.0/5.6/gcc_64/bin/qmake")
project(qmsgpack)
cmake_minimum_required(VERSION 3.1.0)
set (CMAKE_CXX_STANDARD 11)
#set (CMAKE_CXX_STANDARD 20)
set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# build type
if ("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*")
@ -22,49 +23,49 @@ endif (WIN32)
option (QT4_BUILD "BUild with Qt4")
if (NOT QT4_BUILD)
find_package(Qt5Core QUIET)
find_package(Qt6Core QUIET)
endif ()
if (Qt5Core_FOUND)
message("Qt5 found")
include_directories(${Qt5Core_INCLUDE_DIRS})
add_definitions(${Qt5Core_DEFINITIONS})
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(PC_Requires "Qt5Core")
if (Qt6Core_FOUND)
message("Qt6 found")
include_directories(${Qt6Core_INCLUDE_DIRS})
add_definitions(${Qt6Core_DEFINITIONS})
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(PC_Requires "Qt6Core")
else ()
message("Qt5 not found, searching for Qt4")
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(PC_Requires "QtCore")
message("Qt6 not found, searching for Qt4")
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(PC_Requires "QtCore")
endif ()
option (WITH_GUI_TYPES "Build with support for QtGui types")
if (WITH_GUI_TYPES)
if (QT4_BUILD)
find_package(Qt4 QTGUI)
else ()
find_package(Qt5Gui QUIET)
endif ()
if (QT4_BUILD)
find_package(Qt4 QTGUI)
else ()
find_package(Qt6Gui QUIET)
endif ()
endif ()
option (WITH_LOCATION_TYPES "Build with support for QtLocation types")
if (WITH_LOCATION_TYPES)
find_package(Qt5Location QUIET)
find_package(Qt6Location QUIET)
endif ()
if (Qt5Location_FOUND)
message("Qt5Location found")
include_directories(${Qt5Location_INCLUDE_DIRS})
add_definitions(${Qt5Location_DEFINITIONS})
if (Qt6Location_FOUND)
message("Qt6Location found")
include_directories(${Qt6Location_INCLUDE_DIRS})
add_definitions(${Qt6Location_DEFINITIONS})
else ()
message("Qt5Location not found")
message("Qt6Location not found")
endif ()
if (NOT WIN32)
@ -96,7 +97,7 @@ if (BUILD_TESTS)
add_subdirectory(tests)
endif ()
install(EXPORT qmsgpack-export DESTINATION ${CMAKECONFIG_INSTALL_DIR} FILE MsgPackQtTargets.cmake)
# install(EXPORT qmsgpack-export DESTINATION ${CMAKECONFIG_INSTALL_DIR} FILE MsgPackQtTargets.cmake)
file(RELATIVE_PATH relInstallDir ${CMAKE_INSTALL_PREFIX}/$CMAKECONFIG_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX})

View File

@ -6,17 +6,17 @@ if(NOT DEFINED COMPILE_TYPE)
set(COMPILE_TYPE SHARED)
endif(NOT DEFINED COMPILE_TYPE)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick)
add_library(qmsgpack ${COMPILE_TYPE} ${qmsgpack_srcs} ${qmsgpack_headers})
if (Qt5Core_FOUND)
target_link_libraries(qmsgpack Qt5::Core)
else ()
target_link_libraries(qmsgpack ${QT_LIBRARIES})
endif ()
target_include_directories(qmsgpack PUBLIC .)
if (Qt5Gui_FOUND)
target_link_libraries(qmsgpack Qt5::Gui)
endif ()
target_link_libraries(qmsgpack PUBLIC
Qt6::Core
Qt6::Gui
Qt6::Quick
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/msgpackcommon.h.in"
@ -24,19 +24,23 @@ configure_file(
IMMEDIATE @ONLY)
if (NOT android)
set_target_properties(qmsgpack PROPERTIES
VERSION ${QMSGPACK_MAJOR}.${QMSGPACK_MINOR}.${QMSGPACK_VERSION}
SOVERSION ${QMSGPACK_MAJOR})
set_target_properties(qmsgpack PROPERTIES
VERSION ${QMSGPACK_MAJOR}.${QMSGPACK_MINOR}.${QMSGPACK_VERSION}
SOVERSION ${QMSGPACK_MAJOR}
)
endif ()
set_target_properties(qmsgpack PROPERTIES
DEFINE_SYMBOL MSGPACK_MAKE_LIB
PUBLIC_HEADER "${qmsgpack_headers}")
DEFINE_SYMBOL MSGPACK_MAKE_LIB
PUBLIC_HEADER "${qmsgpack_headers}")
install(TARGETS qmsgpack EXPORT qmsgpack-export
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}/qmsgpack)
install(TARGETS qmsgpack)
# install(TARGETS qmsgpack EXPORT qmsgpack-export
# LIBRARY DESTINATION ${LIB_INSTALL_DIR}
# RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
# ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
# PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}/qmsgpack)
install(FILES ${qmsgpack_stream_headers} DESTINATION ${INCLUDE_INSTALL_DIR}/qmsgpack/stream)
# install(FILES ${qmsgpack_stream_headers} DESTINATION ${INCLUDE_INSTALL_DIR}/qmsgpack/stream)

View File

@ -1,34 +0,0 @@
set(qmsgpack_srcs msgpack.cpp msgpack_common.cpp stream.cpp private/pack_p.cpp private/unpack_p.cpp private/qt_types_p.cpp)
set(qmsgpack_headers msgpack.h stream.h msgpack_common.h msgpack_export.h endianhelper.h)
add_library(qmsgpack SHARED ${qmsgpack_srcs} ${qmsgpack_headers})
if (Qt5Core_FOUND)
target_link_libraries(qmsgpack Qt5::Core)
else ()
target_link_libraries(qmsgpack ${QT_LIBRARIES})
endif ()
if (Qt5Gui_FOUND)
target_link_libraries(qmsgpack Qt5::Gui)
endif ()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/msgpack_common.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/msgpack_common.h"
IMMEDIATE @ONLY)
if (NOT android)
set_target_properties(qmsgpack PROPERTIES
VERSION ${QMSGPACK_MAJOR}.${QMSGPACK_MINOR}.${QMSGPACK_VERSION}
SOVERSION ${QMSGPACK_MAJOR})
endif ()
set_target_properties(qmsgpack PROPERTIES
DEFINE_SYMBOL MSGPACK_MAKE_LIB
PUBLIC_HEADER "${qmsgpack_headers}")
install(TARGETS qmsgpack EXPORT qmsgpack-export
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}/qmsgpack)