From e00f9a7407b38bc3fafa709e7beacf3bef1d2086 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Sat, 9 Dec 2023 11:57:03 -0700 Subject: [PATCH 1/5] Attempt 1. --- CMakeLists.txt | 3 +-- cmake/vcpkg.cmake | 69 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76952ae8..2df35e24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 3.25) # Instruct CMake to search the cmake directory for include scripts. list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) include(vcpkg) +option(NETREMOTE_VCPKG_BUILD_FOR_PORT "Enable building the project via a vcpkg port" OFF) # vcpkg build target. # @@ -15,8 +16,6 @@ set(VCPKG_TARGET_DEVELOPMENT "development") set(VCPKG_TARGET_RELEASE "release") set(VCPKG_TARGET ${VCPKG_TARGET_DEVELOPMENT} CACHE STRING "vcpkg target: either 'development' or 'release'") -set(VCPKG_MANIFEST_DIR ${CMAKE_CURRENT_LIST_DIR}/packaging/vcpkg/ports/netremote) - # Tell vcpkg to use the submodule root directory as the vcpkg root, and then configure it. set(VCPKG_SUBMODULE_ROOT ${CMAKE_CURRENT_LIST_DIR}/vcpkg CACHE PATH "Location of vcpkg submodule root") vcpkg_configure(SUBMODULE_ROOT ${VCPKG_SUBMODULE_ROOT}) diff --git a/cmake/vcpkg.cmake b/cmake/vcpkg.cmake index 739e3cf4..52a6d913 100644 --- a/cmake/vcpkg.cmake +++ b/cmake/vcpkg.cmake @@ -17,13 +17,9 @@ function(vcpkg_configure) ${ARGN} ) - # If the vcpkg root has been specified externally, use it. - if (DEFINED ENV{VCPKG_ROOT}) - set(VCPKG_ROOT "$ENV{VCPKG_ROOT}") - # Otherwise, use the specified submodule root. - else() - set(VCPKG_ROOT ${VCPKG_SUBMODULE_ROOT}) + get_filename_component(VCPKG_SUBMODULE_NAME ${VCPKG_SUBMODULE_ROOT} NAME) + if ("${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}" STREQUAL "") find_package(Git REQUIRED) # Initialize vcpkg sub-module if not already done. @@ -32,15 +28,58 @@ function(vcpkg_configure) WORKING_DIRECTORY ${VCPKG_SUBMODULE_ROOT}/../ COMMAND_ERROR_IS_FATAL ANY) endif() - - # Ignore all changes to the submodule tree. - get_filename_component(VCPKG_SUBMODULE_NAME ${VCPKG_SUBMODULE_ROOT} NAME) - execute_process(COMMAND ${GIT_EXECUTABLE} "config submodule.${VCPKG_SUBMODULE_NAME}.ignore all" - WORKING_DIRECTORY ${VCPKG_SUBMODULE_ROOT}../ - ) + set(CMAKE_TOOLCHAIN_FILE "${VCPKG_SUBMODULE_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "vcpkg toolchain file") endif() - # Set the CMake toolchain file to use vcpkg. - set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE FILEPATH "CMake toolchain file") + # Ignore all changes to the submodule tree. + execute_process(COMMAND ${GIT_EXECUTABLE} "config submodule.${VCPKG_SUBMODULE_NAME}.ignore all" + WORKING_DIRECTORY ${VCPKG_SUBMODULE_ROOT}../ + ) + +endfunction() + +# include(CMakeParseArguments) + +# # Configures vcpkg for use locally. +# # +# # This will determine if vcpkg is available. If not, it will clone the vcpkg +# # Github repository as a submodule into the directory specified by +# # SUBMODULE_ROOT, and instruct cmake to use its toolchain file to help satisfy +# # dependencies. It also adds a local git configuration rule to ignore all +# # changes in the submodule. +# function(vcpkg_configure) +# cmake_parse_arguments( +# VCPKG +# "" +# "SUBMODULE_ROOT" +# "" +# ${ARGN} +# ) + +# # If the vcpkg root has been specified externally, use it. +# if (DEFINED ENV{VCPKG_ROOT}) +# set(VCPKG_ROOT "$ENV{VCPKG_ROOT}") +# # Otherwise, use the specified submodule root. +# else() +# set(VCPKG_ROOT ${VCPKG_SUBMODULE_ROOT}) + +# find_package(Git REQUIRED) + +# # Initialize vcpkg sub-module if not already done. +# if (NOT EXISTS ${VCPKG_SUBMODULE_ROOT}/.git) +# execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${VCPKG_SUBMODULE_ROOT} +# WORKING_DIRECTORY ${VCPKG_SUBMODULE_ROOT}/../ +# COMMAND_ERROR_IS_FATAL ANY) +# endif() + +# # Ignore all changes to the submodule tree. +# get_filename_component(VCPKG_SUBMODULE_NAME ${VCPKG_SUBMODULE_ROOT} NAME) +# execute_process(COMMAND ${GIT_EXECUTABLE} "config submodule.${VCPKG_SUBMODULE_NAME}.ignore all" +# WORKING_DIRECTORY ${VCPKG_SUBMODULE_ROOT}../ +# ) +# endif() + +# # Set the CMake toolchain file to use vcpkg. +# set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE FILEPATH "CMake toolchain file") -endfunction() \ No newline at end of file +# endfunction() \ No newline at end of file From 44ae26887960b2e7b62e421055a192df19102fe7 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Sat, 9 Dec 2023 12:34:56 -0700 Subject: [PATCH 2/5] Don't add packaging directory for port builds. --- packaging/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index 01b5b330..ccdeded3 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -1 +1,4 @@ -add_subdirectory(vcpkg) \ No newline at end of file + +if (NOT NETREMOTE_VCPKG_BUILD_FOR_PORT) + add_subdirectory(vcpkg) +endif() From 772dc1eee79a4d3ef5f8643586d6f731bfb931d5 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Sat, 9 Dec 2023 16:50:12 -0700 Subject: [PATCH 3/5] Mark grpc as target dependency instead of host. --- packaging/vcpkg/ports/netremote/vcpkg.json | 5 +---- vcpkg.json | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/packaging/vcpkg/ports/netremote/vcpkg.json b/packaging/vcpkg/ports/netremote/vcpkg.json index 5e68988c..943c4a59 100644 --- a/packaging/vcpkg/ports/netremote/vcpkg.json +++ b/packaging/vcpkg/ports/netremote/vcpkg.json @@ -3,10 +3,7 @@ "name": "netremote", "version-string": "0.0.1", "dependencies": [ - { - "name": "grpc", - "host": true - }, + "grpc", "cli11", "protobuf", "catch2", diff --git a/vcpkg.json b/vcpkg.json index d85fddb7..ab25fab2 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,11 +1,9 @@ { + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", "name": "netremote", "version-string": "1", "dependencies": [ - { - "name": "grpc", - "host": true - }, + "grpc", "cli11", "protobuf", "catch2", From 143a28da7c5fbea3378b40c708d91e2e19e7f5bc Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Sat, 9 Dec 2023 16:55:52 -0700 Subject: [PATCH 4/5] Restore old vcpkg.cmake script. --- cmake/vcpkg.cmake | 69 +++++++++++------------------------------------ 1 file changed, 15 insertions(+), 54 deletions(-) diff --git a/cmake/vcpkg.cmake b/cmake/vcpkg.cmake index 52a6d913..739e3cf4 100644 --- a/cmake/vcpkg.cmake +++ b/cmake/vcpkg.cmake @@ -17,9 +17,13 @@ function(vcpkg_configure) ${ARGN} ) - get_filename_component(VCPKG_SUBMODULE_NAME ${VCPKG_SUBMODULE_ROOT} NAME) + # If the vcpkg root has been specified externally, use it. + if (DEFINED ENV{VCPKG_ROOT}) + set(VCPKG_ROOT "$ENV{VCPKG_ROOT}") + # Otherwise, use the specified submodule root. + else() + set(VCPKG_ROOT ${VCPKG_SUBMODULE_ROOT}) - if ("${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}" STREQUAL "") find_package(Git REQUIRED) # Initialize vcpkg sub-module if not already done. @@ -28,58 +32,15 @@ function(vcpkg_configure) WORKING_DIRECTORY ${VCPKG_SUBMODULE_ROOT}/../ COMMAND_ERROR_IS_FATAL ANY) endif() - set(CMAKE_TOOLCHAIN_FILE "${VCPKG_SUBMODULE_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "vcpkg toolchain file") - endif() - - # Ignore all changes to the submodule tree. - execute_process(COMMAND ${GIT_EXECUTABLE} "config submodule.${VCPKG_SUBMODULE_NAME}.ignore all" - WORKING_DIRECTORY ${VCPKG_SUBMODULE_ROOT}../ - ) - -endfunction() - -# include(CMakeParseArguments) -# # Configures vcpkg for use locally. -# # -# # This will determine if vcpkg is available. If not, it will clone the vcpkg -# # Github repository as a submodule into the directory specified by -# # SUBMODULE_ROOT, and instruct cmake to use its toolchain file to help satisfy -# # dependencies. It also adds a local git configuration rule to ignore all -# # changes in the submodule. -# function(vcpkg_configure) -# cmake_parse_arguments( -# VCPKG -# "" -# "SUBMODULE_ROOT" -# "" -# ${ARGN} -# ) - -# # If the vcpkg root has been specified externally, use it. -# if (DEFINED ENV{VCPKG_ROOT}) -# set(VCPKG_ROOT "$ENV{VCPKG_ROOT}") -# # Otherwise, use the specified submodule root. -# else() -# set(VCPKG_ROOT ${VCPKG_SUBMODULE_ROOT}) - -# find_package(Git REQUIRED) - -# # Initialize vcpkg sub-module if not already done. -# if (NOT EXISTS ${VCPKG_SUBMODULE_ROOT}/.git) -# execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${VCPKG_SUBMODULE_ROOT} -# WORKING_DIRECTORY ${VCPKG_SUBMODULE_ROOT}/../ -# COMMAND_ERROR_IS_FATAL ANY) -# endif() - -# # Ignore all changes to the submodule tree. -# get_filename_component(VCPKG_SUBMODULE_NAME ${VCPKG_SUBMODULE_ROOT} NAME) -# execute_process(COMMAND ${GIT_EXECUTABLE} "config submodule.${VCPKG_SUBMODULE_NAME}.ignore all" -# WORKING_DIRECTORY ${VCPKG_SUBMODULE_ROOT}../ -# ) -# endif() + # Ignore all changes to the submodule tree. + get_filename_component(VCPKG_SUBMODULE_NAME ${VCPKG_SUBMODULE_ROOT} NAME) + execute_process(COMMAND ${GIT_EXECUTABLE} "config submodule.${VCPKG_SUBMODULE_NAME}.ignore all" + WORKING_DIRECTORY ${VCPKG_SUBMODULE_ROOT}../ + ) + endif() -# # Set the CMake toolchain file to use vcpkg. -# set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE FILEPATH "CMake toolchain file") + # Set the CMake toolchain file to use vcpkg. + set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE FILEPATH "CMake toolchain file") -# endfunction() \ No newline at end of file +endfunction() \ No newline at end of file From cdd753e4aab4996316e0330f493cbf4f037143e4 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Sun, 10 Dec 2023 09:19:14 -0700 Subject: [PATCH 5/5] Update docker copy of vcpkg.json. --- .docker/netremote-dev/vcpkg.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.docker/netremote-dev/vcpkg.json b/.docker/netremote-dev/vcpkg.json index d85fddb7..ab25fab2 100644 --- a/.docker/netremote-dev/vcpkg.json +++ b/.docker/netremote-dev/vcpkg.json @@ -1,11 +1,9 @@ { + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", "name": "netremote", "version-string": "1", "dependencies": [ - { - "name": "grpc", - "host": true - }, + "grpc", "cli11", "protobuf", "catch2",