From e50118415a8f915405e291dad8f53453b51cecb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 16 Sep 2022 16:24:06 +0200 Subject: [PATCH 1/6] backport vcpkg part in CMakeLists.txt from main --- CMakeLists.txt | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e39d72cc133..e5924111308 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,17 +45,34 @@ if(POLICY CMP0135) cmake_policy(SET CMP0135 NEW) endif() -# Check if any relevant env vars were set from the build env scripts -if(DEFINED ENV{X_VCPKG_APPLOCAL_DEPS_INSTALL} AND NOT DEFINED X_VCPKG_APPLOCAL_DEPS_INSTALL) - set(X_VCPKG_APPLOCAL_DEPS_INSTALL "$ENV{X_VCPKG_APPLOCAL_DEPS_INSTALL}" CACHE BOOL "") +# Set up vcpkg +if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED VCPKG_ROOT) + set(VCPKG_ROOT "$ENV{VCPKG_ROOT}") endif() -if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) - set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") -endif() +if(DEFINED VCPKG_ROOT) + set(X_VCPKG_APPLOCAL_DEPS_INSTALL ON CACHE BOOL "Automatically copy dependencies into the install target directory for executables." FORCE) -if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) - set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") + if(NOT DEFINED VCPKG_OVERLAY_PORTS) + set(VCPKG_OVERLAY_PORTS "${VCPKG_ROOT}/overlay/ports") + if(APPLE) + list(APPEND VCPKG_OVERLAY_PORTS "${VCPKG_ROOT}/overlay/osx") + elseif(WIN32) + list(APPEND VCPKG_OVERLAY_PORTS "${VCPKG_ROOT}/overlay/windows") + endif() + endif() + + if(NOT DEFINED VCPKG_OVERLAY_TRIPLETS) + set(VCPKG_OVERLAY_TRIPLETS "${VCPKG_ROOT}/overlay/triplets") + endif() + + if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET}) + set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}") + endif() + + if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) + set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") + endif() endif() # Set a default build type if none was specified From bf37fd4594a5e2173bf11e55f27038e2186a4a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 16 Sep 2022 16:44:25 +0200 Subject: [PATCH 2/6] Use the VCPKG_ROOT environment variable only on windows This fixes a build error on the GitHub Ubuntu 22.4 workflow runner which has comes with VCPKG preinstaled --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5924111308..af69e6eba4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,11 @@ endif() # Set up vcpkg if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED VCPKG_ROOT) + if(WIN32) + # We only set the ENV{VCPKG_ROOT} on windows + # Do not use the default VCPKG_ROOT on other targets set(VCPKG_ROOT "$ENV{VCPKG_ROOT}") + endif() endif() if(DEFINED VCPKG_ROOT) From 86ad6b10921ba2fa515fa2316437f097eb44514f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 21 Sep 2022 00:50:15 +0200 Subject: [PATCH 3/6] Don't required VCPKG_ROOT set when building with vcpkg --- CMakeLists.txt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af69e6eba4f..5c3acaec298 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,19 +45,17 @@ if(POLICY CMP0135) cmake_policy(SET CMP0135 NEW) endif() -# Set up vcpkg if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED VCPKG_ROOT) if(WIN32) - # We only set the ENV{VCPKG_ROOT} on windows - # Do not use the default VCPKG_ROOT on other targets + # We assume ENV{VCPKG_ROOT} points to our vcpkg environment on windows + # and we configure the CMAKE_TOOLCHAIN_FILE and overlays accordingly set(VCPKG_ROOT "$ENV{VCPKG_ROOT}") endif() endif() if(DEFINED VCPKG_ROOT) - set(X_VCPKG_APPLOCAL_DEPS_INSTALL ON CACHE BOOL "Automatically copy dependencies into the install target directory for executables." FORCE) - if(NOT DEFINED VCPKG_OVERLAY_PORTS) + # required for manifest mode set(VCPKG_OVERLAY_PORTS "${VCPKG_ROOT}/overlay/ports") if(APPLE) list(APPEND VCPKG_OVERLAY_PORTS "${VCPKG_ROOT}/overlay/osx") @@ -67,18 +65,21 @@ if(DEFINED VCPKG_ROOT) endif() if(NOT DEFINED VCPKG_OVERLAY_TRIPLETS) + # required for manifest mode set(VCPKG_OVERLAY_TRIPLETS "${VCPKG_ROOT}/overlay/triplets") endif() - if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET}) - set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}") - endif() - if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") endif() endif() +if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) + set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}") +endif() +set(X_VCPKG_APPLOCAL_DEPS_INSTALL ON CACHE BOOL "Automatically copy dependencies into the install target directory for executables." FORCE) + + # Set a default build type if none was specified # See https://blog.kitware.com/cmake-and-the-default-build-type/ for details. set(default_build_type "RelWithDebInfo") From 67239406b0a8eba0b504e97e8aab60bf7eff5473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 21 Sep 2022 23:09:45 +0200 Subject: [PATCH 4/6] Verify $ENV{VCPKG_ROOT} before adopting it for the overlay folders --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c3acaec298..ce7ae5b309a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,10 +46,16 @@ if(POLICY CMP0135) endif() if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED VCPKG_ROOT) - if(WIN32) - # We assume ENV{VCPKG_ROOT} points to our vcpkg environment on windows + if(EXISTS "$ENV{VCPKG_ROOT}/overlay/ports" OR NOT EXISTS "$ENV{VCPKG_ROOT}/ports") + # We assume ENV{VCPKG_ROOT} points to our vcpkg environment # and we configure the CMAKE_TOOLCHAIN_FILE and overlays accordingly + message(STATUS "Setting VCKG_ROOT from environment: $ENV{VCPKG_ROOT}") set(VCPKG_ROOT "$ENV{VCPKG_ROOT}") + else() + # The official GitHub Actions runner images sometimes set these + # variables, but we don't want to use vcpkg from the runner. If we use + # vcpkg, we use our own prebuilt environment, not the one from the image. + message(STATUS "Ignoring env VCKG_ROOT (missing $ENV{VCPKG_ROOT}/overlay/ports)") endif() endif() From 556da26875d16e62ce4c3e34f1c8438820552d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 22 Sep 2022 08:36:47 +0200 Subject: [PATCH 5/6] Describe why we user VCPKG_ROOT environment variable --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce7ae5b309a..4cdd2305ad1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,9 @@ if(POLICY CMP0135) cmake_policy(SET CMP0135 NEW) endif() +# Note: ENV{VCPKG_ROOT} is the default location for the vcpkg cli tool which is +# later adjusted by CMAKE_TOOLCHAIN_FILE. We use it here as a workaround to find the +# overlay folders in manifest mode https://github.com/microsoft/vcpkg/issues/12289. if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED VCPKG_ROOT) if(EXISTS "$ENV{VCPKG_ROOT}/overlay/ports" OR NOT EXISTS "$ENV{VCPKG_ROOT}/ports") # We assume ENV{VCPKG_ROOT} points to our vcpkg environment From 3415b8553c9408346915aac72e2770afc01827a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 28 Sep 2022 11:50:08 +0200 Subject: [PATCH 6/6] Move to MIXXX_VCPKG_ROOT to avoid conflicts with system wide VCPKG_ROOT and fail build early in case it is not correctly set --- CMakeLists.txt | 37 ++++++++++++++++++------------------- tools/windows_buildenv.bat | 8 ++++---- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cdd2305ad1..2600dfc5340 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,41 +45,40 @@ if(POLICY CMP0135) cmake_policy(SET CMP0135 NEW) endif() -# Note: ENV{VCPKG_ROOT} is the default location for the vcpkg cli tool which is -# later adjusted by CMAKE_TOOLCHAIN_FILE. We use it here as a workaround to find the -# overlay folders in manifest mode https://github.com/microsoft/vcpkg/issues/12289. -if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED VCPKG_ROOT) - if(EXISTS "$ENV{VCPKG_ROOT}/overlay/ports" OR NOT EXISTS "$ENV{VCPKG_ROOT}/ports") - # We assume ENV{VCPKG_ROOT} points to our vcpkg environment +# We use here ENV{MIXXX_VCPKG_ROOT} as a workaround to find the overlay folders +# in manifest mode https://github.com/microsoft/vcpkg/issues/12289. +# Note: VCPKG_ROOT, the default location for the vcpkg cli tool is later +# adjusted by CMAKE_TOOLCHAIN_FILE. +if(DEFINED ENV{MIXXX_VCPKG_ROOT} AND NOT DEFINED MIXXX_VCPKG_ROOT) + set(MIXXX_VCPKG_ROOT "$ENV{MIXXX_VCPKG_ROOT}") +endif() + +if(DEFINED MIXXX_VCPKG_ROOT) + if(EXISTS "$ENV{MIXXX_VCPKG_ROOT}/overlay/ports" OR NOT EXISTS "$ENV{MIXXX_VCPKG_ROOT}/ports") + # MIXXX_VCPKG_ROOT points to our vcpkg environment # and we configure the CMAKE_TOOLCHAIN_FILE and overlays accordingly - message(STATUS "Setting VCKG_ROOT from environment: $ENV{VCPKG_ROOT}") - set(VCPKG_ROOT "$ENV{VCPKG_ROOT}") + message(STATUS "Using MIXXX_VCPKG_ROOT: $ENV{MIXXX_VCPKG_ROOT}") else() - # The official GitHub Actions runner images sometimes set these - # variables, but we don't want to use vcpkg from the runner. If we use - # vcpkg, we use our own prebuilt environment, not the one from the image. - message(STATUS "Ignoring env VCKG_ROOT (missing $ENV{VCPKG_ROOT}/overlay/ports)") + message(FATAL_ERROR "MIXXX_VCPKG_ROOT not correct (missing $ENV{MIXXX_VCPKG_ROOT}/overlay/ports)") endif() -endif() -if(DEFINED VCPKG_ROOT) if(NOT DEFINED VCPKG_OVERLAY_PORTS) # required for manifest mode - set(VCPKG_OVERLAY_PORTS "${VCPKG_ROOT}/overlay/ports") + set(VCPKG_OVERLAY_PORTS "${MIXXX_VCPKG_ROOT}/overlay/ports") if(APPLE) - list(APPEND VCPKG_OVERLAY_PORTS "${VCPKG_ROOT}/overlay/osx") + list(APPEND VCPKG_OVERLAY_PORTS "${MIXXX_VCPKG_ROOT}/overlay/osx") elseif(WIN32) - list(APPEND VCPKG_OVERLAY_PORTS "${VCPKG_ROOT}/overlay/windows") + list(APPEND VCPKG_OVERLAY_PORTS "${MIXXX_VCPKG_ROOT}/overlay/windows") endif() endif() if(NOT DEFINED VCPKG_OVERLAY_TRIPLETS) # required for manifest mode - set(VCPKG_OVERLAY_TRIPLETS "${VCPKG_ROOT}/overlay/triplets") + set(VCPKG_OVERLAY_TRIPLETS "${MIXXX_VCPKG_ROOT}/overlay/triplets") endif() if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) - set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") + set(CMAKE_TOOLCHAIN_FILE "${MIXXX_VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") endif() endif() diff --git a/tools/windows_buildenv.bat b/tools/windows_buildenv.bat index 87bde83dc1f..2774d1a9620 100644 --- a/tools/windows_buildenv.bat +++ b/tools/windows_buildenv.bat @@ -34,7 +34,7 @@ IF "%~1"=="" ( ) REM Make These permanent, not local to the batch script. -ENDLOCAL & SET "VCPKG_ROOT=%VCPKG_ROOT%" & SET "VCPKG_DEFAULT_TRIPLET=%VCPKG_DEFAULT_TRIPLET%" & SET "X_VCPKG_APPLOCAL_DEPS_INSTALL=%X_VCPKG_APPLOCAL_DEPS_INSTALL%" & SET "CMAKE_GENERATOR=%CMAKE_GENERATOR%" +ENDLOCAL & SET "MIXXX_VCPKG_ROOT=%MIXXX_VCPKG_ROOT%" & SET "VCPKG_DEFAULT_TRIPLET=%VCPKG_DEFAULT_TRIPLET%" & SET "X_VCPKG_APPLOCAL_DEPS_INSTALL=%X_VCPKG_APPLOCAL_DEPS_INSTALL%" & SET "CMAKE_GENERATOR=%CMAKE_GENERATOR%" EXIT /B 0 @@ -86,19 +86,19 @@ EXIT /B 0 ECHO ^Build environment path: !BUILDENV_PATH! - SET "VCPKG_ROOT=!BUILDENV_PATH!" + SET "MIXXX_VCPKG_ROOT=!BUILDENV_PATH!" SET "VCPKG_DEFAULT_TRIPLET=x64-windows" SET "X_VCPKG_APPLOCAL_DEPS_INSTALL=ON" SET "CMAKE_GENERATOR=Ninja" ECHO ^Environment Variables: - ECHO ^- VCPKG_ROOT='!VCPKG_ROOT!' + ECHO ^- MIXXX_VCPKG_ROOT='!MIXXX_VCPKG_ROOT!' ECHO ^- VCPKG_DEFAULT_TRIPLET='!VCPKG_DEFAULT_TRIPLET!' ECHO ^- X_VCPKG_APPLOCAL_DEPS_INSTALL='!X_VCPKG_APPLOCAL_DEPS_INSTALL!' ECHO ^- CMAKE_GENERATOR='!CMAKE_GENERATOR!' IF DEFINED GITHUB_ENV ( - ECHO VCPKG_ROOT=!VCPKG_ROOT!>>!GITHUB_ENV! + ECHO MIXXX_VCPKG_ROOT=!MIXXX_VCPKG_ROOT!>>!GITHUB_ENV! ECHO VCPKG_DEFAULT_TRIPLET=!VCPKG_DEFAULT_TRIPLET!>>!GITHUB_ENV! ECHO X_VCPKG_APPLOCAL_DEPS_INSTALL=!X_VCPKG_APPLOCAL_DEPS_INSTALL!>>!GITHUB_ENV! ECHO CMAKE_GENERATOR=!CMAKE_GENERATOR!>>!GITHUB_ENV!