2022-06-08 07:26:51 +08:00
|
|
|
include_guard(GLOBAL)
|
2021-03-01 05:17:19 +08:00
|
|
|
|
|
|
|
macro(z_vcpkg_cmake_configure_both_set_or_unset var1 var2)
|
|
|
|
if(DEFINED ${var1} AND NOT DEFINED ${var2})
|
|
|
|
message(FATAL_ERROR "If ${var1} is set, then ${var2} must be set.")
|
|
|
|
elseif(NOT DEFINED ${var1} AND DEFINED ${var2})
|
|
|
|
message(FATAL_ERROR "If ${var2} is set, then ${var1} must be set.")
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
function(vcpkg_cmake_configure)
|
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 "arg"
|
2021-07-30 00:47:35 +08:00
|
|
|
"PREFER_NINJA;DISABLE_PARALLEL_CONFIGURE;WINDOWS_USE_MSBUILD;NO_CHARSET_FLAG;Z_CMAKE_GET_VARS_USAGE"
|
2021-03-01 05:17:19 +08:00
|
|
|
"SOURCE_PATH;GENERATOR;LOGFILE_BASE"
|
2021-07-21 01:24:58 +08:00
|
|
|
"OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;MAYBE_UNUSED_VARIABLES"
|
2021-03-01 05:17:19 +08:00
|
|
|
)
|
|
|
|
|
2021-07-30 00:47:35 +08:00
|
|
|
if(NOT arg_Z_CMAKE_GET_VARS_USAGE AND DEFINED CACHE{Z_VCPKG_CMAKE_GENERATOR})
|
2022-05-07 06:12:11 +08:00
|
|
|
message(WARNING "${CMAKE_CURRENT_FUNCTION} already called; this function should only be called once.")
|
|
|
|
endif()
|
|
|
|
if(arg_PREFER_NINJA)
|
|
|
|
message(WARNING "PREFER_NINJA has been deprecated in ${CMAKE_CURRENT_FUNCTION}. Please remove it from the portfile!")
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(DEFINED arg_UNPARSED_ARGUMENTS)
|
2022-05-07 06:12:11 +08:00
|
|
|
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
2022-05-07 06:12:11 +08:00
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
if(NOT DEFINED arg_SOURCE_PATH)
|
|
|
|
message(FATAL_ERROR "SOURCE_PATH must be set")
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED arg_LOGFILE_BASE)
|
2021-07-21 01:24:58 +08:00
|
|
|
set(arg_LOGFILE_BASE "config-${TARGET_TRIPLET}")
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
|
|
|
|
2021-07-21 01:24:58 +08:00
|
|
|
set(manually_specified_variables "")
|
2021-07-30 00:47:35 +08:00
|
|
|
|
|
|
|
if(arg_Z_CMAKE_GET_VARS_USAGE)
|
|
|
|
set(configuring_message "Getting CMake variables for ${TARGET_TRIPLET}")
|
|
|
|
else()
|
|
|
|
set(configuring_message "Configuring ${TARGET_TRIPLET}")
|
|
|
|
|
|
|
|
foreach(option IN LISTS arg_OPTIONS arg_OPTIONS_RELEASE arg_OPTIONS_DEBUG)
|
2022-05-07 06:12:11 +08:00
|
|
|
if("${option}" MATCHES "^-D([^:=]*)[:=]")
|
|
|
|
vcpkg_list(APPEND manually_specified_variables "${CMAKE_MATCH_1}")
|
2021-07-30 00:47:35 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(REMOVE_DUPLICATES manually_specified_variables)
|
|
|
|
foreach(maybe_unused_var IN LISTS arg_MAYBE_UNUSED_VARIABLES)
|
|
|
|
vcpkg_list(REMOVE_ITEM manually_specified_variables "${maybe_unused_var}")
|
|
|
|
endforeach()
|
2021-07-30 00:47:35 +08:00
|
|
|
debug_message("manually specified variables: ${manually_specified_variables}")
|
|
|
|
endif()
|
2021-07-21 01:24:58 +08:00
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
if(CMAKE_HOST_WIN32)
|
|
|
|
if(DEFINED ENV{PROCESSOR_ARCHITEW6432})
|
|
|
|
set(host_architecture "$ENV{PROCESSOR_ARCHITEW6432}")
|
|
|
|
else()
|
|
|
|
set(host_architecture "$ENV{PROCESSOR_ARCHITECTURE}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2022-07-26 03:23:04 +08:00
|
|
|
set(ninja_host ON) # Ninja availability
|
|
|
|
if(host_architecture STREQUAL "x86" OR DEFINED ENV{VCPKG_FORCE_SYSTEM_BINARIES})
|
2021-03-01 05:17:19 +08:00
|
|
|
# Prebuilt ninja binaries are only provided for x64 hosts
|
2022-07-26 03:23:04 +08:00
|
|
|
find_program(NINJA NAMES ninja ninja-build)
|
|
|
|
if(NOT NINJA)
|
|
|
|
set(ninja_host OFF)
|
|
|
|
set(arg_DISABLE_PARALLEL_CONFIGURE ON)
|
|
|
|
set(arg_WINDOWS_USE_MSBUILD ON)
|
|
|
|
endif()
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
|
|
|
|
2022-07-26 03:23:04 +08:00
|
|
|
set(generator "")
|
|
|
|
set(architecture_options "")
|
|
|
|
if(arg_WINDOWS_USE_MSBUILD AND VCPKG_HOST_IS_WINDOWS AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
|
2022-04-12 06:57:36 +08:00
|
|
|
z_vcpkg_get_visual_studio_generator(OUT_GENERATOR generator OUT_ARCH arch)
|
2022-07-26 03:23:04 +08:00
|
|
|
vcpkg_list(APPEND architecture_options "-A${arch}")
|
2022-09-23 05:28:20 +08:00
|
|
|
if(DEFINED VCPKG_PLATFORM_TOOLSET)
|
|
|
|
vcpkg_list(APPEND arg_OPTIONS "-T${VCPKG_PLATFORM_TOOLSET}")
|
|
|
|
endif()
|
|
|
|
if(NOT generator)
|
|
|
|
message(FATAL_ERROR "Unable to determine appropriate Visual Studio generator for triplet ${TARGET_TRIPLET}:
|
|
|
|
ENV{VisualStudioVersion} : $ENV{VisualStudioVersion}
|
|
|
|
VCPKG_TARGET_ARCHITECTURE: ${VCPKG_TARGET_ARCHITECTURE}")
|
|
|
|
endif()
|
2022-07-26 03:23:04 +08:00
|
|
|
elseif(DEFINED arg_GENERATOR)
|
|
|
|
set(generator "${arg_GENERATOR}")
|
|
|
|
elseif(ninja_host)
|
|
|
|
set(generator "Ninja")
|
|
|
|
elseif(NOT VCPKG_HOST_IS_WINDOWS)
|
|
|
|
set(generator "Unix Makefiles")
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
|
|
|
|
2022-04-12 06:57:36 +08:00
|
|
|
if(NOT generator)
|
2021-03-01 05:17:19 +08:00
|
|
|
if(NOT VCPKG_CMAKE_SYSTEM_NAME)
|
2022-04-12 06:57:36 +08:00
|
|
|
set(VCPKG_CMAKE_SYSTEM_NAME "Windows")
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
|
|
|
message(FATAL_ERROR "Unable to determine appropriate generator for: "
|
|
|
|
"${VCPKG_CMAKE_SYSTEM_NAME}-${VCPKG_TARGET_ARCHITECTURE}-${VCPKG_PLATFORM_TOOLSET}")
|
|
|
|
endif()
|
|
|
|
|
2022-07-26 03:23:04 +08:00
|
|
|
if(generator STREQUAL "Ninja")
|
2021-03-01 05:17:19 +08:00
|
|
|
vcpkg_find_acquire_program(NINJA)
|
2022-07-26 03:23:04 +08:00
|
|
|
vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_MAKE_PROGRAM=${NINJA}")
|
|
|
|
# If we use Ninja, it must be on PATH for CMake's ExternalProject,
|
|
|
|
# cf. https://gitlab.kitware.com/cmake/cmake/-/issues/23355.
|
2021-03-01 05:17:19 +08:00
|
|
|
get_filename_component(ninja_path "${NINJA}" DIRECTORY)
|
|
|
|
vcpkg_add_to_path("${ninja_path}")
|
|
|
|
endif()
|
|
|
|
|
2021-12-31 01:45:20 +08:00
|
|
|
set(build_dir_release "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
|
|
|
|
set(build_dir_debug "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
|
2021-03-01 05:17:19 +08:00
|
|
|
file(REMOVE_RECURSE
|
2021-12-31 01:45:20 +08:00
|
|
|
"${build_dir_release}"
|
|
|
|
"${build_dir_debug}")
|
|
|
|
file(MAKE_DIRECTORY "${build_dir_release}")
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
|
|
|
file(MAKE_DIRECTORY "${build_dir_debug}")
|
|
|
|
endif()
|
2021-03-01 05:17:19 +08:00
|
|
|
|
|
|
|
if(DEFINED VCPKG_CMAKE_SYSTEM_NAME)
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_SYSTEM_NAME=${VCPKG_CMAKE_SYSTEM_NAME}")
|
2021-12-11 05:55:24 +08:00
|
|
|
if(VCPKG_TARGET_IS_UWP AND NOT DEFINED VCPKG_CMAKE_SYSTEM_VERSION)
|
2021-03-01 05:17:19 +08:00
|
|
|
set(VCPKG_CMAKE_SYSTEM_VERSION 10.0)
|
2021-12-11 05:55:24 +08:00
|
|
|
elseif(VCPKG_TARGET_IS_ANDROID AND NOT DEFINED VCPKG_CMAKE_SYSTEM_VERSION)
|
2021-03-01 05:17:19 +08:00
|
|
|
set(VCPKG_CMAKE_SYSTEM_VERSION 21)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(DEFINED VCPKG_CMAKE_SYSTEM_VERSION)
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_SYSTEM_VERSION=${VCPKG_CMAKE_SYSTEM_VERSION}")
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(APPEND arg_OPTIONS "-DBUILD_SHARED_LIBS=ON")
|
2021-03-01 05:17:19 +08:00
|
|
|
elseif(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(APPEND arg_OPTIONS "-DBUILD_SHARED_LIBS=OFF")
|
2021-03-01 05:17:19 +08:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"Invalid setting for VCPKG_LIBRARY_LINKAGE: \"${VCPKG_LIBRARY_LINKAGE}\". "
|
|
|
|
"It must be \"static\" or \"dynamic\"")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
z_vcpkg_cmake_configure_both_set_or_unset(VCPKG_CXX_FLAGS_DEBUG VCPKG_C_FLAGS_DEBUG)
|
2021-03-02 03:49:24 +08:00
|
|
|
z_vcpkg_cmake_configure_both_set_or_unset(VCPKG_CXX_FLAGS_RELEASE VCPKG_C_FLAGS_RELEASE)
|
2021-03-01 05:17:19 +08:00
|
|
|
z_vcpkg_cmake_configure_both_set_or_unset(VCPKG_CXX_FLAGS VCPKG_C_FLAGS)
|
|
|
|
|
|
|
|
set(VCPKG_SET_CHARSET_FLAG ON)
|
|
|
|
if(arg_NO_CHARSET_FLAG)
|
|
|
|
set(VCPKG_SET_CHARSET_FLAG OFF)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT DEFINED VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
|
2022-04-12 06:57:36 +08:00
|
|
|
z_vcpkg_select_default_vcpkg_chainload_toolchain()
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
|
|
|
|
2021-07-02 00:21:55 +08:00
|
|
|
list(JOIN VCPKG_TARGET_ARCHITECTURE "\;" target_architecture_string)
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(APPEND arg_OPTIONS
|
2021-03-01 05:17:19 +08:00
|
|
|
"-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}"
|
|
|
|
"-DVCPKG_TARGET_TRIPLET=${TARGET_TRIPLET}"
|
|
|
|
"-DVCPKG_SET_CHARSET_FLAG=${VCPKG_SET_CHARSET_FLAG}"
|
|
|
|
"-DVCPKG_PLATFORM_TOOLSET=${VCPKG_PLATFORM_TOOLSET}"
|
|
|
|
"-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON"
|
|
|
|
"-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON"
|
|
|
|
"-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON"
|
|
|
|
"-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE"
|
|
|
|
"-DCMAKE_VERBOSE_MAKEFILE=ON"
|
|
|
|
"-DVCPKG_APPLOCAL_DEPS=OFF"
|
|
|
|
"-DCMAKE_TOOLCHAIN_FILE=${SCRIPTS}/buildsystems/vcpkg.cmake"
|
|
|
|
"-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON"
|
|
|
|
"-DVCPKG_CXX_FLAGS=${VCPKG_CXX_FLAGS}"
|
|
|
|
"-DVCPKG_CXX_FLAGS_RELEASE=${VCPKG_CXX_FLAGS_RELEASE}"
|
|
|
|
"-DVCPKG_CXX_FLAGS_DEBUG=${VCPKG_CXX_FLAGS_DEBUG}"
|
|
|
|
"-DVCPKG_C_FLAGS=${VCPKG_C_FLAGS}"
|
|
|
|
"-DVCPKG_C_FLAGS_RELEASE=${VCPKG_C_FLAGS_RELEASE}"
|
|
|
|
"-DVCPKG_C_FLAGS_DEBUG=${VCPKG_C_FLAGS_DEBUG}"
|
|
|
|
"-DVCPKG_CRT_LINKAGE=${VCPKG_CRT_LINKAGE}"
|
|
|
|
"-DVCPKG_LINKER_FLAGS=${VCPKG_LINKER_FLAGS}"
|
|
|
|
"-DVCPKG_LINKER_FLAGS_RELEASE=${VCPKG_LINKER_FLAGS_RELEASE}"
|
|
|
|
"-DVCPKG_LINKER_FLAGS_DEBUG=${VCPKG_LINKER_FLAGS_DEBUG}"
|
2021-07-02 00:21:55 +08:00
|
|
|
"-DVCPKG_TARGET_ARCHITECTURE=${target_architecture_string}"
|
2021-03-01 05:17:19 +08:00
|
|
|
"-DCMAKE_INSTALL_LIBDIR:STRING=lib"
|
|
|
|
"-DCMAKE_INSTALL_BINDIR:STRING=bin"
|
|
|
|
"-D_VCPKG_ROOT_DIR=${VCPKG_ROOT_DIR}"
|
|
|
|
"-D_VCPKG_INSTALLED_DIR=${_VCPKG_INSTALLED_DIR}"
|
|
|
|
"-DVCPKG_MANIFEST_INSTALL=OFF"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Sets configuration variables for macOS builds
|
|
|
|
foreach(config_var IN ITEMS INSTALL_NAME_DIR OSX_DEPLOYMENT_TARGET OSX_SYSROOT OSX_ARCHITECTURES)
|
|
|
|
if(DEFINED VCPKG_${config_var})
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_${config_var}=${VCPKG_${config_var}}")
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2021-06-09 00:50:09 +08:00
|
|
|
# Allow overrides / additional configuration variables from triplets
|
|
|
|
if(DEFINED VCPKG_CMAKE_CONFIGURE_OPTIONS)
|
2022-06-21 04:58:43 +08:00
|
|
|
vcpkg_list(APPEND arg_OPTIONS ${VCPKG_CMAKE_CONFIGURE_OPTIONS})
|
2021-06-09 00:50:09 +08:00
|
|
|
endif()
|
|
|
|
if(DEFINED VCPKG_CMAKE_CONFIGURE_OPTIONS_RELEASE)
|
2022-06-21 04:58:43 +08:00
|
|
|
vcpkg_list(APPEND arg_OPTIONS_RELEASE ${VCPKG_CMAKE_CONFIGURE_OPTIONS_RELEASE})
|
2021-06-09 00:50:09 +08:00
|
|
|
endif()
|
|
|
|
if(DEFINED VCPKG_CMAKE_CONFIGURE_OPTIONS_DEBUG)
|
2022-06-21 04:58:43 +08:00
|
|
|
vcpkg_list(APPEND arg_OPTIONS_DEBUG ${VCPKG_CMAKE_CONFIGURE_OPTIONS_DEBUG})
|
2021-06-09 00:50:09 +08:00
|
|
|
endif()
|
|
|
|
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(SET rel_command
|
|
|
|
"${CMAKE_COMMAND}" "${arg_SOURCE_PATH}"
|
|
|
|
-G "${generator}"
|
2022-07-26 03:23:04 +08:00
|
|
|
${architecture_options}
|
2022-05-07 06:12:11 +08:00
|
|
|
"-DCMAKE_BUILD_TYPE=Release"
|
|
|
|
"-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}"
|
|
|
|
${arg_OPTIONS} ${arg_OPTIONS_RELEASE})
|
|
|
|
vcpkg_list(SET dbg_command
|
|
|
|
"${CMAKE_COMMAND}" "${arg_SOURCE_PATH}"
|
|
|
|
-G "${generator}"
|
2022-07-26 03:23:04 +08:00
|
|
|
${architecture_options}
|
2022-05-07 06:12:11 +08:00
|
|
|
"-DCMAKE_BUILD_TYPE=Debug"
|
|
|
|
"-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug"
|
|
|
|
${arg_OPTIONS} ${arg_OPTIONS_DEBUG})
|
|
|
|
|
2022-07-26 03:23:04 +08:00
|
|
|
if(NOT arg_DISABLE_PARALLEL_CONFIGURE)
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_DISABLE_SOURCE_CHANGES=ON")
|
2021-03-01 05:17:19 +08:00
|
|
|
|
|
|
|
vcpkg_find_acquire_program(NINJA)
|
|
|
|
|
|
|
|
#parallelize the configure step
|
2022-05-07 06:12:11 +08:00
|
|
|
set(ninja_configure_contents
|
|
|
|
"rule CreateProcess\n command = \$process\n\n"
|
2021-03-01 05:17:19 +08:00
|
|
|
)
|
|
|
|
|
2022-05-07 06:12:11 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "release")
|
|
|
|
z_vcpkg_configure_cmake_build_cmakecache(ninja_configure_contents ".." "rel")
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
2022-05-07 06:12:11 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "debug")
|
|
|
|
z_vcpkg_configure_cmake_build_cmakecache(ninja_configure_contents "../../${TARGET_TRIPLET}-dbg" "dbg")
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
|
|
|
|
2021-12-31 01:45:20 +08:00
|
|
|
file(MAKE_DIRECTORY "${build_dir_release}/vcpkg-parallel-configure")
|
2022-05-07 06:12:11 +08:00
|
|
|
file(WRITE
|
|
|
|
"${build_dir_release}/vcpkg-parallel-configure/build.ninja"
|
|
|
|
"${ninja_configure_contents}")
|
2021-03-01 05:17:19 +08:00
|
|
|
|
2021-07-30 00:47:35 +08:00
|
|
|
message(STATUS "${configuring_message}")
|
2021-03-01 05:17:19 +08:00
|
|
|
vcpkg_execute_required_process(
|
2022-05-07 06:12:11 +08:00
|
|
|
COMMAND "${NINJA}" -v
|
2021-12-31 01:45:20 +08:00
|
|
|
WORKING_DIRECTORY "${build_dir_release}/vcpkg-parallel-configure"
|
2021-07-21 01:24:58 +08:00
|
|
|
LOGNAME "${arg_LOGFILE_BASE}"
|
2022-07-08 05:58:03 +08:00
|
|
|
SAVE_LOG_FILES ../../${TARGET_TRIPLET}-dbg/CMakeCache.txt ../CMakeCache.txt
|
2021-03-01 05:17:19 +08:00
|
|
|
)
|
2022-05-07 06:12:11 +08:00
|
|
|
|
|
|
|
vcpkg_list(APPEND config_logs
|
2021-07-21 01:24:58 +08:00
|
|
|
"${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-out.log"
|
|
|
|
"${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-err.log")
|
2021-03-01 05:17:19 +08:00
|
|
|
else()
|
2022-05-07 06:12:11 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "debug")
|
2021-07-30 00:47:35 +08:00
|
|
|
message(STATUS "${configuring_message}-dbg")
|
2021-03-01 05:17:19 +08:00
|
|
|
vcpkg_execute_required_process(
|
2022-05-07 06:12:11 +08:00
|
|
|
COMMAND ${dbg_command}
|
2021-12-31 01:45:20 +08:00
|
|
|
WORKING_DIRECTORY "${build_dir_debug}"
|
2021-07-21 01:24:58 +08:00
|
|
|
LOGNAME "${arg_LOGFILE_BASE}-dbg"
|
2022-07-08 05:58:03 +08:00
|
|
|
SAVE_LOG_FILES CMakeCache.txt
|
2021-03-01 05:17:19 +08:00
|
|
|
)
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(APPEND config_logs
|
2021-07-21 01:24:58 +08:00
|
|
|
"${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-dbg-out.log"
|
|
|
|
"${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-dbg-err.log")
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
|
|
|
|
2022-05-07 06:12:11 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "release")
|
2021-07-30 00:47:35 +08:00
|
|
|
message(STATUS "${configuring_message}-rel")
|
2021-03-01 05:17:19 +08:00
|
|
|
vcpkg_execute_required_process(
|
2022-05-07 06:12:11 +08:00
|
|
|
COMMAND ${rel_command}
|
2021-12-31 01:45:20 +08:00
|
|
|
WORKING_DIRECTORY "${build_dir_release}"
|
2021-03-01 05:17:19 +08:00
|
|
|
LOGNAME "${arg_LOGFILE_BASE}-rel"
|
2022-07-08 05:58:03 +08:00
|
|
|
SAVE_LOG_FILES CMakeCache.txt
|
2021-03-01 05:17:19 +08:00
|
|
|
)
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(APPEND config_logs
|
2021-07-21 01:24:58 +08:00
|
|
|
"${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-rel-out.log"
|
|
|
|
"${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-rel-err.log")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(all_unused_variables)
|
|
|
|
foreach(config_log IN LISTS config_logs)
|
|
|
|
if(NOT EXISTS "${config_log}")
|
|
|
|
continue()
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
2021-07-21 01:24:58 +08:00
|
|
|
file(READ "${config_log}" log_contents)
|
|
|
|
debug_message("Reading configure log ${config_log}...")
|
|
|
|
if(NOT log_contents MATCHES "Manually-specified variables were not used by the project:\n\n(( [^\n]*\n)*)")
|
|
|
|
continue()
|
|
|
|
endif()
|
|
|
|
string(STRIP "${CMAKE_MATCH_1}" unused_variables) # remove leading ` ` and trailing `\n`
|
|
|
|
string(REPLACE "\n " ";" unused_variables "${unused_variables}")
|
|
|
|
debug_message("unused variables: ${unused_variables}")
|
|
|
|
foreach(unused_variable IN LISTS unused_variables)
|
|
|
|
if(unused_variable IN_LIST manually_specified_variables)
|
|
|
|
debug_message("manually specified unused variable: ${unused_variable}")
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(APPEND all_unused_variables "${unused_variable}")
|
2021-07-21 01:24:58 +08:00
|
|
|
else()
|
|
|
|
debug_message("unused variable (not manually specified): ${unused_variable}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(DEFINED all_unused_variables)
|
2022-05-07 06:12:11 +08:00
|
|
|
vcpkg_list(REMOVE_DUPLICATES all_unused_variables)
|
|
|
|
vcpkg_list(JOIN all_unused_variables "\n " all_unused_variables)
|
2021-07-21 01:24:58 +08:00
|
|
|
message(WARNING "The following variables are not used in CMakeLists.txt:
|
|
|
|
${all_unused_variables}
|
|
|
|
Please recheck them and remove the unnecessary options from the `vcpkg_cmake_configure` call.
|
|
|
|
If these options should still be passed for whatever reason, please use the `MAYBE_UNUSED_VARIABLES` argument.")
|
2021-03-01 05:17:19 +08:00
|
|
|
endif()
|
|
|
|
|
2021-07-30 00:47:35 +08:00
|
|
|
if(NOT arg_Z_CMAKE_GET_VARS_USAGE)
|
|
|
|
set(Z_VCPKG_CMAKE_GENERATOR "${generator}" CACHE INTERNAL "The generator which was used to configure CMake.")
|
|
|
|
endif()
|
2021-03-01 05:17:19 +08:00
|
|
|
endfunction()
|