diff --git a/docs/howto.md b/docs/howto.md index 676cb3139..a53baa688 100644 --- a/docs/howto.md +++ b/docs/howto.md @@ -59,11 +59,10 @@ NOTE: icon must be without transparency - Update secret (passports) on github ## QGIS debugging -When you want to debug QGIS code it's necessary to first build the QGIS dependency in `RelWithDebugInfo` mode. This can be achieved by specifying these environment variables: -| Name | Value | -|:---------------------:|:------------------:| -| `QGIS_DEBUG_BUILD` | 1 | -| `VCPKG_KEEP_ENV_VARS` | `QGIS_DEBUG_BUILD` | +When you want to debug QGIS code it's necessary to first build the QGIS dependency in `Debug` or `RelWithDebugInfo` mode. +The build type of the QGIS dependency can be selected by setting the `QGIS_BUILD_TYPE` environment variable before calling `cmake`. +Valid values are `Debug` and `RelWithDebugInfo`, any other value or an unset variable will result in having QGIS built in `Release`, which is the default. +Once the QGIS dependency is built in all modes, switching between them should be fast as the vcpkg cache is used and no rebuild is required. -Furthermore, to debug android version of Mergin Maps it's highly recommended to use QtCreator, even though it should be possible also without it. \ No newline at end of file +Furthermore, to debug android version of Mergin Maps it's highly recommended to use QtCreator, even though it should be possible also without it. diff --git a/vcpkg/ports/qgis/portfile.cmake b/vcpkg/ports/qgis/portfile.cmake index 0cd68add3..ef894fea2 100644 --- a/vcpkg/ports/qgis/portfile.cmake +++ b/vcpkg/ports/qgis/portfile.cmake @@ -223,9 +223,16 @@ if (VCPKG_CROSSCOMPILING) ) endif () -if (DEFINED ENV{QGIS_DEBUG_BUILD}) - message(STATUS "Building requested QGIS RelWithDebInfo build") - list(APPEND QGIS_OPTIONS_RELEASE -DCMAKE_BUILD_TYPE=RelWithDebInfo) +if (DEFINED ENV{QGIS_BUILD_TYPE}) + set(QGIS_BUILD_TYPE $ENV{QGIS_BUILD_TYPE}) + if (QGIS_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") + message(STATUS "Building requested QGIS ${QGIS_BUILD_TYPE} build") + list(APPEND QGIS_OPTIONS_RELEASE -DCMAKE_BUILD_TYPE=${QGIS_BUILD_TYPE}) + else () + message(WARNING "QGIS_BUILD_TYPE value '${QGIS_BUILD_TYPE}' is not valid, ignoring. Valid values are Debug or RelWithDebInfo.") + endif () +else () + message(STATUS "Building requested QGIS Release build") endif () vcpkg_configure_cmake( diff --git a/vcpkg/triplets/arm-android.cmake b/vcpkg/triplets/arm-android.cmake index 6ec3ed7c1..68fcddec2 100644 --- a/vcpkg/triplets/arm-android.cmake +++ b/vcpkg/triplets/arm-android.cmake @@ -30,3 +30,5 @@ set(ANDROID_SDK_ROOT $ENV{ANDROID_SDK_ROOT}) set(VCPKG_CXX_FLAGS "-fstack-protector-strong") set(VCPKG_C_FLAGS "-fstack-protector-strong") set(VCPKG_LINKER_FLAGS "-lunwind -Wl,--exclude-libs=libunwind.a") + +include("${CMAKE_CURRENT_LIST_DIR}/qgis-build-type.cmake") diff --git a/vcpkg/triplets/arm64-android.cmake b/vcpkg/triplets/arm64-android.cmake index 7f25f9cbf..5899a94e2 100644 --- a/vcpkg/triplets/arm64-android.cmake +++ b/vcpkg/triplets/arm64-android.cmake @@ -27,3 +27,5 @@ set(ANDROID_SDK_ROOT $ENV{ANDROID_SDK_ROOT}) set(VCPKG_CXX_FLAGS "-fstack-protector-strong") set(VCPKG_C_FLAGS "-fstack-protector-strong") + +include("${CMAKE_CURRENT_LIST_DIR}/qgis-build-type.cmake") diff --git a/vcpkg/triplets/arm64-ios.cmake b/vcpkg/triplets/arm64-ios.cmake index 43c0c08e9..c8288d6ef 100644 --- a/vcpkg/triplets/arm64-ios.cmake +++ b/vcpkg/triplets/arm64-ios.cmake @@ -10,3 +10,5 @@ set(VCPKG_MAKE_BUILD_TRIPLET "--host=aarch64-apple-ios${VCPKG_OSX_DEPLOYMENT_TAR set(VCPKG_BUILD_TYPE release) set(VCPKG_CXX_FLAGS "-fvisibility=hidden") set(VCPKG_C_FLAGS "-fvisibility=hidden") + +include("${CMAKE_CURRENT_LIST_DIR}/qgis-build-type.cmake") diff --git a/vcpkg/triplets/arm64-osx.cmake b/vcpkg/triplets/arm64-osx.cmake index 10fc038e1..e0bb9bb8d 100644 --- a/vcpkg/triplets/arm64-osx.cmake +++ b/vcpkg/triplets/arm64-osx.cmake @@ -11,3 +11,5 @@ set(VCPKG_OSX_DEPLOYMENT_TARGET 11.0) # See https://github.com/microsoft/vcpkg/issues/10038 set(VCPKG_C_FLAGS -mmacosx-version-min=${VCPKG_OSX_DEPLOYMENT_TARGET}) set(VCPKG_CXX_FLAGS -mmacosx-version-min=${VCPKG_OSX_DEPLOYMENT_TARGET}) + +include("${CMAKE_CURRENT_LIST_DIR}/qgis-build-type.cmake") diff --git a/vcpkg/triplets/qgis-build-type.cmake b/vcpkg/triplets/qgis-build-type.cmake new file mode 100644 index 000000000..709420767 --- /dev/null +++ b/vcpkg/triplets/qgis-build-type.cmake @@ -0,0 +1,3 @@ +if (PORT STREQUAL "qgis" AND "$ENV{QGIS_BUILD_TYPE}" MATCHES "^(Debug|RelWithDebInfo)$") + list(APPEND VCPKG_ENV_PASSTHROUGH QGIS_BUILD_TYPE) +endif () diff --git a/vcpkg/triplets/x64-linux.cmake b/vcpkg/triplets/x64-linux.cmake index 54efc5481..1b1c653b4 100644 --- a/vcpkg/triplets/x64-linux.cmake +++ b/vcpkg/triplets/x64-linux.cmake @@ -12,3 +12,5 @@ set(VCPKG_CMAKE_SYSTEM_NAME Linux) set(VCPKG_BUILD_TYPE release) set(VCPKG_FIXUP_ELF_RPATH ON) + +include("${CMAKE_CURRENT_LIST_DIR}/qgis-build-type.cmake") diff --git a/vcpkg/triplets/x64-osx.cmake b/vcpkg/triplets/x64-osx.cmake index 4cc004c68..fc9a48bbf 100644 --- a/vcpkg/triplets/x64-osx.cmake +++ b/vcpkg/triplets/x64-osx.cmake @@ -11,3 +11,5 @@ set(VCPKG_OSX_DEPLOYMENT_TARGET 11.0) # See https://github.com/microsoft/vcpkg/issues/10038 set(VCPKG_C_FLAGS -mmacosx-version-min=${VCPKG_OSX_DEPLOYMENT_TARGET}) set(VCPKG_CXX_FLAGS -mmacosx-version-min=${VCPKG_OSX_DEPLOYMENT_TARGET}) + +include("${CMAKE_CURRENT_LIST_DIR}/qgis-build-type.cmake") diff --git a/vcpkg/triplets/x64-windows.cmake b/vcpkg/triplets/x64-windows.cmake index f6c40253a..4efadc50c 100644 --- a/vcpkg/triplets/x64-windows.cmake +++ b/vcpkg/triplets/x64-windows.cmake @@ -2,3 +2,5 @@ set(VCPKG_TARGET_ARCHITECTURE x64) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE dynamic) set(VCPKG_BUILD_TYPE release) + +include("${CMAKE_CURRENT_LIST_DIR}/qgis-build-type.cmake")