Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use FetchContent module for msgpack #1040

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.*
build/
src/gui/runtime/doc/tags
third-party/msgpack*
compile_commands.json
!.github
11 changes: 3 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
cmake_minimum_required(VERSION 2.8.12)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif (POLICY CMP0069)
cmake_minimum_required(VERSION 3.16)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0069 NEW)

# Neovim-Qt Version, used by --version update before release
# 9999 = Development Pre-Release
Expand Down Expand Up @@ -155,7 +151,6 @@ if(USE_SYSTEM_MSGPACK)
else()
add_subdirectory(third-party)
endif()
include_directories(${MSGPACK_INCLUDE_DIRS})

if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DQT_NO_DEBUG_OUTPUT)
Expand Down
17 changes: 0 additions & 17 deletions cmake/FindMsgpack.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ if(WIN32)
endif()

add_library(neovim-qt STATIC ${NEOVIM_QT_SOURCES})
target_link_libraries(neovim-qt Qt5::Network ${MSGPACK_LIBRARIES})
target_link_libraries(neovim-qt Qt5::Network msgpackc-static)

add_subdirectory(gui)
2 changes: 1 addition & 1 deletion src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ add_executable(nvim-qt WIN32 MACOSX_BUNDLE main.cpp
${RES_FILE}
${ICON_PATH})

target_link_libraries(nvim-qt ${QTLIBS} ${MSGPACK_LIBRARIES} neovim-qt-gui)
target_link_libraries(nvim-qt ${QTLIBS} neovim-qt-gui)

if(APPLE)
add_custom_command(TARGET nvim-qt COMMAND ${CMAKE_COMMAND} -E copy_directory
Expand Down
7 changes: 3 additions & 4 deletions src/gui/shellwidget/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
cmake_minimum_required(VERSION 2.8.12)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)
cmake_minimum_required(VERSION 3.16)
cmake_policy(SET CMP0048 NEW)

project(qshellwidget)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
Expand Down
49 changes: 22 additions & 27 deletions third-party/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
# This is a minimal CMake project to fetch and build third party
# dependencies
cmake_minimum_required(VERSION 2.8.12)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)
cmake_minimum_required(VERSION 3.16)

cmake_policy(SET CMP0048 NEW)
if (POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()

project(neovim-qt-deps)

#
# Get Msgpack
#
include(FetchContent)

set(MSGPACK_VERSION 3.2.0)
set(MSGPACK_URL https://github.com/msgpack/msgpack-c/archive/cpp-${MSGPACK_VERSION}.tar.gz)
set(MSGPACK_SHA256 ff865a36bad5c72b8e7ebc4b7cf5f27a820fce4faff9c571c1791e3728355a39)

message(STATUS "Downloading Msgpack...")
set(MSGPACK_TARBALL msgpack-${MSGPACK_VERSION}.tar.gz)
file(DOWNLOAD ${MSGPACK_URL} ${CMAKE_CURRENT_SOURCE_DIR}/${MSGPACK_TARBALL}
INACTIVITY_TIMEOUT 30
EXPECTED_HASH SHA256=${MSGPACK_SHA256})
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz ${MSGPACK_TARBALL}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE rv)
if(NOT rv EQUAL 0)
message(FATAL_ERROR "Failed to extract ${MSGPACK_TARBALL}")
endif()
FetchContent_Declare(
msgpackc
URL "https://github.com/msgpack/msgpack-c/archive/cpp-${MSGPACK_VERSION}.tar.gz"
URL_HASH SHA256=ff865a36bad5c72b8e7ebc4b7cf5f27a820fce4faff9c571c1791e3728355a39
)


set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
set(MSGPACK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/msgpack-c-cpp-${MSGPACK_VERSION}/)
add_subdirectory(${MSGPACK_SOURCE_DIR} EXCLUDE_FROM_ALL)
FetchContent_GetProperties(msgpackc)
if(NOT msgpackc_POPULATED)
FetchContent_Populate(msgpackc)

# Similar enough to FindMsgpack
set(MSGPACK_INCLUDE_DIRS ${MSGPACK_SOURCE_DIR}/include PARENT_SCOPE)
set(MSGPACK_LIBRARIES msgpackc-static PARENT_SCOPE)
set(MSGPACK_BUILD_EXAMPLES OFF)

add_subdirectory(${msgpackc_SOURCE_DIR} ${msgpackc_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()