diff --git a/docs/maintainers/portfile-functions.md b/docs/maintainers/portfile-functions.md index 6527d8e0bbb..dd97511c0a3 100644 --- a/docs/maintainers/portfile-functions.md +++ b/docs/maintainers/portfile-functions.md @@ -5,6 +5,7 @@ - [vcpkg\_acquire\_msys](vcpkg_acquire_msys.md) - [vcpkg\_add\_to\_path](vcpkg_add_to_path.md) - [vcpkg\_apply\_patches](vcpkg_apply_patches.md) (deprecated) +- [vcpkg\_backup\_restore\_env\_vars](vcpkg_backup_restore_env_vars.md) - [vcpkg\_build\_cmake](vcpkg_build_cmake.md) (deprecated, use [vcpkg\_cmake\_build](ports/vcpkg-cmake/vcpkg_cmake_build.md)) - [vcpkg\_build\_make](vcpkg_build_make.md) - [vcpkg\_build\_msbuild](vcpkg_build_msbuild.md) diff --git a/docs/maintainers/vcpkg_backup_restore_env_vars.md b/docs/maintainers/vcpkg_backup_restore_env_vars.md new file mode 100644 index 00000000000..d1591d06eb3 --- /dev/null +++ b/docs/maintainers/vcpkg_backup_restore_env_vars.md @@ -0,0 +1,26 @@ +# vcpkg_backup_restore_env_vars + +The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/maintainers/vcpkg_backup_restore_env_vars.md). + +Backup or restore the environment variables + +## Usage: +```cmake +vcpkg_backup_env_variables(VARS [...]) +vcpkg_restore_env_variables(VARS [...]) +``` + +### VARS +The variables to back up or restore. +These are placed in the parent scope, so you must backup and restore +from the same scope. + +## Notes +One must always call `vcpkg_backup_env_variables` before +`vcpkg_restore_env_variables`; however, `vcpkg_restore_env_variables` +does not change the back up variables, and so you may call `restore` +multiple times for one `backup`. + + +## Source +[scripts/cmake/vcpkg\_backup\_restore\_env\_vars.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_backup_restore_env_vars.cmake) diff --git a/ports/x264/portfile.cmake b/ports/x264/portfile.cmake index abd2f1d558a..b64c9ad6e55 100644 --- a/ports/x264/portfile.cmake +++ b/ports/x264/portfile.cmake @@ -17,8 +17,8 @@ get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY) vcpkg_add_to_path(${NASM_EXE_PATH}) if(VCPKG_TARGET_IS_WINDOWS) - _vcpkg_determine_autotools_host_cpu(BUILD_ARCH) - _vcpkg_determine_autotools_target_cpu(HOST_ARCH) + z_vcpkg_determine_autotools_host_cpu(BUILD_ARCH) + z_vcpkg_determine_autotools_target_cpu(HOST_ARCH) list(APPEND OPTIONS --build=${BUILD_ARCH}-pc-mingw32) list(APPEND OPTIONS --host=${HOST_ARCH}-pc-mingw32) set(ENV{AS} "${NASM}") diff --git a/ports/x264/vcpkg.json b/ports/x264/vcpkg.json index 128d8ccf410..41aa4b91809 100644 --- a/ports/x264/vcpkg.json +++ b/ports/x264/vcpkg.json @@ -1,7 +1,7 @@ { "name": "x264", "version-string": "157-303c484ec828ed0", - "port-version": 15, + "port-version": 16, "description": "x264 is a free software library and application for encoding video streams into the H.264/MPEG-4 AVC compression format", "homepage": "https://github.com/mirror/x264", "supports": "!arm", diff --git a/scripts/cmake/vcpkg_backup_restore_env_vars.cmake b/scripts/cmake/vcpkg_backup_restore_env_vars.cmake new file mode 100644 index 00000000000..d7eb5f38396 --- /dev/null +++ b/scripts/cmake/vcpkg_backup_restore_env_vars.cmake @@ -0,0 +1,59 @@ +#[===[.md: +# vcpkg_backup_restore_env_vars + +Backup or restore the environment variables + +## Usage: +```cmake +vcpkg_backup_env_variables(VARS [...]) +vcpkg_restore_env_variables(VARS [...]) +``` + +### VARS +The variables to back up or restore. +These are placed in the parent scope, so you must backup and restore +from the same scope. + +## Notes +One must always call `vcpkg_backup_env_variables` before +`vcpkg_restore_env_variables`; however, `vcpkg_restore_env_variables` +does not change the back up variables, and so you may call `restore` +multiple times for one `backup`. + +#]===] + +function(vcpkg_backup_env_variables) + cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "VARS") + if(NOT DEFINED arg_VARS) + message(FATAL_ERROR "VARS must be defined.") + endif() + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + + foreach(envvar IN LISTS arg_VARS) + if(DEFINED ENV{${envvar}}) + set("z_vcpkg_env_backup_${envvar}" "$ENV{${envvar}}" PARENT_SCOPE) + else() + unset("z_vcpkg_env_backup_${envvar}" PARENT_SCOPE) + endif() + endforeach() +endfunction() + +function(vcpkg_restore_env_variables) + cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "VARS") + if(NOT DEFINED arg_VARS) + message(FATAL_ERROR "VARS must be defined.") + endif() + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + + foreach(envvar IN LISTS arg_VARS) + if(DEFINED z_vcpkg_env_backup_${envvar}) + set("ENV{${envvar}}" "${z_vcpkg_env_backup_${envvar}}") + else() + unset("ENV{${envvar}}") + endif() + endforeach() +endfunction() diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index 18f857fcede..aa105fe6cd4 100755 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -55,48 +55,54 @@ function(vcpkg_build_make) include("${cmake_vars_file}") # parse parameters such that semicolons in options arguments to COMMAND don't get erased - cmake_parse_arguments(PARSE_ARGV 0 _bc "ADD_BIN_TO_PATH;ENABLE_INSTALL;DISABLE_PARALLEL" "LOGFILE_ROOT;BUILD_TARGET;SUBPATH;MAKEFILE;INSTALL_TARGET" "") + cmake_parse_arguments(PARSE_ARGV 0 arg + "ADD_BIN_TO_PATH;ENABLE_INSTALL;DISABLE_PARALLEL" + "LOGFILE_ROOT;BUILD_TARGET;SUBPATH;MAKEFILE;INSTALL_TARGET" + "OPTIONS" + ) - if(NOT _bc_LOGFILE_ROOT) - set(_bc_LOGFILE_ROOT "build") + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(WARNING "vcpkg_make_build was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") endif() - if(NOT _bc_BUILD_TARGET) - set(_bc_BUILD_TARGET "all") + if(NOT DEFINED arg_LOGFILE_ROOT) + set(arg_LOGFILE_ROOT "build") endif() - if (NOT _bc_MAKEFILE) - set(_bc_MAKEFILE Makefile) + if(NOT DEFINED arg_BUILD_TARGET) + set(arg_BUILD_TARGET "all") endif() - if(NOT _bc_INSTALL_TARGET) - set(_bc_INSTALL_TARGET "install") + if (NOT DEFINED arg_MAKEFILE) + set(arg_MAKEFILE Makefile) + endif() + + if(NOT DEFINED arg_INSTALL_TARGET) + set(arg_INSTALL_TARGET "install") endif() if(WIN32) - set(_VCPKG_PREFIX ${CURRENT_PACKAGES_DIR}) - set(_VCPKG_INSTALLED ${CURRENT_INSTALLED_DIR}) + set(Z_VCPKG_INSTALLED ${CURRENT_INSTALLED_DIR}) else() - string(REPLACE " " "\ " _VCPKG_PREFIX "${CURRENT_PACKAGES_DIR}") - string(REPLACE " " "\ " _VCPKG_INSTALLED "${CURRENT_INSTALLED_DIR}") + string(REPLACE " " "\ " Z_VCPKG_INSTALLED "${CURRENT_INSTALLED_DIR}") endif() - set(MAKE_OPTS ) - set(INSTALL_OPTS ) + vcpkg_list(SET make_opts) + vcpkg_list(SET install_opts) if (CMAKE_HOST_WIN32) - set(PATH_GLOBAL "$ENV{PATH}") + set(path_backup "$ENV{PATH}") vcpkg_add_to_path(PREPEND "${SCRIPTS}/buildsystems/make_wrapper") if(NOT DEFINED Z_VCPKG_MAKE) vcpkg_acquire_msys(MSYS_ROOT) find_program(Z_VCPKG_MAKE make PATHS "${MSYS_ROOT}/usr/bin" NO_DEFAULT_PATH REQUIRED) endif() - set(MAKE_COMMAND "${Z_VCPKG_MAKE}") - set(MAKE_OPTS ${_bc_MAKE_OPTIONS} -j ${VCPKG_CONCURRENCY} --trace -f ${_bc_MAKEFILE} ${_bc_BUILD_TARGET}) - set(NO_PARALLEL_MAKE_OPTS ${_bc_MAKE_OPTIONS} -j 1 --trace -f ${_bc_MAKEFILE} ${_bc_BUILD_TARGET}) + set(make_command "${Z_VCPKG_MAKE}") + vcpkg_list(SET make_opts ${arg_OPTIONS} ${arg_MAKE_OPTIONS} -j ${VCPKG_CONCURRENCY} --trace -f ${arg_MAKEFILE} ${arg_BUILD_TARGET}) + vcpkg_list(SET no_parallel_make_opts ${arg_OPTIONS} ${arg_MAKE_OPTIONS} -j 1 --trace -f ${arg_MAKEFILE} ${arg_BUILD_TARGET}) - string(REPLACE " " "\\\ " _VCPKG_PACKAGE_PREFIX ${CURRENT_PACKAGES_DIR}) - string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_PACKAGE_PREFIX "${_VCPKG_PACKAGE_PREFIX}") - set(INSTALL_OPTS -j ${VCPKG_CONCURRENCY} --trace -f ${_bc_MAKEFILE} ${_bc_INSTALL_TARGET} DESTDIR=${_VCPKG_PACKAGE_PREFIX}) + string(REPLACE " " [[\ ]] vcpkg_package_prefix "${CURRENT_PACKAGES_DIR}") + string(REGEX REPLACE [[([a-zA-Z]):/]] [[/\1/]] vcpkg_package_prefix "${vcpkg_package_prefix}") + vcpkg_list(SET install_opts -j ${VCPKG_CONCURRENCY} --trace -f ${arg_MAKEFILE} ${arg_INSTALL_TARGET} DESTDIR=${vcpkg_package_prefix}) #TODO: optimize for install-data (release) and install-exec (release/debug) else() if(VCPKG_HOST_IS_OPENBSD) @@ -104,144 +110,127 @@ function(vcpkg_build_make) else() find_program(Z_VCPKG_MAKE make REQUIRED) endif() - set(MAKE_COMMAND "${Z_VCPKG_MAKE}") - set(MAKE_OPTS ${_bc_MAKE_OPTIONS} V=1 -j ${VCPKG_CONCURRENCY} -f ${_bc_MAKEFILE} ${_bc_BUILD_TARGET}) - set(NO_PARALLEL_MAKE_OPTS ${_bc_MAKE_OPTIONS} V=1 -j 1 -f ${_bc_MAKEFILE} ${_bc_BUILD_TARGET}) - set(INSTALL_OPTS -j ${VCPKG_CONCURRENCY} -f ${_bc_MAKEFILE} ${_bc_INSTALL_TARGET} DESTDIR=${CURRENT_PACKAGES_DIR}) + set(make_command "${Z_VCPKG_MAKE}") + vcpkg_list(SET make_opts ${arg_MAKE_OPTIONS} V=1 -j ${VCPKG_CONCURRENCY} -f ${arg_MAKEFILE} ${arg_BUILD_TARGET}) + vcpkg_list(SET no_parallel_make_opts ${arg_MAKE_OPTIONS} V=1 -j 1 -f ${arg_MAKEFILE} ${arg_BUILD_TARGET}) + vcpkg_list(SET install_opts -j ${VCPKG_CONCURRENCY} -f ${arg_MAKEFILE} ${arg_INSTALL_TARGET} DESTDIR=${CURRENT_PACKAGES_DIR}) endif() # Since includes are buildtype independent those are setup by vcpkg_configure_make - _vcpkg_backup_env_variables(LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) + vcpkg_backup_env_variables(VARS LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) - foreach(BUILDTYPE "debug" "release") - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL BUILDTYPE) - if(BUILDTYPE STREQUAL "debug") - # Skip debug generate - if (_VCPKG_NO_DEBUG) - continue() - endif() - set(SHORT_BUILDTYPE "-dbg") - set(CMAKE_BUILDTYPE "DEBUG") - set(PATH_SUFFIX "/debug") + foreach(buildtype IN ITEMS "debug" "release") + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "${buildtype}") + if("${buildtype}" STREQUAL "debug") + set(short_buildtype "-dbg") + set(cmake_buildtype "DEBUG") + set(path_suffix "/debug") else() # In NO_DEBUG mode, we only use ${TARGET_TRIPLET} directory. - if (_VCPKG_NO_DEBUG) - set(SHORT_BUILDTYPE "") - else() - set(SHORT_BUILDTYPE "-rel") - endif() - set(CMAKE_BUILDTYPE "RELEASE") - set(PATH_SUFFIX "") + set(short_buildtype "-rel") + set(cmake_buildtype "RELEASE") + set(path_suffix "") endif() - set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}${_bc_SUBPATH}") - message(STATUS "Building ${TARGET_TRIPLET}${SHORT_BUILDTYPE}") + set(working_directory "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${short_buildtype}${arg_SUBPATH}") + message(STATUS "Building ${TARGET_TRIPLET}${short_buildtype}") - _vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags(${CMAKE_BUILDTYPE}) + z_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags("${cmake_buildtype}") if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") - set(LINKER_FLAGS_${CMAKE_BUILDTYPE} "${VCPKG_DETECTED_STATIC_LINKER_FLAGS_${CMAKE_BUILDTYPE}}") + set(LINKER_FLAGS_${cmake_buildtype} "${VCPKG_DETECTED_STATIC_LINKER_FLAGS_${cmake_buildtype}}") else() # dynamic - set(LINKER_FLAGS_${CMAKE_BUILDTYPE} "${VCPKG_DETECTED_SHARED_LINKER_FLAGS_${CMAKE_BUILDTYPE}}") + set(LINKER_FLAGS_${cmake_buildtype} "${VCPKG_DETECTED_SHARED_LINKER_FLAGS_${cmake_buildtype}}") endif() - if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_C_COMPILER MATCHES "cl.exe") - set(LDFLAGS_${CMAKE_BUILDTYPE} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/manual-link") - set(LINK_ENV_${CMAKE_BUILDTYPE} "$ENV{_LINK_} ${LINKER_FLAGS_${CMAKE_BUILDTYPE}}") + if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe") + set(LDFLAGS_${cmake_buildtype} "-L${Z_VCPKG_INSTALLED}${path_suffix}/lib -L${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link") + set(LINK_ENV_${cmake_buildtype} "$ENV{_LINK_} ${LINKER_FLAGS_${cmake_buildtype}}") else() - set(LDFLAGS_${CMAKE_BUILDTYPE} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/manual-link ${LINKER_FLAGS_${CMAKE_BUILDTYPE}}") + set(LDFLAGS_${cmake_buildtype} "-L${Z_VCPKG_INSTALLED}${path_suffix}/lib -L${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link ${LINKER_FLAGS_${cmake_buildtype}}") endif() # Setup environment - set(ENV{CPPFLAGS} "${CPPFLAGS_${CMAKE_BUILDTYPE}}") - set(ENV{CFLAGS} "${CFLAGS_${CMAKE_BUILDTYPE}}") - set(ENV{CXXFLAGS} "${CXXFLAGS_${CMAKE_BUILDTYPE}}") - set(ENV{RCFLAGS} "${VCPKG_DETECTED_CMAKE_RC_FLAGS_${CMAKE_BUILDTYPE}}") - set(ENV{LDFLAGS} "${LDFLAGS_${CMAKE_BUILDTYPE}}") - set(ENV{LIB} "${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/manual-link/${LIB_PATHLIKE_CONCAT}") - set(ENV{LIBPATH} "${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/manual-link/${LIBPATH_PATHLIKE_CONCAT}") - set(ENV{LIBRARY_PATH} "${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/manual-link/${LIBRARY_PATH_PATHLIKE_CONCAT}") - #set(ENV{LD_LIBRARY_PATH} "${_VCPKG_INSTALLED}${PATH_SUFFIX_${BUILDTYPE}}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}${PATH_SUFFIX_${BUILDTYPE}}/lib/manual-link/${LD_LIBRARY_PATH_PATHLIKE_CONCAT}") + set(ENV{CPPFLAGS} "${CPPFLAGS_${cmake_buildtype}}") + set(ENV{CFLAGS} "${CFLAGS_${cmake_buildtype}}") + set(ENV{CXXFLAGS} "${CXXFLAGS_${cmake_buildtype}}") + set(ENV{RCFLAGS} "${VCPKG_DETECTED_CMAKE_RC_FLAGS_${cmake_buildtype}}") + set(ENV{LDFLAGS} "${LDFLAGS_${cmake_buildtype}}") + vcpkg_host_path_list(PREPEND ENV{LIB} "${Z_VCPKG_INSTALLED}${path_suffix}/lib/" "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link/") + vcpkg_host_path_list(PREPEND ENV{LIBPATH} "${Z_VCPKG_INSTALLED}${path_suffix}/lib/" "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link/") + vcpkg_host_path_list(PREPEND ENV{LIBRARY_PATH} "${Z_VCPKG_INSTALLED}${path_suffix_${buildtype}}/lib/" "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link/") + #vcpkg_host_path_list(PREPEND ENV{LD_LIBRARY_PATH} "${Z_VCPKG_INSTALLED}${path_suffix}/lib/" "${Z_VCPKG_INSTALLED}${path_suffix_${buildtype}}/lib/manual-link/") if(LINK_ENV_${_VAR_SUFFIX}) - set(_LINK_CONFIG_BACKUP "$ENV{_LINK_}") + set(config_link_backup "$ENV{_LINK_}") set(ENV{_LINK_} "${LINK_ENV_${_VAR_SUFFIX}}") endif() - if(_bc_ADD_BIN_TO_PATH) - set(_BACKUP_ENV_PATH "$ENV{PATH}") - vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX}/bin") + if(arg_ADD_BIN_TO_PATH) + set(env_backup_path "$ENV{PATH}") + vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${path_suffix}/bin") endif() - if(MAKE_BASH) - set(MAKE_CMD_LINE "${MAKE_COMMAND} ${MAKE_OPTS}") - set(NO_PARALLEL_MAKE_CMD_LINE "${MAKE_COMMAND} ${NO_PARALLEL_MAKE_OPTS}") - else() - set(MAKE_CMD_LINE ${MAKE_COMMAND} ${MAKE_OPTS}) - set(NO_PARALLEL_MAKE_CMD_LINE ${MAKE_COMMAND} ${NO_PARALLEL_MAKE_OPTS}) - endif() + vcpkg_list(SET make_cmd_line ${make_command} ${make_opts}) + vcpkg_list(SET no_parallel_make_cmd_line ${make_command} ${no_parallel_make_opts}) - if (_bc_DISABLE_PARALLEL) + if (arg_DISABLE_PARALLEL) vcpkg_execute_build_process( - COMMAND ${MAKE_BASH} ${NO_PARALLEL_MAKE_CMD_LINE} - WORKING_DIRECTORY "${WORKING_DIRECTORY}" - LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}" + COMMAND ${no_parallel_make_cmd_line} + WORKING_DIRECTORY "${working_directory}" + LOGNAME "${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}${short_buildtype}" ) else() vcpkg_execute_build_process( - COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE} - NO_PARALLEL_COMMAND ${MAKE_BASH} ${NO_PARALLEL_MAKE_CMD_LINE} - WORKING_DIRECTORY "${WORKING_DIRECTORY}" - LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}" + COMMAND ${make_cmd_line} + NO_PARALLEL_COMMAND ${no_parallel_make_cmd_line} + WORKING_DIRECTORY "${working_directory}" + LOGNAME "${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}${short_buildtype}" ) endif() - file(READ "${CURRENT_BUILDTREES_DIR}/${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}-out.log" LOGDATA) - if(LOGDATA MATCHES "Warning: linker path does not have real file for library") + file(READ "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_ROOT}-${TARGET_TRIPLET}${short_buildtype}-out.log" logdata) + if(logdata MATCHES "Warning: linker path does not have real file for library") message(FATAL_ERROR "libtool could not find a file being linked against!") endif() - if (_bc_ENABLE_INSTALL) - message(STATUS "Installing ${TARGET_TRIPLET}${SHORT_BUILDTYPE}") - if(MAKE_BASH) - set(MAKE_CMD_LINE "${MAKE_COMMAND} ${INSTALL_OPTS}") - else() - set(MAKE_CMD_LINE ${MAKE_COMMAND} ${INSTALL_OPTS}) - endif() + if (arg_ENABLE_INSTALL) + message(STATUS "Installing ${TARGET_TRIPLET}${short_buildtype}") + vcpkg_list(SET make_cmd_line ${make_command} ${install_opts}) vcpkg_execute_build_process( - COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE} - WORKING_DIRECTORY "${WORKING_DIRECTORY}" - LOGNAME "install-${TARGET_TRIPLET}${SHORT_BUILDTYPE}" + COMMAND ${make_cmd_line} + WORKING_DIRECTORY "${working_directory}" + LOGNAME "install-${TARGET_TRIPLET}${short_buildtype}" ) endif() - if(_LINK_CONFIG_BACKUP) - set(ENV{_LINK_} "${_LINK_CONFIG_BACKUP}") - unset(_LINK_CONFIG_BACKUP) + if(config_link_backup) + set(ENV{_LINK_} "${config_link_backup}") + unset(config_link_backup) endif() - if(_bc_ADD_BIN_TO_PATH) - set(ENV{PATH} "${_BACKUP_ENV_PATH}") + if(arg_ADD_BIN_TO_PATH) + set(ENV{PATH} "${env_backup_path}") endif() endif() endforeach() - if (_bc_ENABLE_INSTALL) - string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_INSTALL_PREFIX "${CURRENT_INSTALLED_DIR}") + if (arg_ENABLE_INSTALL) + string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" Z_VCPKG_INSTALL_PREFIX "${CURRENT_INSTALLED_DIR}") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}_tmp") file(RENAME "${CURRENT_PACKAGES_DIR}" "${CURRENT_PACKAGES_DIR}_tmp") - file(RENAME "${CURRENT_PACKAGES_DIR}_tmp${_VCPKG_INSTALL_PREFIX}" "${CURRENT_PACKAGES_DIR}") + file(RENAME "${CURRENT_PACKAGES_DIR}_tmp${Z_VCPKG_INSTALL_PREFIX}" "${CURRENT_PACKAGES_DIR}") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}_tmp") endif() # Remove libtool files since they contain absolute paths and are not necessary. - file(GLOB_RECURSE LIBTOOL_FILES "${CURRENT_PACKAGES_DIR}/**/*.la") - if(LIBTOOL_FILES) - file(REMOVE ${LIBTOOL_FILES}) + file(GLOB_RECURSE libtool_files "${CURRENT_PACKAGES_DIR}/**/*.la") + if(libtool_files) + file(REMOVE ${libtool_files}) endif() if (CMAKE_HOST_WIN32) - set(ENV{PATH} "${PATH_GLOBAL}") + set(ENV{PATH} "${path_backup}") endif() - _vcpkg_restore_env_variables(LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) + vcpkg_restore_env_variables(VARS LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) endfunction() diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index c8bdcb554b2..da0fd2aad39 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -89,46 +89,46 @@ This command supplies many common arguments to configure. To see the full list, * [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake) #]===] -macro(_vcpkg_determine_host_mingw out_var) +macro(z_vcpkg_determine_host_mingw out_var) if(DEFINED ENV{PROCESSOR_ARCHITEW6432}) - set(HOST_ARCH $ENV{PROCESSOR_ARCHITEW6432}) + set(host_arch $ENV{PROCESSOR_ARCHITEW6432}) else() - set(HOST_ARCH $ENV{PROCESSOR_ARCHITECTURE}) + set(host_arch $ENV{PROCESSOR_ARCHITECTURE}) endif() - if(HOST_ARCH MATCHES "(amd|AMD)64") + if(host_arch MATCHES "(amd|AMD)64") set(${out_var} mingw64) - elseif(HOST_ARCH MATCHES "(x|X)86") + elseif(host_arch MATCHES "(x|X)86") set(${out_var} mingw32) else() - message(FATAL_ERROR "Unsupported mingw architecture ${HOST_ARCH} in _vcpkg_determine_autotools_host_cpu!" ) + message(FATAL_ERROR "Unsupported mingw architecture ${host_arch} in z_vcpkg_determine_autotools_host_cpu!" ) endif() - unset(HOST_ARCH) + unset(host_arch) endmacro() -macro(_vcpkg_determine_autotools_host_cpu out_var) +macro(z_vcpkg_determine_autotools_host_cpu out_var) # TODO: the host system processor architecture can differ from the host triplet target architecture if(DEFINED ENV{PROCESSOR_ARCHITEW6432}) - set(HOST_ARCH $ENV{PROCESSOR_ARCHITEW6432}) + set(host_arch $ENV{PROCESSOR_ARCHITEW6432}) elseif(DEFINED ENV{PROCESSOR_ARCHITECTURE}) - set(HOST_ARCH $ENV{PROCESSOR_ARCHITECTURE}) + set(host_arch $ENV{PROCESSOR_ARCHITECTURE}) else() - set(HOST_ARCH "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}") + set(host_arch "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}") endif() - if(HOST_ARCH MATCHES "(amd|AMD)64") + if(host_arch MATCHES "(amd|AMD)64") set(${out_var} x86_64) - elseif(HOST_ARCH MATCHES "(x|X)86") + elseif(host_arch MATCHES "(x|X)86") set(${out_var} i686) - elseif(HOST_ARCH MATCHES "^(ARM|arm)64$") + elseif(host_arch MATCHES "^(ARM|arm)64$") set(${out_var} aarch64) - elseif(HOST_ARCH MATCHES "^(ARM|arm)$") + elseif(host_arch MATCHES "^(ARM|arm)$") set(${out_var} arm) else() - message(FATAL_ERROR "Unsupported host architecture ${HOST_ARCH} in _vcpkg_determine_autotools_host_cpu!" ) + message(FATAL_ERROR "Unsupported host architecture ${host_arch} in z_vcpkg_determine_autotools_host_cpu!" ) endif() - unset(HOST_ARCH) + unset(host_arch) endmacro() -macro(_vcpkg_determine_autotools_target_cpu out_var) +macro(z_vcpkg_determine_autotools_target_cpu out_var) if(VCPKG_TARGET_ARCHITECTURE MATCHES "(x|X)64") set(${out_var} x86_64) elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "(x|X)86") @@ -138,19 +138,19 @@ macro(_vcpkg_determine_autotools_target_cpu out_var) elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)$") set(${out_var} arm) else() - message(FATAL_ERROR "Unsupported VCPKG_TARGET_ARCHITECTURE architecture ${VCPKG_TARGET_ARCHITECTURE} in _vcpkg_determine_autotools_target_cpu!" ) + message(FATAL_ERROR "Unsupported VCPKG_TARGET_ARCHITECTURE architecture ${VCPKG_TARGET_ARCHITECTURE} in z_vcpkg_determine_autotools_target_cpu!" ) endif() endmacro() -macro(_vcpkg_determine_autotools_host_arch_mac out_var) +macro(z_vcpkg_determine_autotools_host_arch_mac out_var) set(${out_var} "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}") endmacro() -macro(_vcpkg_determine_autotools_target_arch_mac out_var) - list(LENGTH VCPKG_OSX_ARCHITECTURES _num_osx_archs) - if(_num_osx_archs EQUAL 0) +macro(z_vcpkg_determine_autotools_target_arch_mac out_var) + list(LENGTH VCPKG_OSX_ARCHITECTURES osx_archs_num) + if(osx_archs_num EQUAL 0) set(${out_var} "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}") - elseif(_num_osx_archs GREATER_EQUAL 2) + elseif(osx_archs_num GREATER_EQUAL 2) set(${out_var} "universal") else() # Better match the arch behavior of config.guess @@ -161,128 +161,125 @@ macro(_vcpkg_determine_autotools_target_arch_mac out_var) set(${out_var} "${VCPKG_OSX_ARCHITECTURES}") endif() endif() - unset(_num_osx_archs) + unset(osx_archs_num) endmacro() -macro(_vcpkg_backup_env_variable envvar) - if(DEFINED ENV{${envvar}}) - set(${envvar}_BACKUP "$ENV{${envvar}}") - set(${envvar}_PATHLIKE_CONCAT "${VCPKG_HOST_PATH_SEPARATOR}$ENV{${envvar}}") - else() - set(${envvar}_BACKUP) - set(${envvar}_PATHLIKE_CONCAT) - endif() -endmacro() - -macro(_vcpkg_backup_env_variables) - foreach(_var ${ARGV}) - _vcpkg_backup_env_variable(${_var}) - endforeach() -endmacro() - -macro(_vcpkg_restore_env_variable envvar) - if(${envvar}_BACKUP) - set(ENV{${envvar}} "${${envvar}_BACKUP}") - else() - unset(ENV{${envvar}}) - endif() -endmacro() - -macro(_vcpkg_restore_env_variables) - foreach(_var ${ARGV}) - _vcpkg_restore_env_variable(${_var}) - endforeach() -endmacro() - -macro(_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags _SUFFIX) - string(REGEX MATCHALL "( |^)-D[^ ]+" CPPFLAGS_${_SUFFIX} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${_SUFFIX}}") - string(REGEX MATCHALL "( |^)-D[^ ]+" CXXPPFLAGS_${_SUFFIX} "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${_SUFFIX}}") - list(JOIN CXXPPFLAGS_${_SUFFIX} "|" CXXREGEX) +macro(z_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags flag_suffix) + string(REGEX MATCHALL "( |^)-D[^ ]+" CPPFLAGS_${flag_suffix} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${flag_suffix}}") + string(REGEX MATCHALL "( |^)-D[^ ]+" CXXPPFLAGS_${flag_suffix} "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${flag_suffix}}") + list(JOIN CXXPPFLAGS_${flag_suffix} "|" CXXREGEX) if(CXXREGEX) - list(FILTER CPPFLAGS_${_SUFFIX} INCLUDE REGEX "(${CXXREGEX})") + list(FILTER CPPFLAGS_${flag_suffix} INCLUDE REGEX "(${CXXREGEX})") else() - set(CPPFLAGS_${_SUFFIX}) + set(CPPFLAGS_${flag_suffix}) endif() - list(JOIN CPPFLAGS_${_SUFFIX} "|" CPPREGEX) - list(JOIN CPPFLAGS_${_SUFFIX} " " CPPFLAGS_${_SUFFIX}) - set(CPPFLAGS_${_SUFFIX} "${CPPFLAGS_${_SUFFIX}}") + list(JOIN CPPFLAGS_${flag_suffix} "|" CPPREGEX) + list(JOIN CPPFLAGS_${flag_suffix} " " CPPFLAGS_${flag_suffix}) + set(CPPFLAGS_${flag_suffix} "${CPPFLAGS_${flag_suffix}}") if(CPPREGEX) - string(REGEX REPLACE "(${CPPREGEX})" "" CFLAGS_${_SUFFIX} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${_SUFFIX}}") - string(REGEX REPLACE "(${CPPREGEX})" "" CXXFLAGS_${_SUFFIX} "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${_SUFFIX}}") + string(REGEX REPLACE "(${CPPREGEX})" "" CFLAGS_${flag_suffix} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${flag_suffix}}") + string(REGEX REPLACE "(${CPPREGEX})" "" CXXFLAGS_${flag_suffix} "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${flag_suffix}}") else() - set(CFLAGS_${_SUFFIX} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${_SUFFIX}}") - set(CXXFLAGS_${_SUFFIX} "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${_SUFFIX}}") + set(CFLAGS_${flag_suffix} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${flag_suffix}}") + set(CXXFLAGS_${flag_suffix} "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${flag_suffix}}") endif() - string(REGEX REPLACE " +" " " CPPFLAGS_${_SUFFIX} "${CPPFLAGS_${_SUFFIX}}") - string(REGEX REPLACE " +" " " CFLAGS_${_SUFFIX} "${CFLAGS_${_SUFFIX}}") - string(REGEX REPLACE " +" " " CXXFLAGS_${_SUFFIX} "${CXXFLAGS_${_SUFFIX}}") + string(REGEX REPLACE " +" " " CPPFLAGS_${flag_suffix} "${CPPFLAGS_${flag_suffix}}") + string(REGEX REPLACE " +" " " CFLAGS_${flag_suffix} "${CFLAGS_${flag_suffix}}") + string(REGEX REPLACE " +" " " CXXFLAGS_${flag_suffix} "${CXXFLAGS_${flag_suffix}}") # libtool has and -R option so we need to guard against -RTC by using -Xcompiler # while configuring there might be a lot of unknown compiler option warnings due to that # just ignore them. - string(REGEX REPLACE "((-|/)RTC[^ ]+)" "-Xcompiler \\1" CFLAGS_${_SUFFIX} "${CFLAGS_${_SUFFIX}}") - string(REGEX REPLACE "((-|/)RTC[^ ]+)" "-Xcompiler \\1" CXXFLAGS_${_SUFFIX} "${CXXFLAGS_${_SUFFIX}}") - string(STRIP "${CPPFLAGS_${_SUFFIX}}" CPPFLAGS_${_SUFFIX}) - string(STRIP "${CFLAGS_${_SUFFIX}}" CFLAGS_${_SUFFIX}) - string(STRIP "${CXXFLAGS_${_SUFFIX}}" CXXFLAGS_${_SUFFIX}) - debug_message("CPPFLAGS_${_SUFFIX}: ${CPPFLAGS_${_SUFFIX}}") - debug_message("CFLAGS_${_SUFFIX}: ${CFLAGS_${_SUFFIX}}") - debug_message("CXXFLAGS_${_SUFFIX}: ${CXXFLAGS_${_SUFFIX}}") + string(REGEX REPLACE "((-|/)RTC[^ ]+)" "-Xcompiler \\1" CFLAGS_${flag_suffix} "${CFLAGS_${flag_suffix}}") + string(REGEX REPLACE "((-|/)RTC[^ ]+)" "-Xcompiler \\1" CXXFLAGS_${flag_suffix} "${CXXFLAGS_${flag_suffix}}") + string(STRIP "${CPPFLAGS_${flag_suffix}}" CPPFLAGS_${flag_suffix}) + string(STRIP "${CFLAGS_${flag_suffix}}" CFLAGS_${flag_suffix}) + string(STRIP "${CXXFLAGS_${flag_suffix}}" CXXFLAGS_${flag_suffix}) + debug_message("CPPFLAGS_${flag_suffix}: ${CPPFLAGS_${flag_suffix}}") + debug_message("CFLAGS_${flag_suffix}: ${CFLAGS_${flag_suffix}}") + debug_message("CXXFLAGS_${flag_suffix}: ${CXXFLAGS_${flag_suffix}}") +endmacro() + +macro(z_vcpkg_append_to_configure_environment inoutstring var defaultval) + # Allows to overwrite settings in custom triplets via the environment on windows + if(CMAKE_HOST_WIN32 AND DEFINED ENV{${var}}) + string(APPEND ${inoutstring} " ${var}='$ENV{${var}}'") + else() + string(APPEND ${inoutstring} " ${var}='${defaultval}'") + endif() +endmacro() + +# Setup include environment (since these are buildtype independent restoring them is unnecessary) +macro(z_prepend_include_path var) + unset(ENV{${var}}) + if(NOT DEFINED z_vcpkg_env_backup_${var} OR "${z_vcpkg_env_backup_${var}}" STREQUAL "") + vcpkg_host_path_list(APPEND ENV{${var}} "${CURRENT_INSTALLED_DIR}/include") + else() + foreach (one_bk IN ITEMS ${z_vcpkg_env_backup_${var}}) + vcpkg_host_path_list(PREPEND ENV{${var}} "${one_bk}") + endforeach() + vcpkg_host_path_list(PREPEND ENV{${var}} "${CURRENT_INSTALLED_DIR}/include") + endif() +endmacro() + +macro(z_convert_to_list input output) + string(REGEX MATCHALL "(( +|^ *)[^ ]+)" ${output} "${${input}}") endmacro() function(vcpkg_configure_make) # parse parameters such that semicolons in options arguments to COMMAND don't get erased - cmake_parse_arguments(PARSE_ARGV 0 _csc + cmake_parse_arguments(PARSE_ARGV 0 arg "AUTOCONFIG;SKIP_CONFIGURE;COPY_SOURCE;DISABLE_VERBOSE_FLAGS;NO_ADDITIONAL_PATHS;ADD_BIN_TO_PATH;USE_WRAPPERS;DETERMINE_BUILD_TRIPLET" "SOURCE_PATH;PROJECT_SUBPATH;PRERUN_SHELL;BUILD_TRIPLET" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;CONFIGURE_ENVIRONMENT_VARIABLES;CONFIG_DEPENDENT_ENVIRONMENT;ADDITIONAL_MSYS_PACKAGES" ) + z_vcpkg_get_cmake_vars(cmake_vars_file) debug_message("Including cmake vars from: ${cmake_vars_file}") include("${cmake_vars_file}") if(DEFINED VCPKG_MAKE_BUILD_TRIPLET) - set(_csc_BUILD_TRIPLET ${VCPKG_MAKE_BUILD_TRIPLET}) # Triplet overwrite for crosscompiling + set(arg_BUILD_TRIPLET ${VCPKG_MAKE_BUILD_TRIPLET}) # Triplet overwrite for crosscompiling endif() - set(SRC_DIR "${_csc_SOURCE_PATH}/${_csc_PROJECT_SUBPATH}") + set(src_dir "${arg_SOURCE_PATH}/${arg_PROJECT_SUBPATH}") - set(REQUIRES_AUTOGEN FALSE) # use autogen.sh - set(REQUIRES_AUTOCONFIG FALSE) # use autotools and configure.ac - if(EXISTS "${SRC_DIR}/configure" AND "${SRC_DIR}/configure.ac") # remove configure; rerun autoconf + set(requires_autogen OFF) # use autogen.sh + set(requires_autoconfig OFF) # use autotools and configure.ac + if(EXISTS "${src_dir}/configure" AND "${src_dir}/configure.ac") # remove configure; rerun autoconf if(NOT VCPKG_MAINTAINER_SKIP_AUTOCONFIG) # If fixing bugs skipping autoconfig saves a lot of time - set(REQUIRES_AUTOCONFIG TRUE) + set(requires_autoconfig ON) file(REMOVE "${SRC_DIR}/configure") # remove possible autodated configure scripts - set(_csc_AUTOCONFIG ON) + set(arg_AUTOCONFIG ON) endif() - elseif(EXISTS "${SRC_DIR}/configure" AND NOT _csc_SKIP_CONFIGURE) # run normally; no autoconf or autgen required - elseif(EXISTS "${SRC_DIR}/configure.ac") # Run autoconfig - set(REQUIRES_AUTOCONFIG TRUE) - set(_csc_AUTOCONFIG ON) - elseif(EXISTS "${SRC_DIR}/autogen.sh") # Run autogen - set(REQUIRES_AUTOGEN TRUE) + elseif(EXISTS "${src_dir}/configure" AND NOT arg_SKIP_CONFIGURE) # run normally; no autoconf or autogen required + elseif(EXISTS "${src_dir}/configure.ac") # Run autoconfig + set(requires_autoconfig ON) + set(arg_AUTOCONFIG ON) + elseif(EXISTS "${src_dir}/autogen.sh") # Run autogen + set(requires_autogen ON) else() message(FATAL_ERROR "Could not determine method to configure make") endif() - debug_message("REQUIRES_AUTOGEN:${REQUIRES_AUTOGEN}") - debug_message("REQUIRES_AUTOCONFIG:${REQUIRES_AUTOCONFIG}") + debug_message("requires_autogen:${requires_autogen}") + debug_message("requires_autoconfig:${requires_autoconfig}") if(CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe") #only applies to windows (clang-)cl and lib - if(_csc_AUTOCONFIG) - set(_csc_USE_WRAPPERS TRUE) + if(arg_AUTOCONFIG) + set(arg_USE_WRAPPERS ON) else() # Keep the setting from portfiles. # Without autotools we assume a custom configure script which correctly handles cl and lib. # Otherwise the port needs to set CC|CXX|AR and probably CPP. endif() else() - set(_csc_USE_WRAPPERS FALSE) + set(arg_USE_WRAPPERS OFF) endif() # Backup environment variables # CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJCXX R UPC Y - set(_cm_FLAGS AS CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJXX R UPC Y RC) - list(TRANSFORM _cm_FLAGS APPEND "FLAGS") - _vcpkg_backup_env_variables(${_cm_FLAGS}) + set(cm_FLAGS AS CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJXX R UPC Y RC) + list(TRANSFORM cm_FLAGS APPEND "FLAGS") + vcpkg_backup_env_variables(VARS ${cm_FLAGS}) # FC fotran compiler | FF Fortran 77 compiler @@ -290,68 +287,59 @@ function(vcpkg_configure_make) # LIBS -> pass -l flags #Used by gcc/linux - _vcpkg_backup_env_variables(C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH) + vcpkg_backup_env_variables(VARS C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH) #Used by cl - _vcpkg_backup_env_variables(INCLUDE LIB LIBPATH) + vcpkg_backup_env_variables(VARS INCLUDE LIB LIBPATH) - set(_vcm_paths_with_spaces FALSE) + set(vcm_paths_with_spaces OFF) if(CURRENT_PACKAGES_DIR MATCHES " " OR CURRENT_INSTALLED_DIR MATCHES " ") # Don't bother with whitespace. The tools will probably fail and I tried very hard trying to make it work (no success so far)! message(WARNING "Detected whitespace in root directory. Please move the path to one without whitespaces! The required tools do not handle whitespaces correctly and the build will most likely fail") - set(_vcm_paths_with_spaces TRUE) + set(vcm_paths_with_spaces ON) endif() - set(CONFIGURE_ENV "V=1") + set(configure_env "V=1") # Pre-processing windows configure requirements if (VCPKG_TARGET_IS_WINDOWS) if(CMAKE_HOST_WIN32) - list(APPEND MSYS_REQUIRE_PACKAGES binutils libtool autoconf automake-wrapper automake1.16 m4) - vcpkg_acquire_msys(MSYS_ROOT PACKAGES ${MSYS_REQUIRE_PACKAGES} ${_csc_ADDITIONAL_MSYS_PACKAGES}) + list(APPEND msys_require_packages binutils libtool autoconf automake-wrapper automake1.16 m4) + vcpkg_acquire_msys(MSYS_ROOT PACKAGES ${msys_require_packages} ${arg_ADDITIONAL_MSYS_PACKAGES}) endif() - if (_csc_AUTOCONFIG AND NOT _csc_BUILD_TRIPLET OR _csc_DETERMINE_BUILD_TRIPLET OR VCPKG_CROSSCOMPILING AND NOT _csc_BUILD_TRIPLET) - _vcpkg_determine_autotools_host_cpu(BUILD_ARCH) # VCPKG_HOST => machine you are building on => --build= - _vcpkg_determine_autotools_target_cpu(TARGET_ARCH) + if (arg_AUTOCONFIG AND NOT arg_BUILD_TRIPLET OR arg_DETERMINE_BUILD_TRIPLET OR VCPKG_CROSSCOMPILING AND NOT arg_BUILD_TRIPLET) + z_vcpkg_determine_autotools_host_cpu(BUILD_ARCH) # VCPKG_HOST => machine you are building on => --build= + z_vcpkg_determine_autotools_target_cpu(TARGET_ARCH) # --build: the machine you are building on # --host: the machine you are building for # --target: the machine that CC will produce binaries for # https://stackoverflow.com/questions/21990021/how-to-determine-host-value-for-configure-when-using-cross-compiler # Only for ports using autotools so we can assume that they follow the common conventions for build/target/host if(CMAKE_HOST_WIN32) - set(_csc_BUILD_TRIPLET "--build=${BUILD_ARCH}-pc-mingw32") # This is required since we are running in a msys + set(arg_BUILD_TRIPLET "--build=${BUILD_ARCH}-pc-mingw32") # This is required since we are running in a msys # shell which will be otherwise identified as ${BUILD_ARCH}-pc-msys endif() if(NOT TARGET_ARCH MATCHES "${BUILD_ARCH}" OR NOT CMAKE_HOST_WIN32) # we don't need to specify the additional flags if we build nativly, this does not hold when we are not on windows - string(APPEND _csc_BUILD_TRIPLET " --host=${TARGET_ARCH}-pc-mingw32") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target) + string(APPEND arg_BUILD_TRIPLET " --host=${TARGET_ARCH}-pc-mingw32") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target) endif() - if(VCPKG_TARGET_IS_UWP AND NOT _csc_BUILD_TRIPLET MATCHES "--host") + if(VCPKG_TARGET_IS_UWP AND NOT arg_BUILD_TRIPLET MATCHES "--host") # Needs to be different from --build to enable cross builds. - string(APPEND _csc_BUILD_TRIPLET " --host=${TARGET_ARCH}-unknown-mingw32") + string(APPEND arg_BUILD_TRIPLET " --host=${TARGET_ARCH}-unknown-mingw32") endif() - debug_message("Using make triplet: ${_csc_BUILD_TRIPLET}") + debug_message("Using make triplet: ${arg_BUILD_TRIPLET}") endif() if(CMAKE_HOST_WIN32) - set(APPEND_ENV) - if(_csc_USE_WRAPPERS) - set(APPEND_ENV ";${MSYS_ROOT}/usr/share/automake-1.16") - string(APPEND APPEND_ENV ";${SCRIPTS}/buildsystems/make_wrapper") # Other required wrappers are also located there + set(append_env) + if(arg_USE_WRAPPERS) + set(append_env ";${MSYS_ROOT}/usr/share/automake-1.16") + string(APPEND append_env ";${SCRIPTS}/buildsystems/make_wrapper") # Other required wrappers are also located there endif() # This inserts msys before system32 (which masks sort.exe and find.exe) but after MSVC (which avoids masking link.exe) - string(REPLACE ";$ENV{SystemRoot}\\System32;" "${APPEND_ENV};${MSYS_ROOT}/usr/bin;$ENV{SystemRoot}\\System32;" NEWPATH "$ENV{PATH}") - string(REPLACE ";$ENV{SystemRoot}\\system32;" "${APPEND_ENV};${MSYS_ROOT}/usr/bin;$ENV{SystemRoot}\\system32;" NEWPATH "$ENV{PATH}") + string(REPLACE ";$ENV{SystemRoot}\\System32;" "${append_env};${MSYS_ROOT}/usr/bin;$ENV{SystemRoot}\\System32;" NEWPATH "$ENV{PATH}") + string(REPLACE ";$ENV{SystemRoot}\\system32;" "${append_env};${MSYS_ROOT}/usr/bin;$ENV{SystemRoot}\\system32;" NEWPATH "$ENV{PATH}") set(ENV{PATH} "${NEWPATH}") - set(BASH "${MSYS_ROOT}/usr/bin/bash.exe") + set(bash_executable "${MSYS_ROOT}/usr/bin/bash.exe") endif() - macro(_vcpkg_append_to_configure_environment inoutstring var defaultval) - # Allows to overwrite settings in custom triplets via the environment on windows - if(CMAKE_HOST_WIN32 AND DEFINED ENV{${var}}) - string(APPEND ${inoutstring} " ${var}='$ENV{${var}}'") - else() - string(APPEND ${inoutstring} " ${var}='${defaultval}'") - endif() - endmacro() - # Remove full filepaths due to spaces and prepend filepaths to PATH (cross-compiling tools are unlikely on path by default) set(progs VCPKG_DETECTED_CMAKE_C_COMPILER VCPKG_DETECTED_CMAKE_CXX_COMPILER VCPKG_DETECTED_CMAKE_AR VCPKG_DETECTED_CMAKE_LINKER VCPKG_DETECTED_CMAKE_RANLIB VCPKG_DETECTED_CMAKE_OBJDUMP @@ -368,66 +356,66 @@ function(vcpkg_configure_make) endif() endif() endforeach() - if (_csc_USE_WRAPPERS) - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER} -E") + if (arg_USE_WRAPPERS) + z_vcpkg_append_to_configure_environment(configure_env CPP "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER} -E") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER}") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC_FOR_BUILD "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER}") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "compile ${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV RC "windres-rc ${VCPKG_DETECTED_CMAKE_RC_COMPILER}") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV WINDRES "windres-rc ${VCPKG_DETECTED_CMAKE_RC_COMPILER}") + z_vcpkg_append_to_configure_environment(configure_env CC "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER}") + z_vcpkg_append_to_configure_environment(configure_env CC_FOR_BUILD "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER}") + z_vcpkg_append_to_configure_environment(configure_env CXX "compile ${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") + z_vcpkg_append_to_configure_environment(configure_env RC "windres-rc ${VCPKG_DETECTED_CMAKE_RC_COMPILER}") + z_vcpkg_append_to_configure_environment(configure_env WINDRES "windres-rc ${VCPKG_DETECTED_CMAKE_RC_COMPILER}") if(VCPKG_DETECTED_CMAKE_AR) - _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "ar-lib ${VCPKG_DETECTED_CMAKE_AR}") + z_vcpkg_append_to_configure_environment(configure_env AR "ar-lib ${VCPKG_DETECTED_CMAKE_AR}") else() - _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "ar-lib lib.exe -verbose") + z_vcpkg_append_to_configure_environment(configure_env AR "ar-lib lib.exe -verbose") endif() else() - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "${VCPKG_DETECTED_CMAKE_C_COMPILER} -E") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "${VCPKG_DETECTED_CMAKE_C_COMPILER}") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC_FOR_BUILD "${VCPKG_DETECTED_CMAKE_C_COMPILER}") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV RC "${VCPKG_DETECTED_CMAKE_RC_COMPILER}") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV WINDRES "${VCPKG_DETECTED_CMAKE_RC_COMPILER}") + z_vcpkg_append_to_configure_environment(configure_env CPP "${VCPKG_DETECTED_CMAKE_C_COMPILER} -E") + z_vcpkg_append_to_configure_environment(configure_env CC "${VCPKG_DETECTED_CMAKE_C_COMPILER}") + z_vcpkg_append_to_configure_environment(configure_env CC_FOR_BUILD "${VCPKG_DETECTED_CMAKE_C_COMPILER}") + z_vcpkg_append_to_configure_environment(configure_env CXX "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") + z_vcpkg_append_to_configure_environment(configure_env RC "${VCPKG_DETECTED_CMAKE_RC_COMPILER}") + z_vcpkg_append_to_configure_environment(configure_env WINDRES "${VCPKG_DETECTED_CMAKE_RC_COMPILER}") if(VCPKG_DETECTED_CMAKE_AR) - _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "${VCPKG_DETECTED_CMAKE_AR}") + z_vcpkg_append_to_configure_environment(configure_env AR "${VCPKG_DETECTED_CMAKE_AR}") else() - _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "lib.exe -verbose") + z_vcpkg_append_to_configure_environment(configure_env AR "lib.exe -verbose") endif() endif() - _vcpkg_append_to_configure_environment(CONFIGURE_ENV LD "${VCPKG_DETECTED_CMAKE_LINKER} -verbose") + z_vcpkg_append_to_configure_environment(configure_env LD "${VCPKG_DETECTED_CMAKE_LINKER} -verbose") if(VCPKG_DETECTED_CMAKE_RANLIB) - _vcpkg_append_to_configure_environment(CONFIGURE_ENV RANLIB "${VCPKG_DETECTED_CMAKE_RANLIB}") # Trick to ignore the RANLIB call + z_vcpkg_append_to_configure_environment(configure_env RANLIB "${VCPKG_DETECTED_CMAKE_RANLIB}") # Trick to ignore the RANLIB call else() - _vcpkg_append_to_configure_environment(CONFIGURE_ENV RANLIB ":") + z_vcpkg_append_to_configure_environment(configure_env RANLIB ":") endif() if(VCPKG_DETECTED_CMAKE_OBJDUMP) #Objdump is required to make shared libraries. Otherwise define lt_cv_deplibs_check_method=pass_all - _vcpkg_append_to_configure_environment(CONFIGURE_ENV OBJDUMP "${VCPKG_DETECTED_CMAKE_OBJDUMP}") # Trick to ignore the RANLIB call + z_vcpkg_append_to_configure_environment(configure_env OBJDUMP "${VCPKG_DETECTED_CMAKE_OBJDUMP}") # Trick to ignore the RANLIB call endif() if(VCPKG_DETECTED_CMAKE_STRIP) # If required set the ENV variable STRIP in the portfile correctly - _vcpkg_append_to_configure_environment(CONFIGURE_ENV STRIP "${VCPKG_DETECTED_CMAKE_STRIP}") + z_vcpkg_append_to_configure_environment(configure_env STRIP "${VCPKG_DETECTED_CMAKE_STRIP}") else() - _vcpkg_append_to_configure_environment(CONFIGURE_ENV STRIP ":") - list(APPEND _csc_OPTIONS ac_cv_prog_ac_ct_STRIP=:) + z_vcpkg_append_to_configure_environment(configure_env STRIP ":") + list(APPEND arg_OPTIONS ac_cv_prog_ac_ct_STRIP=:) endif() if(VCPKG_DETECTED_CMAKE_NM) # If required set the ENV variable NM in the portfile correctly - _vcpkg_append_to_configure_environment(CONFIGURE_ENV NM "${VCPKG_DETECTED_CMAKE_NM}") + z_vcpkg_append_to_configure_environment(configure_env NM "${VCPKG_DETECTED_CMAKE_NM}") else() # Would be better to have a true nm here! Some symbols (mainly exported variables) get not properly imported with dumpbin as nm # and require __declspec(dllimport) for some reason (same problem CMake has with WINDOWS_EXPORT_ALL_SYMBOLS) - _vcpkg_append_to_configure_environment(CONFIGURE_ENV NM "dumpbin.exe -symbols -headers") + z_vcpkg_append_to_configure_environment(configure_env NM "dumpbin.exe -symbols -headers") endif() if(VCPKG_DETECTED_CMAKE_DLLTOOL) # If required set the ENV variable DLLTOOL in the portfile correctly - _vcpkg_append_to_configure_environment(CONFIGURE_ENV DLLTOOL "${VCPKG_DETECTED_CMAKE_DLLTOOL}") + z_vcpkg_append_to_configure_environment(configure_env DLLTOOL "${VCPKG_DETECTED_CMAKE_DLLTOOL}") else() - _vcpkg_append_to_configure_environment(CONFIGURE_ENV DLLTOOL "link.exe -verbose -dll") + z_vcpkg_append_to_configure_environment(configure_env DLLTOOL "link.exe -verbose -dll") endif() - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CCAS ":") # If required set the ENV variable CCAS in the portfile correctly - _vcpkg_append_to_configure_environment(CONFIGURE_ENV AS ":") # If required set the ENV variable AS in the portfile correctly + z_vcpkg_append_to_configure_environment(configure_env CCAS ":") # If required set the ENV variable CCAS in the portfile correctly + z_vcpkg_append_to_configure_environment(configure_env AS ":") # If required set the ENV variable AS in the portfile correctly - foreach(_env IN LISTS _csc_CONFIGURE_ENVIRONMENT_VARIABLES) - _vcpkg_append_to_configure_environment(CONFIGURE_ENV ${_env} "${${_env}}") + foreach(_env IN LISTS arg_CONFIGURE_ENVIRONMENT_VARIABLES) + z_vcpkg_append_to_configure_environment(configure_env ${_env} "${${_env}}") endforeach() - debug_message("CONFIGURE_ENV: '${CONFIGURE_ENV}'") + debug_message("configure_env: '${configure_env}'") # Other maybe interesting variables to control # COMPILE This is the command used to actually compile a C source file. The file name is appended to form the complete command line. # LINK This is the command used to actually link a C program. @@ -435,45 +423,45 @@ function(vcpkg_configure_make) # CXXLINK The command used to actually link a C++ program. # Variables not correctly detected by configure. In release builds. - list(APPEND _csc_OPTIONS gl_cv_double_slash_root=yes + list(APPEND arg_OPTIONS gl_cv_double_slash_root=yes ac_cv_func_memmove=yes) - #list(APPEND _csc_OPTIONS lt_cv_deplibs_check_method=pass_all) # Just ignore libtool checks + #list(APPEND arg_OPTIONS lt_cv_deplibs_check_method=pass_all) # Just ignore libtool checks if(VCPKG_TARGET_ARCHITECTURE MATCHES "^[Aa][Rr][Mm]64$") - list(APPEND _csc_OPTIONS gl_cv_host_cpu_c_abi=no) + list(APPEND arg_OPTIONS gl_cv_host_cpu_c_abi=no) # Currently needed for arm64 because objdump yields: "unrecognised machine type (0xaa64) in Import Library Format archive" - list(APPEND _csc_OPTIONS lt_cv_deplibs_check_method=pass_all) + list(APPEND arg_OPTIONS lt_cv_deplibs_check_method=pass_all) elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^[Aa][Rr][Mm]$") # Currently needed for arm because objdump yields: "unrecognised machine type (0x1c4) in Import Library Format archive" - list(APPEND _csc_OPTIONS lt_cv_deplibs_check_method=pass_all) + list(APPEND arg_OPTIONS lt_cv_deplibs_check_method=pass_all) endif() endif() # Some PATH handling for dealing with spaces....some tools will still fail with that! # In particular, the libtool install command is unable to install correctly to paths with spaces. # CURRENT_INSTALLED_DIR: Pristine native path (unprotected spaces, Windows drive letters) - # _VCPKG_INSTALLED: Native path with escaped space characters - # _VCPKG_PREFIX: Path with unprotected spaces, but drive letters transformed for mingw/msys - string(REPLACE " " "\\ " _VCPKG_INSTALLED "${CURRENT_INSTALLED_DIR}") + # z_vcpkg_installed_path: Native path with escaped space characters + # z_vcpkg_prefix_path: Path with unprotected spaces, but drive letters transformed for mingw/msys + string(REPLACE " " "\\ " z_vcpkg_installed_path "${CURRENT_INSTALLED_DIR}") if(CMAKE_HOST_WIN32) - string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_PREFIX "${CURRENT_INSTALLED_DIR}") + string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" z_vcpkg_prefix_path "${CURRENT_INSTALLED_DIR}") else() - set(_VCPKG_PREFIX "${CURRENT_INSTALLED_DIR}") + set(z_vcpkg_prefix_path "${CURRENT_INSTALLED_DIR}") endif() # macOS - cross-compiling support if(VCPKG_TARGET_IS_OSX) - if (_csc_AUTOCONFIG AND NOT _csc_BUILD_TRIPLET OR _csc_DETERMINE_BUILD_TRIPLET) - _vcpkg_determine_autotools_host_arch_mac(BUILD_ARCH) # machine you are building on => --build= - _vcpkg_determine_autotools_target_arch_mac(TARGET_ARCH) + if (requires_autoconfig AND NOT arg_BUILD_TRIPLET OR arg_DETERMINE_BUILD_TRIPLET) + z_vcpkg_determine_autotools_host_arch_mac(BUILD_ARCH) # machine you are building on => --build= + z_vcpkg_determine_autotools_target_arch_mac(TARGET_ARCH) # --build: the machine you are building on # --host: the machine you are building for # --target: the machine that CC will produce binaries for # https://stackoverflow.com/questions/21990021/how-to-determine-host-value-for-configure-when-using-cross-compiler # Only for ports using autotools so we can assume that they follow the common conventions for build/target/host if(NOT "${TARGET_ARCH}" STREQUAL "${BUILD_ARCH}") # we don't need to specify the additional flags if we build natively. - set(_csc_BUILD_TRIPLET "--host=${TARGET_ARCH}-apple-darwin") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target) + set(arg_BUILD_TRIPLET "--host=${TARGET_ARCH}-apple-darwin") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target) endif() - debug_message("Using make triplet: ${_csc_BUILD_TRIPLET}") + debug_message("Using make triplet: ${arg_BUILD_TRIPLET}") endif() endif() @@ -483,11 +471,11 @@ function(vcpkg_configure_make) "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}") # Set configure paths - set(_csc_OPTIONS_RELEASE ${_csc_OPTIONS_RELEASE} "--prefix=${_VCPKG_PREFIX}") - set(_csc_OPTIONS_DEBUG ${_csc_OPTIONS_DEBUG} "--prefix=${_VCPKG_PREFIX}/debug") - if(NOT _csc_NO_ADDITIONAL_PATHS) + set(arg_OPTIONS_RELEASE ${arg_OPTIONS_RELEASE} "--prefix=${z_vcpkg_prefix_path}") + set(arg_OPTIONS_DEBUG ${arg_OPTIONS_DEBUG} "--prefix=${z_vcpkg_prefix_path}/debug") + if(NOT arg_NO_ADDITIONAL_PATHS) # ${prefix} has an extra backslash to prevent early expansion when calling `bash -c configure "..."`. - set(_csc_OPTIONS_RELEASE ${_csc_OPTIONS_RELEASE} + set(arg_OPTIONS_RELEASE ${arg_OPTIONS_RELEASE} # Important: These should all be relative to prefix! "--bindir=\\\${prefix}/tools/${PORT}/bin" "--sbindir=\\\${prefix}/tools/${PORT}/sbin" @@ -496,7 +484,7 @@ function(vcpkg_configure_make) "--mandir=\\\${prefix}/share/${PORT}" "--docdir=\\\${prefix}/share/${PORT}" "--datarootdir=\\\${prefix}/share/${PORT}") - set(_csc_OPTIONS_DEBUG ${_csc_OPTIONS_DEBUG} + set(arg_OPTIONS_DEBUG ${arg_OPTIONS_DEBUG} # Important: These should all be relative to prefix! "--bindir=\\\${prefix}/../tools/${PORT}/debug/bin" "--sbindir=\\\${prefix}/../tools/${PORT}/debug/sbin" @@ -505,53 +493,45 @@ function(vcpkg_configure_make) "--datarootdir=\\\${prefix}/share/${PORT}") endif() # Setup common options - if(NOT DISABLE_VERBOSE_FLAGS) - list(APPEND _csc_OPTIONS --disable-silent-rules --verbose) + if(NOT arg_DISABLE_VERBOSE_FLAGS) + list(APPEND arg_OPTIONS --disable-silent-rules --verbose) endif() if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - list(APPEND _csc_OPTIONS --enable-shared --disable-static) + list(APPEND arg_OPTIONS --enable-shared --disable-static) else() - list(APPEND _csc_OPTIONS --disable-shared --enable-static) + list(APPEND arg_OPTIONS --disable-shared --enable-static) endif() # Can be set in the triplet to append options for configure - if(DEFINED VCPKG_MAKE_CONFIGURE_OPTIONS) - list(APPEND _csc_OPTIONS ${VCPKG_MAKE_CONFIGURE_OPTIONS}) + if(DEFINED VCPKG_CONFIGURE_MAKE_OPTIONS) + list(APPEND arg_OPTIONS ${VCPKG_CONFIGURE_MAKE_OPTIONS}) endif() - if(DEFINED VCPKG_MAKE_CONFIGURE_OPTIONS_RELEASE) - list(APPEND _csc_OPTIONS_RELEASE ${VCPKG_MAKE_CONFIGURE_OPTIONS_RELEASE}) + if(DEFINED VCPKG_CONFIGURE_MAKE_OPTIONS_RELEASE) + list(APPEND arg_OPTIONS_RELEASE ${VCPKG_CONFIGURE_MAKE_OPTIONS_RELEASE}) endif() - if(DEFINED VCPKG_MAKE_CONFIGURE_OPTIONS_DEBUG) - list(APPEND _csc_OPTIONS_DEBUG ${VCPKG_MAKE_CONFIGURE_OPTIONS_DEBUG}) + if(DEFINED VCPKG_CONFIGURE_MAKE_OPTIONS_DEBUG) + list(APPEND arg_OPTIONS_DEBUG ${VCPKG_CONFIGURE_MAKE_OPTIONS_DEBUG}) endif() - file(RELATIVE_PATH RELATIVE_BUILD_PATH "${CURRENT_BUILDTREES_DIR}" "${_csc_SOURCE_PATH}/${_csc_PROJECT_SUBPATH}") + file(RELATIVE_PATH relative_build_path "${CURRENT_BUILDTREES_DIR}" "${arg_SOURCE_PATH}/${arg_PROJECT_SUBPATH}") set(base_cmd) if(CMAKE_HOST_WIN32) - set(base_cmd ${BASH} --noprofile --norc --debug) + set(base_cmd ${bash_executable} --noprofile --norc --debug) else() find_program(base_cmd bash REQUIRED) endif() - - # Setup include environment (since these are buildtype independent restoring them is unnecessary) - macro(prepend_include_path var) - if("${${var}_BACKUP}" STREQUAL "") - set(ENV{${var}} "${CURRENT_INSTALLED_DIR}/include") - else() - set(ENV{${var}} "${CURRENT_INSTALLED_DIR}/include${VCPKG_HOST_PATH_SEPARATOR}${${var}_BACKUP}") - endif() - endmacro() + # Used by CL - prepend_include_path(INCLUDE) + z_prepend_include_path(INCLUDE) # Used by GCC - prepend_include_path(C_INCLUDE_PATH) - prepend_include_path(CPLUS_INCLUDE_PATH) + z_prepend_include_path(C_INCLUDE_PATH) + z_prepend_include_path(CPLUS_INCLUDE_PATH) # Flags should be set in the toolchain instead (Setting this up correctly requires a function named vcpkg_determined_cmake_compiler_flags which can also be used to setup CC and CXX etc.) if(VCPKG_TARGET_IS_WINDOWS) - _vcpkg_backup_env_variables(_CL_ _LINK_) + vcpkg_backup_env_variables(VARS _CL_ _LINK_) # TODO: Should be CPP flags instead -> rewrite when vcpkg_determined_cmake_compiler_flags defined if(VCPKG_TARGET_IS_UWP) # Be aware that configure thinks it is crosscompiling due to: @@ -569,45 +549,42 @@ function(vcpkg_configure_make) endif() endif() - macro(convert_to_list input output) - string(REGEX MATCHALL "(( +|^ *)[^ ]+)" ${output} "${${input}}") - endmacro() - convert_to_list(VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES C_LIBS_LIST) - convert_to_list(VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES CXX_LIBS_LIST) - set(ALL_LIBS_LIST ${C_LIBS_LIST} ${CXX_LIBS_LIST}) - list(REMOVE_DUPLICATES ALL_LIBS_LIST) - list(TRANSFORM ALL_LIBS_LIST STRIP) + z_convert_to_list(VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES c_libs_list) + z_convert_to_list(VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES cxx_libs_list) + set(all_libs_list ${c_libs_list} ${cxx_libs_list}) + list(REMOVE_DUPLICATES all_libs_list) + list(TRANSFORM all_libs_list STRIP) #Do lib list transformation from name.lib to -lname if necessary - set(_VCPKG_TRANSFORM_LIBS TRUE) + set(x_vcpkg_transform_libs ON) if(VCPKG_TARGET_IS_UWP) - set(_VCPKG_TRANSFORM_LIBS FALSE) + set(x_vcpkg_transform_libs OFF) # Avoid libtool choke: "Warning: linker path does not have real file for library -lWindowsApp." # The problem with the choke is that libtool always falls back to built a static library even if a dynamic was requested. # Note: Env LIBPATH;LIB are on the search path for libtool by default on windows. # It even does unix/dos-short/unix transformation with the path to get rid of spaces. endif() - set(_lprefix) - if(_VCPKG_TRANSFORM_LIBS) - set(_lprefix "-l") - list(TRANSFORM ALL_LIBS_LIST REPLACE "(.dll.lib|.lib|.a|.so)$" "") + set(l_prefix) + if(x_vcpkg_transform_libs) + set(l_prefix "-l") + list(TRANSFORM all_libs_list REPLACE "(.dll.lib|.lib|.a|.so)$" "") if(VCPKG_TARGET_IS_WINDOWS) - list(REMOVE_ITEM ALL_LIBS_LIST "uuid") + list(REMOVE_ITEM all_libs_list "uuid") endif() - list(TRANSFORM ALL_LIBS_LIST REPLACE "^(${_lprefix})" "") + list(TRANSFORM all_libs_list REPLACE "^(${l_prefix})" "") endif() - list(JOIN ALL_LIBS_LIST " ${_lprefix}" ALL_LIBS_STRING) + list(JOIN all_libs_list " ${l_prefix}" all_libs_string) if(VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") # libtool must be told explicitly that there is no dynamic linkage for uuid. # The "-Wl,..." syntax is understood by libtool and gcc, but no by ld. - string(REPLACE " -luuid" " -Wl,-Bstatic,-luuid,-Bdynamic" ALL_LIBS_STRING "${ALL_LIBS_STRING}") + string(REPLACE " -luuid" " -Wl,-Bstatic,-luuid,-Bdynamic" all_libs_string "${all_libs_string}") endif() - if(ALL_LIBS_STRING) - set(ALL_LIBS_STRING "${_lprefix}${ALL_LIBS_STRING}") + if(all_libs_string) + set(all_libs_string "${l_prefix}${all_libs_string}") if(DEFINED ENV{LIBS}) - set(ENV{LIBS} "$ENV{LIBS} ${ALL_LIBS_STRING}") + set(ENV{LIBS} "$ENV{LIBS} ${all_libs_string}") else() - set(ENV{LIBS} "${ALL_LIBS_STRING}") + set(ENV{LIBS} "${all_libs_string}") endif() endif() debug_message("ENV{LIBS}:$ENV{LIBS}") @@ -617,8 +594,7 @@ function(vcpkg_configure_make) endif() # Run autoconf if necessary - set(_GENERATED_CONFIGURE FALSE) - if (_csc_AUTOCONFIG OR REQUIRES_AUTOCONFIG) + if (arg_AUTOCONFIG OR requires_autoconfig) find_program(AUTORECONF autoreconf) if(NOT AUTORECONF) message(FATAL_ERROR "${PORT} requires autoconf from the system package manager (example: \"sudo apt-get install autoconf\")") @@ -627,113 +603,121 @@ function(vcpkg_configure_make) if (CMAKE_HOST_WIN32) vcpkg_execute_required_process( COMMAND ${base_cmd} -c "autoreconf -vfi" - WORKING_DIRECTORY "${SRC_DIR}" - LOGNAME autoconf-${TARGET_TRIPLET} + WORKING_DIRECTORY "${src_dir}" + LOGNAME "autoconf-${TARGET_TRIPLET}" ) else() vcpkg_execute_required_process( - COMMAND ${AUTORECONF} -vfi - WORKING_DIRECTORY "${SRC_DIR}" - LOGNAME autoconf-${TARGET_TRIPLET} + COMMAND "${AUTORECONF}" -vfi + WORKING_DIRECTORY "${src_dir}" + LOGNAME "autoconf-${TARGET_TRIPLET}" ) endif() message(STATUS "Finished generating configure for ${TARGET_TRIPLET}") endif() - if(REQUIRES_AUTOGEN) + if(requires_autogen) message(STATUS "Generating configure for ${TARGET_TRIPLET} via autogen.sh") if (CMAKE_HOST_WIN32) vcpkg_execute_required_process( COMMAND ${base_cmd} -c "./autogen.sh" - WORKING_DIRECTORY "${SRC_DIR}" - LOGNAME autoconf-${TARGET_TRIPLET} + WORKING_DIRECTORY "${src_dir}" + LOGNAME "autoconf-${TARGET_TRIPLET}" ) else() vcpkg_execute_required_process( COMMAND "./autogen.sh" - WORKING_DIRECTORY "${SRC_DIR}" - LOGNAME autoconf-${TARGET_TRIPLET} + WORKING_DIRECTORY "${src_dir}" + LOGNAME "autoconf-${TARGET_TRIPLET}" ) endif() message(STATUS "Finished generating configure for ${TARGET_TRIPLET}") endif() - if (_csc_PRERUN_SHELL) + if (arg_PRERUN_SHELL) message(STATUS "Prerun shell with ${TARGET_TRIPLET}") - vcpkg_execute_required_process( - COMMAND ${base_cmd} -c "${_csc_PRERUN_SHELL}" - WORKING_DIRECTORY "${SRC_DIR}" - LOGNAME prerun-${TARGET_TRIPLET} - ) + if (CMAKE_HOST_WIN32) + vcpkg_execute_required_process( + COMMAND ${base_cmd} -c "${arg_PRERUN_SHELL}" + WORKING_DIRECTORY "${src_dir}" + LOGNAME "prerun-${TARGET_TRIPLET}" + ) + else() + vcpkg_execute_required_process( + COMMAND "${base_cmd}" -c "${arg_PRERUN_SHELL}" + WORKING_DIRECTORY "${src_dir}" + LOGNAME "prerun-${TARGET_TRIPLET}" + ) + endif() endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" AND NOT _csc_NO_DEBUG) - set(_VAR_SUFFIX DEBUG) - set(PATH_SUFFIX_${_VAR_SUFFIX} "/debug") - set(SHORT_NAME_${_VAR_SUFFIX} "dbg") - list(APPEND _buildtypes ${_VAR_SUFFIX}) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" AND NOT arg_NO_DEBUG) + set(var_suffix DEBUG) + set(path_suffix_${var_suffix} "/debug") + set(short_name_${var_suffix} "dbg") + list(APPEND all_buildtypes ${var_suffix}) if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") - set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LINKER_FLAGS_${var_suffix} "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${var_suffix}}") else() # dynamic - set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LINKER_FLAGS_${var_suffix} "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${var_suffix}}") endif() - _vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags(${_VAR_SUFFIX}) + z_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags(${var_suffix}) if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe") - if(NOT _vcm_paths_with_spaces) - set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") + if(NOT vcm_paths_with_spaces) + set(LDFLAGS_${var_suffix} "-L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib -L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib/manual-link") endif() if(DEFINED ENV{_LINK_}) - set(LINK_ENV_${_VAR_SUFFIX} "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LINK_ENV_${var_suffix} "$ENV{_LINK_} ${LINKER_FLAGS_${var_suffix}}") else() - set(LINK_ENV_${_VAR_SUFFIX} "${LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LINK_ENV_${var_suffix} "${LINKER_FLAGS_${var_suffix}}") endif() else() - set(_link_dirs) - if(EXISTS "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib") - set(_link_dirs "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib") + set(link_required_dirs) + if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${var_suffix}}/lib") + set(link_required_dirs "-L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib") endif() - if(EXISTS "{CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") - set(_link_dirs "${_link_dirs} -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") + if(EXISTS "{CURRENT_INSTALLED_DIR}${path_suffix_${var_suffix}}/lib/manual-link") + set(link_required_dirs "${link_required_dirs} -L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib/manual-link") endif() - string(STRIP "${_link_dirs}" _link_dirs) - set(LDFLAGS_${_VAR_SUFFIX} "${_link_dirs} ${LINKER_FLAGS_${_VAR_SUFFIX}}") + string(STRIP "${link_required_dirs}" link_required_dirs) + set(LDFLAGS_${var_suffix} "${link_required_dirs} ${LINKER_FLAGS_${var_suffix}}") endif() - unset(_VAR_SUFFIX) + unset(var_suffix) endif() if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - set(_VAR_SUFFIX RELEASE) - set(PATH_SUFFIX_${_VAR_SUFFIX} "") - set(SHORT_NAME_${_VAR_SUFFIX} "rel") - list(APPEND _buildtypes ${_VAR_SUFFIX}) + set(var_suffix RELEASE) + set(path_suffix_${var_suffix} "") + set(short_name_${var_suffix} "rel") + list(APPEND all_buildtypes ${var_suffix}) if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") - set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LINKER_FLAGS_${var_suffix} "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${var_suffix}}") else() # dynamic - set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LINKER_FLAGS_${var_suffix} "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${var_suffix}}") endif() - _vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags(${_VAR_SUFFIX}) + z_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags(${var_suffix}) if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe") - if(NOT _vcm_paths_with_spaces) - set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") + if(NOT vcm_paths_with_spaces) + set(LDFLAGS_${var_suffix} "-L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib -L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib/manual-link") endif() if(DEFINED ENV{_LINK_}) - set(LINK_ENV_${_VAR_SUFFIX} "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LINK_ENV_${var_suffix} "$ENV{_LINK_} ${LINKER_FLAGS_${var_suffix}}") else() - set(LINK_ENV_${_VAR_SUFFIX} "${LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LINK_ENV_${var_suffix} "${LINKER_FLAGS_${var_suffix}}") endif() else() - set(_link_dirs) - if(EXISTS "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib") - set(_link_dirs "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib") + set(link_required_dirs) + if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${var_suffix}}/lib") + set(link_required_dirs "-L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib") endif() - if(EXISTS "{CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") - set(_link_dirs "${_link_dirs} -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") + if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${var_suffix}}/lib/manual-link") + set(link_required_dirs "${link_required_dirs} -L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib/manual-link") endif() - string(STRIP "${_link_dirs}" _link_dirs) - set(LDFLAGS_${_VAR_SUFFIX} "${_link_dirs} ${LINKER_FLAGS_${_VAR_SUFFIX}}") + string(STRIP "${link_required_dirs}" link_required_dirs) + set(LDFLAGS_${var_suffix} "${link_required_dirs} ${LINKER_FLAGS_${var_suffix}}") endif() - unset(_VAR_SUFFIX) + unset(var_suffix) endif() - foreach(var IN ITEMS _csc_OPTIONS _csc_OPTIONS_RELEASE _csc_OPTIONS_DEBUG) + foreach(var IN ITEMS arg_OPTIONS arg_OPTIONS_RELEASE arg_OPTIONS_DEBUG) vcpkg_list(SET tmp) foreach(element IN LISTS "${var}") string(REPLACE [["]] [[\"]] element "${element}") @@ -742,39 +726,39 @@ function(vcpkg_configure_make) vcpkg_list(JOIN tmp " " "${var}") endforeach() - foreach(_buildtype IN LISTS _buildtypes) - foreach(ENV_VAR ${_csc_CONFIG_DEPENDENT_ENVIRONMENT}) + foreach(current_buildtype IN LISTS all_buildtypes) + foreach(ENV_VAR ${arg_CONFIG_DEPENDENT_ENVIRONMENT}) if(DEFINED ENV{${ENV_VAR}}) - set(BACKUP_CONFIG_${ENV_VAR} "$ENV{${ENV_VAR}}") + set(backup_config_${ENV_VAR} "$ENV{${ENV_VAR}}") endif() - set(ENV{${ENV_VAR}} "${${ENV_VAR}_${_buildtype}}") + set(ENV{${ENV_VAR}} "${${ENV_VAR}_${current_buildtype}}") endforeach() - set(TAR_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}") - file(MAKE_DIRECTORY "${TAR_DIR}") - file(RELATIVE_PATH RELATIVE_BUILD_PATH "${TAR_DIR}" "${SRC_DIR}") + set(target_dir "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_name_${current_buildtype}}") + file(MAKE_DIRECTORY "${target_dir}") + file(RELATIVE_PATH relative_build_path "${target_dir}" "${src_dir}") - if(_csc_COPY_SOURCE) - file(COPY "${SRC_DIR}/" DESTINATION "${TAR_DIR}") - set(RELATIVE_BUILD_PATH .) + if(arg_COPY_SOURCE) + file(COPY "${src_dir}/" DESTINATION "${target_dir}") + set(relative_build_path .) endif() # Setup PKG_CONFIG_PATH - set(PKGCONFIG_INSTALLED_DIR "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_buildtype}}/lib/pkgconfig") - set(PKGCONFIG_INSTALLED_SHARE_DIR "${CURRENT_INSTALLED_DIR}/share/pkgconfig") + set(pkgconfig_installed_dir "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib/pkgconfig") + set(pkgconfig_installed_share_dir "${CURRENT_INSTALLED_DIR}/share/pkgconfig") if(ENV{PKG_CONFIG_PATH}) - set(BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype} $ENV{PKG_CONFIG_PATH}) - set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}${VCPKG_HOST_PATH_SEPARATOR}${PKGCONFIG_INSTALLED_SHARE_DIR}${VCPKG_HOST_PATH_SEPARATOR}$ENV{PKG_CONFIG_PATH}") + set(backup_env_pkg_config_path_${current_buildtype} $ENV{PKG_CONFIG_PATH}) + set(ENV{PKG_CONFIG_PATH} "${pkgconfig_installed_dir}${VCPKG_HOST_PATH_SEPARATOR}${pkgconfig_installed_share_dir}${VCPKG_HOST_PATH_SEPARATOR}$ENV{PKG_CONFIG_PATH}") else() - set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}${VCPKG_HOST_PATH_SEPARATOR}${PKGCONFIG_INSTALLED_SHARE_DIR}") + set(ENV{PKG_CONFIG_PATH} "${pkgconfig_installed_dir}${VCPKG_HOST_PATH_SEPARATOR}${pkgconfig_installed_share_dir}") endif() # Setup environment - set(ENV{CPPFLAGS} "${CPPFLAGS_${_buildtype}}") - set(ENV{CFLAGS} "${CFLAGS_${_buildtype}}") - set(ENV{CXXFLAGS} "${CXXFLAGS_${_buildtype}}") - set(ENV{RCFLAGS} "${VCPKG_DETECTED_CMAKE_RC_FLAGS_${_buildtype}}") - set(ENV{LDFLAGS} "${LDFLAGS_${_buildtype}}") + set(ENV{CPPFLAGS} "${CPPFLAGS_${current_buildtype}}") + set(ENV{CFLAGS} "${CFLAGS_${current_buildtype}}") + set(ENV{CXXFLAGS} "${CXXFLAGS_${current_buildtype}}") + set(ENV{RCFLAGS} "${VCPKG_DETECTED_CMAKE_RC_FLAGS_${current_buildtype}}") + set(ENV{LDFLAGS} "${LDFLAGS_${current_buildtype}}") # https://www.gnu.org/software/libtool/manual/html_node/Link-mode.html # -avoid-version is handled specially by libtool link mode, this flag is not forwarded to linker, @@ -783,76 +767,70 @@ function(vcpkg_configure_make) set(ENV{LDFLAGS} "-avoid-version $ENV{LDFLAGS}") endif() - if(LINK_ENV_${_buildtype}) - set(_LINK_CONFIG_BACKUP "$ENV{_LINK_}") - set(ENV{_LINK_} "${LINK_ENV_${_buildtype}}") + if(LINK_ENV_${current_buildtype}) + set(link_config_backup "$ENV{_LINK_}") + set(ENV{_LINK_} "${LINK_ENV_${current_buildtype}}") endif() set(ENV{PKG_CONFIG} "${PKGCONFIG}") - set(_lib_env_vars LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) - foreach(_lib_env_var IN LISTS _lib_env_vars) - set(_link_path) - if(EXISTS "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_buildtype}}/lib") - set(_link_path "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_buildtype}}/lib") + vcpkg_list(APPEND lib_env_vars LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) + foreach(lib_env_var IN LISTS lib_env_vars) + if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib") + vcpkg_host_path_list(PREPEND ENV{${lib_env_var}} "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib") endif() - if(EXISTS "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_buildtype}}/lib/manual-link") - if(_link_path) - set(_link_path "${_link_path}${VCPKG_HOST_PATH_SEPARATOR}") - endif() - set(_link_path "${_link_path}${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_buildtype}}/lib/manual-link") + if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib/manual-link") + vcpkg_host_path_list(PREPEND ENV{${lib_env_var}} "${CURRENT_INSTALLED_DIR}" "${path_suffix_${current_buildtype}}/lib/manual-link") endif() - set(ENV{${_lib_env_var}} "${_link_path}${${_lib_env_var}_PATHLIKE_CONCAT}") endforeach() - unset(_link_path) - unset(_lib_env_vars) + unset(lib_env_vars) - set(command "${base_cmd}" -c "${CONFIGURE_ENV} ./${RELATIVE_BUILD_PATH}/configure ${_csc_BUILD_TRIPLET} ${_csc_OPTIONS} ${_csc_OPTIONS_${_buildtype}}") + set(command "${base_cmd}" -c "${configure_env} ./${relative_build_path}/configure ${arg_BUILD_TRIPLET} ${arg_OPTIONS} ${arg_OPTIONS_${current_buildtype}}") - if(_csc_ADD_BIN_TO_PATH) - set(PATH_BACKUP $ENV{PATH}) - vcpkg_add_to_path("${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_buildtype}}/bin") + if(arg_ADD_BIN_TO_PATH) + set(path_backup $ENV{PATH}) + vcpkg_add_to_path("${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/bin") endif() debug_message("Configure command:'${command}'") - if (NOT _csc_SKIP_CONFIGURE) - message(STATUS "Configuring ${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}") + if (NOT arg_SKIP_CONFIGURE) + message(STATUS "Configuring ${TARGET_TRIPLET}-${short_name_${current_buildtype}}") vcpkg_execute_required_process( COMMAND ${command} - WORKING_DIRECTORY "${TAR_DIR}" - LOGNAME config-${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}} + WORKING_DIRECTORY "${target_dir}" + LOGNAME "config-${TARGET_TRIPLET}-${short_name_${current_buildtype}}" ) if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - file(GLOB_RECURSE LIBTOOL_FILES "${TAR_DIR}*/libtool") - foreach(lt_file IN LISTS LIBTOOL_FILES) + file(GLOB_RECURSE libtool_files "${target_dir}*/libtool") + foreach(lt_file IN LISTS libtool_files) file(READ "${lt_file}" _contents) string(REPLACE ".dll.lib" ".lib" _contents "${_contents}") file(WRITE "${lt_file}" "${_contents}") endforeach() endif() - if(EXISTS "${TAR_DIR}/config.log") - file(RENAME "${TAR_DIR}/config.log" "${CURRENT_BUILDTREES_DIR}/config.log-${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}.log") + if(EXISTS "${target_dir}/config.log") + file(RENAME "${target_dir}/config.log" "${CURRENT_BUILDTREES_DIR}/config.log-${TARGET_TRIPLET}-${short_name_${current_buildtype}}.log") endif() endif() - if(BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype}) - set(ENV{PKG_CONFIG_PATH} "${BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype}}") + if(backup_env_pkg_config_path_${current_buildtype}) + set(ENV{PKG_CONFIG_PATH} "${backup_env_pkg_config_path_${current_buildtype}}") else() unset(ENV{PKG_CONFIG_PATH}) endif() - unset(BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype}) + unset(backup_env_pkg_config_path_${current_buildtype}) - if(_LINK_CONFIG_BACKUP) - set(ENV{_LINK_} "${_LINK_CONFIG_BACKUP}") - unset(_LINK_CONFIG_BACKUP) + if(link_config_backup) + set(ENV{_LINK_} "${link_config_backup}") + unset(link_config_backup) endif() - if(_csc_ADD_BIN_TO_PATH) - set(ENV{PATH} "${PATH_BACKUP}") + if(arg_ADD_BIN_TO_PATH) + set(ENV{PATH} "${path_backup}") endif() # Restore environment (config dependent) - foreach(ENV_VAR ${_csc_CONFIG_DEPENDENT_ENVIRONMENT}) - if(BACKUP_CONFIG_${ENV_VAR}) - set(ENV{${ENV_VAR}} "${BACKUP_CONFIG_${ENV_VAR}}") + foreach(ENV_VAR IN LISTS ${arg_CONFIG_DEPENDENT_ENVIRONMENT}) + if(backup_config_${ENV_VAR}) + set(ENV{${ENV_VAR}} "${backup_config_${ENV_VAR}}") else() unset(ENV{${ENV_VAR}}) endif() @@ -869,8 +847,8 @@ function(vcpkg_configure_make) endif() # Restore environment - _vcpkg_restore_env_variables(${_cm_FLAGS} LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) + vcpkg_restore_env_variables(VARS ${cm_FLAGS} LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) - SET(_VCPKG_PROJECT_SOURCE_PATH ${_csc_SOURCE_PATH} PARENT_SCOPE) - set(_VCPKG_PROJECT_SUBPATH ${_csc_PROJECT_SUBPATH} PARENT_SCOPE) + set(_VCPKG_PROJECT_SOURCE_PATH ${arg_SOURCE_PATH} PARENT_SCOPE) + set(_VCPKG_PROJECT_SUBPATH ${arg_PROJECT_SUBPATH} PARENT_SCOPE) endfunction() diff --git a/scripts/cmake/vcpkg_install_make.cmake b/scripts/cmake/vcpkg_install_make.cmake index ce8a782d3c5..f622edd406a 100644 --- a/scripts/cmake/vcpkg_install_make.cmake +++ b/scripts/cmake/vcpkg_install_make.cmake @@ -23,5 +23,9 @@ This command transparently forwards to [`vcpkg_build_make()`](vcpkg_build_make.m #]===] function(vcpkg_install_make) - vcpkg_build_make(${ARGN} LOGFILE_ROOT ENABLE_INSTALL) + vcpkg_build_make( + ${ARGN} + LOGFILE_ROOT + ENABLE_INSTALL + ) endfunction() diff --git a/scripts/ports.cmake b/scripts/ports.cmake index 914c47cae9c..53ac2ac9991 100644 --- a/scripts/ports.cmake +++ b/scripts/ports.cmake @@ -6,6 +6,7 @@ include("${SCRIPTS}/cmake/execute_process.cmake") include("${SCRIPTS}/cmake/vcpkg_acquire_msys.cmake") include("${SCRIPTS}/cmake/vcpkg_add_to_path.cmake") include("${SCRIPTS}/cmake/vcpkg_apply_patches.cmake") +include("${SCRIPTS}/cmake/vcpkg_backup_restore_env_vars.cmake") include("${SCRIPTS}/cmake/vcpkg_build_cmake.cmake") include("${SCRIPTS}/cmake/vcpkg_build_make.cmake") include("${SCRIPTS}/cmake/vcpkg_build_msbuild.cmake") diff --git a/versions/baseline.json b/versions/baseline.json index f334952134f..7f31dc2ca58 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -7122,7 +7122,7 @@ }, "x264": { "baseline": "157-303c484ec828ed0", - "port-version": 15 + "port-version": 16 }, "x265": { "baseline": "3.4", diff --git a/versions/x-/x264.json b/versions/x-/x264.json index d129da3b53d..7ca11279e98 100644 --- a/versions/x-/x264.json +++ b/versions/x-/x264.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "e8f14328cb425b2a7450bf36f731f97d41564fed", + "version-string": "157-303c484ec828ed0", + "port-version": 16 + }, { "git-tree": "e766671c5f64574235784ce45b1668daf4cb9b44", "version-string": "157-303c484ec828ed0",