Skip to content

Commit 65c9423

Browse files
committed
Use FetchContent for msgpack
Using fetch content cmake module is less verbose, than custom download and extract logic with setting of additional variables. CMake version 3.16 is in the Ubuntu 20.04 repository, so everyone should have at least it by now.
1 parent 2b7ef36 commit 65c9423

File tree

7 files changed

+24
-59
lines changed

7 files changed

+24
-59
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.*
22
build/
33
src/gui/runtime/doc/tags
4-
third-party/msgpack*
54
compile_commands.json
65
!.github

CMakeLists.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
cmake_minimum_required(VERSION 2.8.12)
2-
if (POLICY CMP0048)
3-
cmake_policy(SET CMP0048 NEW)
4-
endif (POLICY CMP0048)
5-
if (POLICY CMP0069)
6-
cmake_policy(SET CMP0069 NEW)
7-
endif (POLICY CMP0069)
1+
cmake_minimum_required(VERSION 3.16)
2+
cmake_policy(SET CMP0048 NEW)
3+
cmake_policy(SET CMP0069 NEW)
84

95
# Neovim-Qt Version, used by --version update before release
106
# 9999 = Development Pre-Release
@@ -155,7 +151,6 @@ if(USE_SYSTEM_MSGPACK)
155151
else()
156152
add_subdirectory(third-party)
157153
endif()
158-
include_directories(${MSGPACK_INCLUDE_DIRS})
159154

160155
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
161156
add_definitions(-DQT_NO_DEBUG_OUTPUT)

cmake/FindMsgpack.cmake

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ if(WIN32)
2222
endif()
2323

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

2727
add_subdirectory(gui)

src/gui/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ add_executable(nvim-qt WIN32 MACOSX_BUNDLE main.cpp
6767
${RES_FILE}
6868
${ICON_PATH})
6969

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

7272
if(APPLE)
7373
add_custom_command(TARGET nvim-qt COMMAND ${CMAKE_COMMAND} -E copy_directory

src/gui/shellwidget/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
cmake_minimum_required(VERSION 2.8.12)
2-
if (POLICY CMP0048)
3-
cmake_policy(SET CMP0048 NEW)
4-
endif (POLICY CMP0048)
1+
cmake_minimum_required(VERSION 3.16)
2+
cmake_policy(SET CMP0048 NEW)
3+
54
project(qshellwidget)
65

76
set(CMAKE_INCLUDE_CURRENT_DIR ON)

third-party/CMakeLists.txt

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,23 @@
11
# This is a minimal CMake project to fetch and build third party
22
# dependencies
3-
cmake_minimum_required(VERSION 2.8.12)
4-
if (POLICY CMP0048)
5-
cmake_policy(SET CMP0048 NEW)
6-
endif (POLICY CMP0048)
3+
cmake_minimum_required(VERSION 3.16)
4+
5+
cmake_policy(SET CMP0048 NEW)
6+
if (POLICY CMP0135)
7+
cmake_policy(SET CMP0135 NEW)
8+
endif()
9+
710
project(neovim-qt-deps)
811

9-
#
10-
# Get Msgpack
11-
#
12-
set(MSGPACK_VERSION 3.2.0)
13-
set(MSGPACK_URL https://github.com/msgpack/msgpack-c/archive/cpp-${MSGPACK_VERSION}.tar.gz)
14-
set(MSGPACK_SHA256 ff865a36bad5c72b8e7ebc4b7cf5f27a820fce4faff9c571c1791e3728355a39)
12+
include(FetchContent)
1513

16-
message(STATUS "Downloading Msgpack...")
17-
set(MSGPACK_TARBALL msgpack-${MSGPACK_VERSION}.tar.gz)
18-
file(DOWNLOAD ${MSGPACK_URL} ${CMAKE_CURRENT_SOURCE_DIR}/${MSGPACK_TARBALL}
19-
INACTIVITY_TIMEOUT 30
20-
EXPECTED_HASH SHA256=${MSGPACK_SHA256})
21-
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz ${MSGPACK_TARBALL}
22-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
23-
RESULT_VARIABLE rv)
24-
if(NOT rv EQUAL 0)
25-
message(FATAL_ERROR "Failed to extract ${MSGPACK_TARBALL}")
26-
endif()
14+
set(MSGPACK_VERSION 3.2.0)
15+
FetchContent_Declare(
16+
msgpackc
17+
URL "https://github.com/msgpack/msgpack-c/archive/cpp-${MSGPACK_VERSION}.tar.gz"
18+
URL_HASH SHA256=ff865a36bad5c72b8e7ebc4b7cf5f27a820fce4faff9c571c1791e3728355a39
19+
)
2720

28-
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
29-
set(MSGPACK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/msgpack-c-cpp-${MSGPACK_VERSION}/)
30-
add_subdirectory(${MSGPACK_SOURCE_DIR} EXCLUDE_FROM_ALL)
21+
set(MSGPACK_BUILD_EXAMPLES OFF)
3122

32-
# Similar enough to FindMsgpack
33-
set(MSGPACK_INCLUDE_DIRS ${MSGPACK_SOURCE_DIR}/include PARENT_SCOPE)
34-
set(MSGPACK_LIBRARIES msgpackc-static PARENT_SCOPE)
23+
FetchContent_MakeAvailable(msgpackc)

0 commit comments

Comments
 (0)