diff --git a/docs/maintainers/portfile-functions.md b/docs/maintainers/portfile-functions.md index dd97511c0a35c1..6e5c8a5928e9be 100644 --- a/docs/maintainers/portfile-functions.md +++ b/docs/maintainers/portfile-functions.md @@ -7,7 +7,7 @@ - [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\_make](vcpkg_build_make.md) (deprecated, use [vcpkg\_make\_build](ports/vcpkg-make/vcpkg_make_build.md)) - [vcpkg\_build\_msbuild](vcpkg_build_msbuild.md) - [vcpkg\_build\_ninja](vcpkg_build_ninja.md) - [vcpkg\_build\_nmake](vcpkg_build_nmake.md) @@ -20,7 +20,7 @@ - [vcpkg\_common\_definitions](vcpkg_common_definitions.md) - [vcpkg\_configure\_cmake](vcpkg_configure_cmake.md) (deprecated, use [vcpkg\_cmake\_configure](ports/vcpkg-cmake/vcpkg_cmake_configure.md)) - [vcpkg\_configure\_gn](vcpkg_configure_gn.md) -- [vcpkg\_configure\_make](vcpkg_configure_make.md) +- [vcpkg\_configure\_make](vcpkg_configure_make.md) (deprecated, use [vcpkg\_make\_configure](ports/vcpkg-make/vcpkg_make_configure.md)) - [vcpkg\_configure\_meson](vcpkg_configure_meson.md) - [vcpkg\_configure\_qmake](vcpkg_configure_qmake.md) - [vcpkg\_copy\_pdbs](vcpkg_copy_pdbs.md) @@ -48,7 +48,7 @@ - [vcpkg\_host\_path\_list](vcpkg_host_path_list.md) - [vcpkg\_install\_cmake](vcpkg_install_cmake.md) (deprecated, use [vcpkg\_cmake\_install](ports/vcpkg-cmake/vcpkg_cmake_install.md)) - [vcpkg\_install\_gn](vcpkg_install_gn.md) -- [vcpkg\_install\_make](vcpkg_install_make.md) +- [vcpkg\_install\_make](vcpkg_install_make.md) (deprecated, use [vcpkg\_make\_install](ports/vcpkg-make/vcpkg_make_install.md)) - [vcpkg\_install\_meson](vcpkg_install_meson.md) - [vcpkg\_install\_msbuild](vcpkg_install_msbuild.md) - [vcpkg\_install\_nmake](vcpkg_install_nmake.md) @@ -81,3 +81,9 @@ ### [vcpkg-pkgconfig-get-modules](ports/vcpkg-pkgconfig-get-modules.md) - [x\_vcpkg\_pkgconfig\_get\_modules](ports/vcpkg-pkgconfig-get-modules/x_vcpkg_pkgconfig_get_modules.md) + +### [vcpkg-make](ports/vcpkg-make.md) + +- [vcpkg\_make\_build](ports/vcpkg-make/vcpkg_make_build.md) +- [vcpkg\_make\_configure](ports/vcpkg-make/vcpkg_make_configure.md) +- [vcpkg\_make\_install](ports/vcpkg-make/vcpkg_make_install.md) diff --git a/docs/maintainers/ports/vcpkg-make.md b/docs/maintainers/ports/vcpkg-make.md new file mode 100644 index 00000000000000..ae134c2163b520 --- /dev/null +++ b/docs/maintainers/ports/vcpkg-make.md @@ -0,0 +1,7 @@ +# vcpkg-make + +This port contains make functions for dealing with a Makefile buildsystem. + +In the common case, `vcpkg_make_configure()` (with appropriate arguments) +followed by `vcpkg_make_install()` will be enough to build and install a port. +`vcpkg_make_build()` is provided for more complex cases. diff --git a/docs/maintainers/ports/vcpkg-make/vcpkg_make_build.md b/docs/maintainers/ports/vcpkg-make/vcpkg_make_build.md new file mode 100644 index 00000000000000..25d9a5c0f1b589 --- /dev/null +++ b/docs/maintainers/ports/vcpkg-make/vcpkg_make_build.md @@ -0,0 +1,59 @@ +# vcpkg_make_build + +The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/maintainers/ports/vcpkg-make/vcpkg_make_build.md). + +Build a linux makefile project. + +```cmake +vcpkg_make_build( + [BUILD_TARGET ] + [ADD_BIN_TO_PATH] + [ENABLE_INSTALL] + [MAKEFILE ] + [DISABLE_PARALLEL] + [LOGFILE_BASE ] +) +``` + +`vcpkg_make_build` builds an already-configured make project. +You can use the alias [`vcpkg_make_install()`] function +if the Makefile build system supports the `install` TARGET, +and this is something we recommend doing whenever possible. +Otherwise, you can directly call `vcpkg_make_build` without `ENABLE_INSTALL`. + +By default, `vcpkg_make_build` will call the `Makefile` in the build directory +and build all the targets. + +If the makefile comes from another path or the name is not `Makefile`, please +pass `MAKEFILE` and set the absolute path. +Please pass `BUILD_TARGET` to select the needed targets. + +When `ENABLE_INSTALL` is enabled, `vcpkg_make_build` will install all targets +unless `INSTALL_TARGET` is declared as some specific targets. + +`LOGFILE_BASE` is used to set the base of the logfile names; +by default, this is `build`, and thus the logfiles end up being something like +`build-x86-windows-dbg.log`; if you use `vcpkg_cmake_install`, +this is set to `install`, so you'll get log names like `install-x86-windows-dbg.log`. + +For build systems that are buggy when run in parallel, +using `DISABLE_PARALLEL` will run the build with only one job. + +Finally, `ADD_BIN_TO_PATH` adds the appropriate (either release or debug) +`bin/` directories to the path during the build, +such that executables run during the build will be able to access those DLLs. + +## Notes: +This command should be preceded by a call to [`vcpkg_make_configure()`](vcpkg_make_configure.md). +You can use the alias [`vcpkgl_make_install()`](vcpkgl_make_install.md) function if your makefile +supports the "install" target. + +## Examples + +* [x264](https://github.com/Microsoft/vcpkg/blob/master/ports/x264/portfile.cmake) +* [tcl](https://github.com/Microsoft/vcpkg/blob/master/ports/tcl/portfile.cmake) +* [freexl](https://github.com/Microsoft/vcpkg/blob/master/ports/freexl/portfile.cmake) +* [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake) + +## Source +[ports/vcpkg-make/vcpkg\_make\_build.cmake](https://github.com/Microsoft/vcpkg/blob/master/ports/vcpkg-make/vcpkg_make_build.cmake) diff --git a/docs/maintainers/ports/vcpkg-make/vcpkg_make_configure.md b/docs/maintainers/ports/vcpkg-make/vcpkg_make_configure.md new file mode 100644 index 00000000000000..a40b318ee35cb0 --- /dev/null +++ b/docs/maintainers/ports/vcpkg-make/vcpkg_make_configure.md @@ -0,0 +1,76 @@ +# vcpkg_make_configure + +The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/maintainers/ports/vcpkg-make/vcpkg_make_configure.md). + +Configure a Makefile buildsystem. + +```cmake +vcpkg_make_configure( + SOURCE_PATH <${source_path}> + [AUTOCONFIG] + [USE_WRAPPERS] + [DETERMINE_BUILD_TRIPLET] + [BUILD_TRIPLET "--host=x64 --build=i686-unknown-pc"] + [NO_ADDITIONAL_PATHS] + [CONFIG_DEPENDENT_ENVIRONMENT ...] + [CONFIGURE_ENVIRONMENT_VARIABLES ...] + [ADD_BIN_TO_PATH] + [NO_DEBUG] + [SKIP_CONFIGURE] + [PROJECT_SUBPATH <${proj_subpath}>] + [PRERUN_SHELL <${shell_path}>] + [OPTIONS <--use_this_in_all_builds=1>...] + [OPTIONS_RELEASE <--optimize=1>...] + [OPTIONS_DEBUG <--debuggable=1>...] +) +``` + +`vcpkg_make_configure` configures a Makefile build system for use with +`vcpkg_make_buildsystem_build` and `vcpkg_make_buildsystem_install`. +`source-path` is where the source is located; by convention, +this is usually `${SOURCE_PATH}`, which is set by one of the `vcpkg_from_*` functions. +Use `PROJECT_SUBPATH` if `configure`/`configure.ac` is elsewhere in the source directory. +This function configures the build system for both Debug and Release builds by default, +assuming that `VCPKG_BUILD_TYPE` is not set; if it is, then it will only configure for +that build type. All default build configurations will be obtained from cmake +configuration through `z_vcpkg_get_cmake_vars`. + +Use the `OPTIONS` argument to set the configure settings for both release and debug, +and use `OPTIONS_RELEASE` and `OPTIONS_DEBUG` to set the configure settings for +release only and debug only respectively. + +`vcpkg_make_configure` uses [mingw] as its build system on Windows and uses [GNU Make] +on non-Windows. +Do not use for batch files which simply call autoconf or configure. + +[mingw]: https://www.mingw-w64.org/ +[GNU Make]: https://www.gnu.org/software/make/ + +By default, `vcpkg_make_configure` uses the current architecture as the --build/--target/--host. +For cross-platform construction, use `DETERMINE_BUILD_TRIPLET` to adapt to the host platform. +You can also use `BUILD_TRIPLET` to specify --build/--target/--host, this option will overwrite +`VCPKG_MAKE_BUILD_TRIPLET` globally. + +For some libraries, additional scripts need to be called before configure, pass `PRERUN_SHELL` +and set the script relative path. + +Use `ADD_BIN_TO_PATH` during configuration to add the appropriate Release and Debug `bin\` +directories to the path so that the executable file can run against the in-tree DLL. +Use `NO_ADDITIONAL_PATHS `to not add additional paths except `--prefix` to configure. + +Use `USE_WRAPPERS` to use autotools ar-lib and compile wrappers when building Windows. + +Use `DISABLE_VERBOSE_FLAGS` to not pass '--disable-silent-rules --verbose' to configure. + +## Notes +This command supplies many common arguments to configure. To see the full list, examine the source. + +## Examples + +* [x264](https://github.com/Microsoft/vcpkg/blob/master/ports/x264/portfile.cmake) +* [tcl](https://github.com/Microsoft/vcpkg/blob/master/ports/tcl/portfile.cmake) +* [freexl](https://github.com/Microsoft/vcpkg/blob/master/ports/freexl/portfile.cmake) +* [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake) + +## Source +[ports/vcpkg-make/vcpkg\_make\_configure.cmake](https://github.com/Microsoft/vcpkg/blob/master/ports/vcpkg-make/vcpkg_make_configure.cmake) diff --git a/docs/maintainers/ports/vcpkg-make/vcpkg_make_install.md b/docs/maintainers/ports/vcpkg-make/vcpkg_make_install.md new file mode 100644 index 00000000000000..e6b9a24cb67f43 --- /dev/null +++ b/docs/maintainers/ports/vcpkg-make/vcpkg_make_install.md @@ -0,0 +1,25 @@ +# vcpkg_install_make + +The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/maintainers/ports/vcpkg-make/vcpkg_make_install.md). + +Build and install a make project. + +```cmake +vcpkg_make_install( + [DISABLE_PARALLEL] + [ADD_BIN_TO_PATH] +) +``` + +`vcpkg_make_install` transparently forwards to [`vcpkg_make_build()`], +with additional parameters to set `ENABLE_INSTALL`, +and to set the `LOGFILE_BASE` to `install` as well. + +[`vcpkg_make_build()`]: vcpkg_make_build.cmake + +## Examples + +* [x264](https://github.com/Microsoft/vcpkg/blob/master/ports/x264/portfile.cmake) + +## Source +[ports/vcpkg-make/vcpkg\_make\_install.cmake](https://github.com/Microsoft/vcpkg/blob/master/ports/vcpkg-make/vcpkg_make_install.cmake) diff --git a/docs/maintainers/vcpkg_build_make.md b/docs/maintainers/vcpkg_build_make.md index a274b6f6e42ab1..638c331f41b7f3 100644 --- a/docs/maintainers/vcpkg_build_make.md +++ b/docs/maintainers/vcpkg_build_make.md @@ -1,5 +1,7 @@ # vcpkg_build_make +**This function has been deprecated in favor of [`vcpkg_make_build`](ports/vcpkg-make/vcpkg_make_build.md) from the vcpkg-make port.** + The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/maintainers/vcpkg_build_make.md). Build a linux makefile project. diff --git a/docs/maintainers/vcpkg_configure_make.md b/docs/maintainers/vcpkg_configure_make.md index ebf80521af7718..e8ac99f6146ef2 100644 --- a/docs/maintainers/vcpkg_configure_make.md +++ b/docs/maintainers/vcpkg_configure_make.md @@ -1,5 +1,7 @@ # vcpkg_configure_make +**This function has been deprecated in favor of [`vcpkg_make_configure`](ports/vcpkg-make/vcpkg_make_configure.md) from the vcpkg-make port.** + The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/maintainers/vcpkg_configure_make.md). Configure configure for Debug and Release builds of a project. diff --git a/docs/maintainers/vcpkg_install_make.md b/docs/maintainers/vcpkg_install_make.md index 19f4b5ca8f1e3b..4a39f226fd8a9f 100644 --- a/docs/maintainers/vcpkg_install_make.md +++ b/docs/maintainers/vcpkg_install_make.md @@ -1,5 +1,7 @@ # vcpkg_install_make +**This function has been deprecated in favor of [`vcpkg_make_install`](ports/vcpkg-make/vcpkg_make_install.md) from the vcpkg-make port.** + The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/maintainers/vcpkg_install_make.md). Build and install a make project. diff --git a/docs/regenerate.ps1 b/docs/regenerate.ps1 index f2f888a770046a..af9dc24d4038c8 100755 --- a/docs/regenerate.ps1 +++ b/docs/regenerate.ps1 @@ -29,6 +29,7 @@ class CMakeDocumentation { 'vcpkg-cmake' 'vcpkg-cmake-config' 'vcpkg-pkgconfig-get-modules' + 'vcpkg-make' ) [CMakeDocumentation[]]$tableOfContents = @() diff --git a/ports/apr-util/portfile.cmake b/ports/apr-util/portfile.cmake index 1065bdb7234c0c..f9c1f8baf6db8c 100644 --- a/ports/apr-util/portfile.cmake +++ b/ports/apr-util/portfile.cmake @@ -62,7 +62,7 @@ else(VCPKG_TARGET_IS_WINDOWS) message(STATUS "Configuring apr-util") endif() - vcpkg_configure_make( + vcpkg_make_configure( SOURCE_PATH "${SOURCE_PATH}" NO_DEBUG OPTIONS @@ -75,7 +75,7 @@ else(VCPKG_TARGET_IS_WINDOWS) "${CONFIGURE_PARAMETER_3}" ) - vcpkg_install_make() + vcpkg_make_install() endif() diff --git a/ports/apr-util/vcpkg.json b/ports/apr-util/vcpkg.json index aa7937210aa20c..a0082c567007ce 100644 --- a/ports/apr-util/vcpkg.json +++ b/ports/apr-util/vcpkg.json @@ -1,12 +1,16 @@ { "name": "apr-util", "version-string": "1.6.1", - "port-version": 4, + "port-version": 5, "description": "Apache Portable Runtime (APR) project mission is to create and maintain software libraries that provide a predictable and consistent interface to underlying platform-specific implementation", "homepage": "https://apr.apache.org/", "dependencies": [ "apr", "expat", - "openssl" + "openssl", + { + "name": "vcpkg-make", + "host": true + } ] } diff --git a/ports/apr/portfile.cmake b/ports/apr/portfile.cmake index 3b9bed66415f1c..f18f906f4d6680 100644 --- a/ports/apr/portfile.cmake +++ b/ports/apr/portfile.cmake @@ -66,7 +66,7 @@ else() message(STATUS "Configuring apr") endif() set(ENV{CFLAGS} "$ENV{CFLAGS} -Wno-error=implicit-function-declaration") - vcpkg_configure_make( + vcpkg_make_configure( SOURCE_PATH "${SOURCE_PATH}" NO_DEBUG OPTIONS @@ -76,7 +76,7 @@ else() "${CONFIGURE_PARAMETER_3}" ) - vcpkg_install_make() + vcpkg_make_install() vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/apr-1.pc "-lapr-\${APR_MAJOR_VERSION}" "-lapr-1" diff --git a/ports/apr/vcpkg.json b/ports/apr/vcpkg.json index 91fb9c71307363..a6b34ace35837a 100644 --- a/ports/apr/vcpkg.json +++ b/ports/apr/vcpkg.json @@ -1,10 +1,16 @@ { "name": "apr", "version": "1.7.0", - "port-version": 4, + "port-version": 5, "description": "The Apache Portable Runtime (APR) is a C library that forms a system portability layer that covers many operating systems.", "homepage": "https://apr.apache.org/", "supports": "!uwp", + "dependencies": [ + { + "name": "vcpkg-make", + "host": true + } + ], "features": { "private-headers": { "description": "Install non-standard files required for building Apache httpd" diff --git a/ports/gdal/portfile.cmake b/ports/gdal/portfile.cmake index 5ccf4e8e61072d..2a96ba68d3f169 100644 --- a/ports/gdal/portfile.cmake +++ b/ports/gdal/portfile.cmake @@ -317,7 +317,7 @@ else() list(APPEND CONF_OPTS "--with-tools=no") endif() - vcpkg_configure_make( + vcpkg_make_configure( SOURCE_PATH "${SOURCE_PATH}/gdal" AUTOCONFIG COPY_SOURCE @@ -349,8 +349,8 @@ else() endif() endforeach() - vcpkg_install_make(MAKEFILE GNUmakefile) - + vcpkg_make_install(MAKEFILE GNUmakefile) + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/gdalplugins" "${CURRENT_PACKAGES_DIR}/debug/lib/gdalplugins" diff --git a/ports/gdal/vcpkg.json b/ports/gdal/vcpkg.json index 77d8cbf287227a..dd6f4b241a6255 100644 --- a/ports/gdal/vcpkg.json +++ b/ports/gdal/vcpkg.json @@ -1,7 +1,7 @@ { "name": "gdal", "version-semver": "3.3.2", - "port-version": 2, + "port-version": 3, "description": "The Geographic Data Abstraction Library for reading and writing geospatial raster and vector data", "homepage": "https://gdal.org", "supports": "!arm", @@ -28,6 +28,10 @@ "proj4", "sqlite3", "tiff", + { + "name": "vcpkg-make", + "host": true + }, "zlib", "zstd" ], diff --git a/ports/gettext/portfile.cmake b/ports/gettext/portfile.cmake index 0c351d73505490..1bff1fb375d687 100644 --- a/ports/gettext/portfile.cmake +++ b/ports/gettext/portfile.cmake @@ -65,7 +65,7 @@ function(build_libintl_and_tools) if(DEFINED arg_BUILD_TYPE) set(VCPKG_BUILD_TYPE "${arg_BUILD_TYPE}") endif() - vcpkg_configure_make(SOURCE_PATH "${SOURCE_PATH}" + vcpkg_make_configure(SOURCE_PATH "${SOURCE_PATH}" DETERMINE_BUILD_TRIPLET USE_WRAPPERS ADD_BIN_TO_PATH # So configure can check for working iconv @@ -73,7 +73,7 @@ function(build_libintl_and_tools) OPTIONS ${OPTIONS} ) - vcpkg_install_make(MAKEFILE "${CMAKE_CURRENT_LIST_DIR}/Makefile") + vcpkg_make_install(MAKEFILE "${CMAKE_CURRENT_LIST_DIR}/Makefile") endfunction() function(build_libintl_only) @@ -81,14 +81,14 @@ function(build_libintl_only) if(DEFINED arg_BUILD_TYPE) set(VCPKG_BUILD_TYPE "${arg_BUILD_TYPE}") endif() - vcpkg_configure_make(SOURCE_PATH "${SOURCE_PATH}/gettext-runtime" + vcpkg_make_configure(SOURCE_PATH "${SOURCE_PATH}/gettext-runtime" DETERMINE_BUILD_TRIPLET USE_WRAPPERS ADD_BIN_TO_PATH # So configure can check for working iconv OPTIONS ${OPTIONS} ) - vcpkg_install_make( + vcpkg_make_install( MAKEFILE "${CMAKE_CURRENT_LIST_DIR}/Makefile" BUILD_TARGET build-intl INSTALL_TARGET install-intl diff --git a/ports/gettext/vcpkg.json b/ports/gettext/vcpkg.json index bd1f1d4b6c9857..ff981fc1e2ff78 100644 --- a/ports/gettext/vcpkg.json +++ b/ports/gettext/vcpkg.json @@ -1,11 +1,15 @@ { "name": "gettext", "version": "0.21", - "port-version": 6, + "port-version": 7, "description": "GNU gettext provides libintl and a set of tools to help produce multi-lingual messages.", "homepage": "https://www.gnu.org/software/gettext/", "dependencies": [ - "libiconv" + "libiconv", + { + "name": "vcpkg-make", + "host": true + } ], "features": { "tools": { diff --git a/ports/healpix/portfile.cmake b/ports/healpix/portfile.cmake index dde1ac3c170adc..56ea9635577e53 100644 --- a/ports/healpix/portfile.cmake +++ b/ports/healpix/portfile.cmake @@ -10,17 +10,17 @@ vcpkg_from_sourceforge( PATCHES fix-dependency.patch ) -vcpkg_configure_make( - AUTOCONFIG +vcpkg_make_configure( SOURCE_PATH ${SOURCE_PATH} PROJECT_SUBPATH src/cxx + AUTOCONFIG COPY_SOURCE OPTIONS --with-libcfitsio-include=${CURRENT_INSTALLED_DIR}/include/cfitsio --with-libcfitsio-lib=${CURRENT_INSTALLED_DIR}/lib ) -vcpkg_build_make(BUILD_TARGET compile_all) +vcpkg_make_build(BUILD_TARGET compile_all) #vcpkg_fixup_pkgconfig() # Install manually because healpix has no install target diff --git a/ports/healpix/vcpkg.json b/ports/healpix/vcpkg.json index 15b383f089fb74..dcdf0d609f1ac0 100644 --- a/ports/healpix/vcpkg.json +++ b/ports/healpix/vcpkg.json @@ -1,11 +1,15 @@ { "name": "healpix", "version-string": "1.12.10", - "port-version": 8, + "port-version": 9, "description": "HEALPix is an acronym for Hierarchical Equal Area isoLatitude Pixelation of a sphere.", "homepage": "http://healpix.sourceforge.net/", "supports": "linux", "dependencies": [ - "cfitsio" + "cfitsio", + { + "name": "vcpkg-make", + "host": true + } ] } diff --git a/ports/hunspell/portfile.cmake b/ports/hunspell/portfile.cmake index 053d1dda4f70c4..751e50b6c0d5af 100644 --- a/ports/hunspell/portfile.cmake +++ b/ports/hunspell/portfile.cmake @@ -61,15 +61,14 @@ else() file(WRITE "${SOURCE_PATH}/src/Makefile.am" "${_contents}") endif() vcpkg_add_to_path("${CURRENT_HOST_INSTALLED_DIR}/tools/gettext/bin") - vcpkg_configure_make( + vcpkg_make_configure( SOURCE_PATH ${SOURCE_PATH} - OPTIONS AUTOCONFIG ADDITIONAL_MSYS_PACKAGES gzip ) #install-pkgconfDATA: - vcpkg_build_make(BUILD_TARGET dist LOGFILE_ROOT build-dist) - vcpkg_install_make() + vcpkg_make_build(BUILD_TARGET dist LOGFILE_BASE build-dist) + vcpkg_make_install() file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug") vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin") diff --git a/ports/hunspell/vcpkg.json b/ports/hunspell/vcpkg.json index c89c4ca94ac102..dce20832fca90c 100644 --- a/ports/hunspell/vcpkg.json +++ b/ports/hunspell/vcpkg.json @@ -1,7 +1,7 @@ { "name": "hunspell", "version": "1.7.0", - "port-version": 5, + "port-version": 6, "description": "The most popular spellchecking library.", "homepage": "https://github.com/hunspell/hunspell", "supports": "!((arm | uwp) & windows)", @@ -13,7 +13,11 @@ "tools" ] }, - "libiconv" + "libiconv", + { + "name": "vcpkg-make", + "host": true + } ], "features": { "tools": { diff --git a/ports/icu/portfile.cmake b/ports/icu/portfile.cmake index 66905dd70ea125..541f63f7e24d5f 100644 --- a/ports/icu/portfile.cmake +++ b/ports/icu/portfile.cmake @@ -45,7 +45,7 @@ elseif(VCPKG_CROSSCOMPILING) list(APPEND CONFIGURE_OPTIONS "--with-cross-build=${_VCPKG_TOOL_PATH}") endif() -vcpkg_configure_make( +vcpkg_make_configure( SOURCE_PATH ${SOURCE_PATH} PROJECT_SUBPATH source OPTIONS ${CONFIGURE_OPTIONS} @@ -56,7 +56,7 @@ vcpkg_configure_make( if(VCPKG_TARGET_IS_OSX AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND (NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")) - vcpkg_build_make() + vcpkg_make_build() # remove this block if https://unicode-org.atlassian.net/browse/ICU-21458 # is resolved and use the configure script instead if(DEFINED CMAKE_INSTALL_NAME_DIR) @@ -125,7 +125,7 @@ if(VCPKG_TARGET_IS_OSX AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND (NOT DEF ) endif() -vcpkg_install_make() +vcpkg_make_install() file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/share diff --git a/ports/icu/vcpkg.json b/ports/icu/vcpkg.json index 37d08e43dc1924..babc7144c5df3e 100644 --- a/ports/icu/vcpkg.json +++ b/ports/icu/vcpkg.json @@ -1,7 +1,7 @@ { "name": "icu", "version": "69.1", - "port-version": 15, + "port-version": 16, "description": "Mature and widely used Unicode and localization library.", "homepage": "https://icu.unicode.org/home", "supports": "!uwp", @@ -9,6 +9,10 @@ { "name": "icu", "host": true + }, + { + "name": "vcpkg-make", + "host": true } ] } diff --git a/ports/libiconv/portfile.cmake b/ports/libiconv/portfile.cmake index 9d8ff25aa030b1..63600584093d22 100644 --- a/ports/libiconv/portfile.cmake +++ b/ports/libiconv/portfile.cmake @@ -26,16 +26,17 @@ if (NOT VCPKG_TARGET_IS_ANDROID) list(APPEND OPTIONS --enable-relocatable) endif() -vcpkg_configure_make(SOURCE_PATH ${SOURCE_PATH} - DETERMINE_BUILD_TRIPLET - USE_WRAPPERS - OPTIONS - --enable-extra-encodings - --without-libiconv-prefix - --without-libintl-prefix - ${OPTIONS} - ) -vcpkg_install_make() +vcpkg_make_configure( + SOURCE_PATH ${SOURCE_PATH} + DETERMINE_BUILD_TRIPLET + USE_WRAPPERS + OPTIONS + --enable-extra-encodings + --without-libiconv-prefix + --without-libintl-prefix + ${OPTIONS} +) +vcpkg_make_install() vcpkg_copy_pdbs() vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin) diff --git a/ports/libiconv/vcpkg.json b/ports/libiconv/vcpkg.json index 2cafb021836a0a..5a99bf148f62ab 100644 --- a/ports/libiconv/vcpkg.json +++ b/ports/libiconv/vcpkg.json @@ -1,7 +1,13 @@ { "name": "libiconv", "version": "1.16", - "port-version": 11, + "port-version": 12, "description": "GNU Unicode text conversion", - "homepage": "https://www.gnu.org/software/libiconv/" + "homepage": "https://www.gnu.org/software/libiconv/", + "dependencies": [ + { + "name": "vcpkg-make", + "host": true + } + ] } diff --git a/ports/liburing/portfile.cmake b/ports/liburing/portfile.cmake index 304bef5ecc676a..959f278efbca9c 100644 --- a/ports/liburing/portfile.cmake +++ b/ports/liburing/portfile.cmake @@ -12,12 +12,12 @@ vcpkg_from_github( ) # note: check ${SOURCE_PATH}/liburing.spec before updating configure options -vcpkg_configure_make( +vcpkg_make_configure( SOURCE_PATH ${SOURCE_PATH} COPY_SOURCE NO_DEBUG ) -vcpkg_install_make() +vcpkg_make_install() vcpkg_fixup_pkgconfig() file(INSTALL ${SOURCE_PATH}/LICENSE diff --git a/ports/liburing/vcpkg.json b/ports/liburing/vcpkg.json index e2bb1b53e23a5f..8d451da4b6dcae 100644 --- a/ports/liburing/vcpkg.json +++ b/ports/liburing/vcpkg.json @@ -1,7 +1,14 @@ { "name": "liburing", "version": "2.0", + "port-version": 1, "description": "Linux-native io_uring I/O access library", "homepage": "https://github.com/axboe/liburing", - "supports": "linux" + "supports": "linux", + "dependencies": [ + { + "name": "vcpkg-make", + "host": true + } + ] } diff --git a/ports/ncurses/portfile.cmake b/ports/ncurses/portfile.cmake index 71ccfda8b11826..bb1043be7f15f9 100644 --- a/ports/ncurses/portfile.cmake +++ b/ports/ncurses/portfile.cmake @@ -40,14 +40,14 @@ set(OPTIONS_RELEASE --without-debug ) -vcpkg_configure_make( +vcpkg_make_configure( SOURCE_PATH ${SOURCE_PATH} OPTIONS ${OPTIONS} OPTIONS_DEBUG ${OPTIONS_DEBUG} OPTIONS_RELEASE ${OPTIONS_RELEASE} NO_ADDITIONAL_PATHS ) -vcpkg_install_make() +vcpkg_make_install() vcpkg_fixup_pkgconfig() diff --git a/ports/ncurses/vcpkg.json b/ports/ncurses/vcpkg.json index a0aa9df575e10d..5692847150b75a 100644 --- a/ports/ncurses/vcpkg.json +++ b/ports/ncurses/vcpkg.json @@ -1,7 +1,13 @@ { "name": "ncurses", "version-string": "6.2", - "port-version": 1, + "port-version": 2, "description": "free software emulation of curses in System V Release 4.0", - "supports": "!(windows | uwp)" + "supports": "!(windows | uwp)", + "dependencies": [ + { + "name": "vcpkg-make", + "host": true + } + ] } diff --git a/ports/starlink-ast/portfile.cmake b/ports/starlink-ast/portfile.cmake index 92475ad5509dc2..bfe506db966364 100644 --- a/ports/starlink-ast/portfile.cmake +++ b/ports/starlink-ast/portfile.cmake @@ -29,7 +29,7 @@ else() list(APPEND CONFIGURE_OPTIONS --without-pthreads) endif() -vcpkg_configure_make( +vcpkg_make_configure( SOURCE_PATH "${SOURCE_PATH}" USE_WRAPPERS DETERMINE_BUILD_TRIPLET @@ -37,7 +37,7 @@ vcpkg_configure_make( OPTIONS ${CONFIGURE_OPTIONS} ) -vcpkg_install_make() +vcpkg_make_install() file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share") diff --git a/ports/starlink-ast/vcpkg.json b/ports/starlink-ast/vcpkg.json index 5c3753df6b4cdd..c27361df757ecc 100644 --- a/ports/starlink-ast/vcpkg.json +++ b/ports/starlink-ast/vcpkg.json @@ -1,10 +1,16 @@ { "name": "starlink-ast", "version-semver": "9.2.4", - "port-version": 2, + "port-version": 3, "description": "The AST library provides a comprehensive range of facilities for attaching world coordinate systems to astronomical data, for retrieving and interpreting that information and for generating graphical output based on it", "homepage": "https://starlink.eao.hawaii.edu/starlink/AST", "supports": "windows", + "dependencies": [ + { + "name": "vcpkg-make", + "host": true + } + ], "features": { "pthreads": { "description": "build with POSIX threads support", diff --git a/ports/vcpkg-make/README.md b/ports/vcpkg-make/README.md new file mode 100644 index 00000000000000..ae134c2163b520 --- /dev/null +++ b/ports/vcpkg-make/README.md @@ -0,0 +1,7 @@ +# vcpkg-make + +This port contains make functions for dealing with a Makefile buildsystem. + +In the common case, `vcpkg_make_configure()` (with appropriate arguments) +followed by `vcpkg_make_install()` will be enough to build and install a port. +`vcpkg_make_build()` is provided for more complex cases. diff --git a/ports/vcpkg-make/copyright b/ports/vcpkg-make/copyright new file mode 100644 index 00000000000000..2e4eac8264fa4c --- /dev/null +++ b/ports/vcpkg-make/copyright @@ -0,0 +1,23 @@ +Copyright (c) Microsoft Corporation + +All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ports/vcpkg-make/portfile.cmake b/ports/vcpkg-make/portfile.cmake new file mode 100644 index 00000000000000..25fca3be4dbb1e --- /dev/null +++ b/ports/vcpkg-make/portfile.cmake @@ -0,0 +1,14 @@ +if(NOT TARGET_TRIPLET STREQUAL _HOST_TRIPLET) + # make FATAL_ERROR in CI when issue #16773 fixed + message(WARNING "vcpkg-make is a host-only port; please mark it as a host port in your dependencies.") +endif() + +file(INSTALL + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_configure.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_build.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_install.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" + "${CMAKE_CURRENT_LIST_DIR}/copyright" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/ports/vcpkg-make/vcpkg-port-config.cmake b/ports/vcpkg-make/vcpkg-port-config.cmake new file mode 100644 index 00000000000000..48f7cb8b8e30f9 --- /dev/null +++ b/ports/vcpkg-make/vcpkg-port-config.cmake @@ -0,0 +1,3 @@ +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_configure.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_build.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_install.cmake") diff --git a/ports/vcpkg-make/vcpkg.json b/ports/vcpkg-make/vcpkg.json new file mode 100644 index 00000000000000..a0b09becf7f7b9 --- /dev/null +++ b/ports/vcpkg-make/vcpkg.json @@ -0,0 +1,4 @@ +{ + "name": "vcpkg-make", + "version-date": "2021-08-25" +} diff --git a/ports/vcpkg-make/vcpkg_make_build.cmake b/ports/vcpkg-make/vcpkg_make_build.cmake new file mode 100644 index 00000000000000..e87a79b62d6dca --- /dev/null +++ b/ports/vcpkg-make/vcpkg_make_build.cmake @@ -0,0 +1,246 @@ +#[===[.md: +# vcpkg_make_build + +Build a linux makefile project. + +```cmake +vcpkg_make_build( + [BUILD_TARGET ] + [ADD_BIN_TO_PATH] + [ENABLE_INSTALL] + [MAKEFILE ] + [DISABLE_PARALLEL] + [LOGFILE_BASE ] +) +``` + +`vcpkg_make_build` builds an already-configured make project. +You can use the alias [`vcpkg_make_install()`] function +if the Makefile build system supports the `install` TARGET, +and this is something we recommend doing whenever possible. +Otherwise, you can directly call `vcpkg_make_build` without `ENABLE_INSTALL`. + +By default, `vcpkg_make_build` will call the `Makefile` in the build directory +and build all the targets. + +If the makefile comes from another path or the name is not `Makefile`, please +pass `MAKEFILE` and set the absolute path. +Please pass `BUILD_TARGET` to select the needed targets. + +When `ENABLE_INSTALL` is enabled, `vcpkg_make_build` will install all targets +unless `INSTALL_TARGET` is declared as some specific targets. + +`LOGFILE_BASE` is used to set the base of the logfile names; +by default, this is `build`, and thus the logfiles end up being something like +`build-x86-windows-dbg.log`; if you use `vcpkg_cmake_install`, +this is set to `install`, so you'll get log names like `install-x86-windows-dbg.log`. + +For build systems that are buggy when run in parallel, +using `DISABLE_PARALLEL` will run the build with only one job. + +Finally, `ADD_BIN_TO_PATH` adds the appropriate (either release or debug) +`bin/` directories to the path during the build, +such that executables run during the build will be able to access those DLLs. + +## Notes: +This command should be preceded by a call to [`vcpkg_make_configure()`](vcpkg_make_configure.md). +You can use the alias [`vcpkgl_make_install()`](vcpkgl_make_install.md) function if your makefile +supports the "install" target. + +## Examples + +* [x264](https://github.com/Microsoft/vcpkg/blob/master/ports/x264/portfile.cmake) +* [tcl](https://github.com/Microsoft/vcpkg/blob/master/ports/tcl/portfile.cmake) +* [freexl](https://github.com/Microsoft/vcpkg/blob/master/ports/freexl/portfile.cmake) +* [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake) +#]===] + +if(Z_VCPKG_MAKE_BUILD_GUARD) + return() +endif() +set(Z_VCPKG_MAKE_BUILD_GUARD ON CACHE INTERNAL "guard variable") + +function(vcpkg_make_build) + z_vcpkg_get_cmake_vars(cmake_vars_file) + include("${cmake_vars_file}") + + # parse parameters such that semicolons in options arguments to COMMAND don't get erased + cmake_parse_arguments(PARSE_ARGV 0 arg + "ADD_BIN_TO_PATH;ENABLE_INSTALL;DISABLE_PARALLEL" + "LOGFILE_BASE;BUILD_TARGET;MAKEFILE;INSTALL_TARGET" + "OPTIONS" + ) + + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "vcpkg_make_build was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + + if(NOT DEFINED arg_LOGFILE_BASE) + set(arg_LOGFILE_BASE "build") + endif() + + if(NOT DEFINED arg_BUILD_TARGET) + set(arg_BUILD_TARGET "all") + endif() + + 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(Z_VCPKG_INSTALLED ${CURRENT_INSTALLED_DIR}) + else() + string(REPLACE " " "\ " Z_VCPKG_INSTALLED "${CURRENT_INSTALLED_DIR}") + endif() + + vcpkg_list(SET make_opts) + vcpkg_list(SET install_opts) + if (CMAKE_HOST_WIN32) + 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}") + 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}") + 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) + find_program(Z_VCPKG_MAKE gmake REQUIRED) + else() + find_program(Z_VCPKG_MAKE make REQUIRED) + endif() + 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_make_configure + vcpkg_backup_env_variables(VARS LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) + + 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. + set(short_buildtype "-rel") + set(cmake_buildtype "RELEASE") + set(path_suffix "") + endif() + + set(working_directory "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${short_buildtype}") + message(STATUS "Building ${TARGET_TRIPLET}${short_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}}") + else() # dynamic + set(LINKER_FLAGS_${cmake_buildtype} "${VCPKG_DETECTED_SHARED_LINKER_FLAGS_${cmake_buildtype}}") + endif() + 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${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}}") + 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(config_link_backup "$ENV{_LINK_}") + set(ENV{_LINK_} "${LINK_ENV_${_VAR_SUFFIX}}") + endif() + + if(arg_ADD_BIN_TO_PATH) + set(env_backup_path "$ENV{PATH}") + vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${path_suffix}/bin") + 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 (arg_DISABLE_PARALLEL) + vcpkg_execute_build_process( + COMMAND ${no_parallel_make_cmd_line} + WORKING_DIRECTORY "${working_directory}" + LOGNAME "${arg_LOGFILE_BASE}-${TARGET_TRIPLET}${short_buildtype}" + ) + else() + vcpkg_execute_build_process( + COMMAND ${make_cmd_line} + NO_PARALLEL_COMMAND ${no_parallel_make_cmd_line} + WORKING_DIRECTORY "${working_directory}" + LOGNAME "${arg_LOGFILE_BASE}-${TARGET_TRIPLET}${short_buildtype}" + ) + endif() + + file(READ "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-${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 (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_cmd_line} + WORKING_DIRECTORY "${working_directory}" + LOGNAME "install-${TARGET_TRIPLET}${short_buildtype}" + ) + endif() + + if(config_link_backup) + set(ENV{_LINK_} "${config_link_backup}") + unset(config_link_backup) + endif() + + if(arg_ADD_BIN_TO_PATH) + set(ENV{PATH} "${env_backup_path}") + endif() + endif() + endforeach() + + 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${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}) + endif() + + if (CMAKE_HOST_WIN32) + set(ENV{PATH} "${path_backup}") + endif() + + vcpkg_restore_env_variables(VARS LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) +endfunction() diff --git a/ports/vcpkg-make/vcpkg_make_configure.cmake b/ports/vcpkg-make/vcpkg_make_configure.cmake new file mode 100644 index 00000000000000..6db4f543d9add0 --- /dev/null +++ b/ports/vcpkg-make/vcpkg_make_configure.cmake @@ -0,0 +1,842 @@ +#[===[.md: +# vcpkg_make_configure + +Configure a Makefile buildsystem. + +```cmake +vcpkg_make_configure( + SOURCE_PATH <${source_path}> + [AUTOCONFIG] + [USE_WRAPPERS] + [DETERMINE_BUILD_TRIPLET] + [BUILD_TRIPLET "--host=x64 --build=i686-unknown-pc"] + [NO_ADDITIONAL_PATHS] + [CONFIG_DEPENDENT_ENVIRONMENT ...] + [CONFIGURE_ENVIRONMENT_VARIABLES ...] + [ADD_BIN_TO_PATH] + [NO_DEBUG] + [SKIP_CONFIGURE] + [PROJECT_SUBPATH <${proj_subpath}>] + [PRERUN_SHELL <${shell_path}>] + [OPTIONS <--use_this_in_all_builds=1>...] + [OPTIONS_RELEASE <--optimize=1>...] + [OPTIONS_DEBUG <--debuggable=1>...] +) +``` + +`vcpkg_make_configure` configures a Makefile build system for use with +`vcpkg_make_buildsystem_build` and `vcpkg_make_buildsystem_install`. +`source-path` is where the source is located; by convention, +this is usually `${SOURCE_PATH}`, which is set by one of the `vcpkg_from_*` functions. +Use `PROJECT_SUBPATH` if `configure`/`configure.ac` is elsewhere in the source directory. +This function configures the build system for both Debug and Release builds by default, +assuming that `VCPKG_BUILD_TYPE` is not set; if it is, then it will only configure for +that build type. All default build configurations will be obtained from cmake +configuration through `z_vcpkg_get_cmake_vars`. + +Use the `OPTIONS` argument to set the configure settings for both release and debug, +and use `OPTIONS_RELEASE` and `OPTIONS_DEBUG` to set the configure settings for +release only and debug only respectively. + +`vcpkg_make_configure` uses [mingw] as its build system on Windows and uses [GNU Make] +on non-Windows. +Do not use for batch files which simply call autoconf or configure. + +[mingw]: https://www.mingw-w64.org/ +[GNU Make]: https://www.gnu.org/software/make/ + +By default, `vcpkg_make_configure` uses the current architecture as the --build/--target/--host. +For cross-platform construction, use `DETERMINE_BUILD_TRIPLET` to adapt to the host platform. +You can also use `BUILD_TRIPLET` to specify --build/--target/--host, this option will overwrite +`VCPKG_MAKE_BUILD_TRIPLET` globally. + +For some libraries, additional scripts need to be called before configure, pass `PRERUN_SHELL` +and set the script relative path. + +Use `ADD_BIN_TO_PATH` during configuration to add the appropriate Release and Debug `bin\` +directories to the path so that the executable file can run against the in-tree DLL. +Use `NO_ADDITIONAL_PATHS `to not add additional paths except `--prefix` to configure. + +Use `USE_WRAPPERS` to use autotools ar-lib and compile wrappers when building Windows. + +Use `DISABLE_VERBOSE_FLAGS` to not pass '--disable-silent-rules --verbose' to configure. + +## Notes +This command supplies many common arguments to configure. To see the full list, examine the source. + +## Examples + +* [x264](https://github.com/Microsoft/vcpkg/blob/master/ports/x264/portfile.cmake) +* [tcl](https://github.com/Microsoft/vcpkg/blob/master/ports/tcl/portfile.cmake) +* [freexl](https://github.com/Microsoft/vcpkg/blob/master/ports/freexl/portfile.cmake) +* [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake) +#]===] + +if(Z_VCPKG_MAKE_CONFIGURE_GUARD) + return() +endif() +set(Z_VCPKG_CAKE_CONFIGURE_GUARD ON CACHE INTERNAL "guard variable") + +macro(z_vcpkg_determine_host_mingw out_var) + if(DEFINED ENV{PROCESSOR_ARCHITEW6432}) + set(host_arch $ENV{PROCESSOR_ARCHITEW6432}) + else() + set(host_arch $ENV{PROCESSOR_ARCHITECTURE}) + endif() + if(host_arch MATCHES "(amd|AMD)64") + set(${out_var} mingw64) + elseif(host_arch MATCHES "(x|X)86") + set(${out_var} mingw32) + else() + message(FATAL_ERROR "Unsupported mingw architecture ${host_arch} in z_vcpkg_determine_autotools_host_cpu!" ) + endif() + unset(host_arch) +endmacro() + +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}) + elseif(DEFINED ENV{PROCESSOR_ARCHITECTURE}) + set(host_arch $ENV{PROCESSOR_ARCHITECTURE}) + else() + set(host_arch "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}") + endif() + if(host_arch MATCHES "(amd|AMD)64") + set(${out_var} x86_64) + elseif(host_arch MATCHES "(x|X)86") + set(${out_var} i686) + elseif(host_arch MATCHES "^(ARM|arm)64$") + set(${out_var} aarch64) + elseif(host_arch MATCHES "^(ARM|arm)$") + set(${out_var} arm) + else() + message(FATAL_ERROR "Unsupported host architecture ${host_arch} in z_vcpkg_determine_autotools_host_cpu!" ) + endif() + unset(host_arch) +endmacro() + +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") + set(${out_var} i686) + elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)64$") + set(${out_var} aarch64) + elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)$") + set(${out_var} arm) + else() + message(FATAL_ERROR "Unsupported VCPKG_TARGET_ARCHITECTURE architecture ${VCPKG_TARGET_ARCHITECTURE} in z_vcpkg_determine_autotools_target_cpu!" ) + endif() +endmacro() + +macro(z_vcpkg_determine_autotools_host_arch_mac out_var) + set(${out_var} "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}") +endmacro() + +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(osx_archs_num GREATER_EQUAL 2) + set(${out_var} "universal") + else() + # Better match the arch behavior of config.guess + # See: https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD + if(VCPKG_OSX_ARCHITECTURES MATCHES "^(ARM|arm)64$") + set(${out_var} "aarch64") + else() + set(${out_var} "${VCPKG_OSX_ARCHITECTURES}") + endif() + endif() + unset(osx_archs_num) +endmacro() + +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_${flag_suffix} INCLUDE REGEX "(${CXXREGEX})") + else() + set(CPPFLAGS_${flag_suffix}) + endif() + 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_${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_${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_${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_${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_make_configure) + # parse parameters such that semicolons in options arguments to COMMAND don't get erased + 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(arg_BUILD_TRIPLET ${VCPKG_MAKE_BUILD_TRIPLET}) # Triplet overwrite for crosscompiling + endif() + + set(src_dir "${arg_SOURCE_PATH}/${arg_PROJECT_SUBPATH}") + + set(requires_autogen OFF) # use autogen.sh + set(requires_autoconfig OFF) # use autotools and configure.ac + if(arg_AUTOCONFIG) + set(requires_autoconfig ON) + elseif(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 ON) + file(REMOVE "${SRC_DIR}/configure") # remove possible autodated configure scripts + endif() + 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) + 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}") + + if(CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe") #only applies to windows (clang-)cl and lib + if(requires_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(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(VARS ${cm_FLAGS}) + + + # FC fotran compiler | FF Fortran 77 compiler + # LDFLAGS -> pass -L flags + # LIBS -> pass -l flags + + #Used by gcc/linux + vcpkg_backup_env_variables(VARS C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH) + + #Used by cl + vcpkg_backup_env_variables(VARS INCLUDE LIB LIBPATH) + + 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 ON) + endif() + + 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} ${arg_ADDITIONAL_MSYS_PACKAGES}) + endif() + if (requires_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(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 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 arg_BUILD_TRIPLET MATCHES "--host") + # Needs to be different from --build to enable cross builds. + string(APPEND arg_BUILD_TRIPLET " --host=${TARGET_ARCH}-unknown-mingw32") + endif() + debug_message("Using make triplet: ${arg_BUILD_TRIPLET}") + endif() + if(CMAKE_HOST_WIN32) + 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}") + set(ENV{PATH} "${NEWPATH}") + set(bash_executable "${MSYS_ROOT}/usr/bin/bash.exe") + endif() + + # 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 + VCPKG_DETECTED_CMAKE_STRIP VCPKG_DETECTED_CMAKE_NM VCPKG_DETECTED_CMAKE_DLLTOOL VCPKG_DETECTED_CMAKE_RC_COMPILER) + foreach(prog IN LISTS progs) + if(${prog}) + set(path "${${prog}}") + unset(prog_found CACHE) + get_filename_component(${prog} "${${prog}}" NAME) + find_program(prog_found ${${prog}} PATHS ENV PATH NO_DEFAULT_PATH) + if(NOT path STREQUAL prog_found) + get_filename_component(path "${path}" DIRECTORY) + vcpkg_add_to_path(PREPEND ${path}) + endif() + endif() + endforeach() + if (arg_USE_WRAPPERS) + z_vcpkg_append_to_configure_environment(configure_env CPP "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER} -E") + + 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) + z_vcpkg_append_to_configure_environment(configure_env AR "ar-lib ${VCPKG_DETECTED_CMAKE_AR}") + else() + z_vcpkg_append_to_configure_environment(configure_env AR "ar-lib lib.exe -verbose") + endif() + else() + 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) + z_vcpkg_append_to_configure_environment(configure_env AR "${VCPKG_DETECTED_CMAKE_AR}") + else() + z_vcpkg_append_to_configure_environment(configure_env AR "lib.exe -verbose") + endif() + endif() + z_vcpkg_append_to_configure_environment(configure_env LD "${VCPKG_DETECTED_CMAKE_LINKER} -verbose") + if(VCPKG_DETECTED_CMAKE_RANLIB) + z_vcpkg_append_to_configure_environment(configure_env RANLIB "${VCPKG_DETECTED_CMAKE_RANLIB}") # Trick to ignore the RANLIB call + else() + 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 + 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 + z_vcpkg_append_to_configure_environment(configure_env STRIP "${VCPKG_DETECTED_CMAKE_STRIP}") + else() + 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 + 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) + 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 + z_vcpkg_append_to_configure_environment(configure_env DLLTOOL "${VCPKG_DETECTED_CMAKE_DLLTOOL}") + else() + z_vcpkg_append_to_configure_environment(configure_env DLLTOOL "link.exe -verbose -dll") + endif() + 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 arg_CONFIGURE_ENVIRONMENT_VARIABLES) + z_vcpkg_append_to_configure_environment(configure_env ${_env} "${${_env}}") + endforeach() + 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. + # CXXCOMPILE The command used to actually compile a C++ source file. The file name is appended to form the complete command line. + # CXXLINK The command used to actually link a C++ program. + + # Variables not correctly detected by configure. In release builds. + list(APPEND arg_OPTIONS gl_cv_double_slash_root=yes + ac_cv_func_memmove=yes) + #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 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 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 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) + # 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/" z_vcpkg_prefix_path "${CURRENT_INSTALLED_DIR}") + else() + set(z_vcpkg_prefix_path "${CURRENT_INSTALLED_DIR}") + endif() + + # macOS - cross-compiling support + if(VCPKG_TARGET_IS_OSX) + 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(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: ${arg_BUILD_TRIPLET}") + endif() + endif() + + # Cleanup previous build dirs + file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" + "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" + "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}") + + # Set configure 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(arg_OPTIONS_RELEASE ${arg_OPTIONS_RELEASE} + # Important: These should all be relative to prefix! + "--bindir=\\\${prefix}/tools/${PORT}/bin" + "--sbindir=\\\${prefix}/tools/${PORT}/sbin" + "--libdir=\\\${prefix}/lib" # On some Linux distributions lib64 is the default + #"--includedir='\${prefix}'/include" # already the default! + "--mandir=\\\${prefix}/share/${PORT}" + "--docdir=\\\${prefix}/share/${PORT}" + "--datarootdir=\\\${prefix}/share/${PORT}") + 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" + "--libdir=\\\${prefix}/lib" # On some Linux distributions lib64 is the default + "--includedir=\\\${prefix}/../include" + "--datarootdir=\\\${prefix}/share/${PORT}") + endif() + # Setup common options + if(NOT arg_DISABLE_VERBOSE_FLAGS) + list(APPEND arg_OPTIONS --disable-silent-rules --verbose) + endif() + + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + list(APPEND arg_OPTIONS --enable-shared --disable-static) + else() + list(APPEND arg_OPTIONS --disable-shared --enable-static) + endif() + + # Can be set in the triplet to append options for configure + if(DEFINED VCPKG_CONFIGURE_MAKE_OPTIONS) + list(APPEND arg_OPTIONS ${VCPKG_CONFIGURE_MAKE_OPTIONS}) + endif() + if(DEFINED VCPKG_CONFIGURE_MAKE_OPTIONS_RELEASE) + list(APPEND arg_OPTIONS_RELEASE ${VCPKG_CONFIGURE_MAKE_OPTIONS_RELEASE}) + endif() + 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}" "${arg_SOURCE_PATH}/${arg_PROJECT_SUBPATH}") + + set(base_cmd) + if(CMAKE_HOST_WIN32) + set(base_cmd ${bash_executable} --noprofile --norc --debug) + else() + find_program(base_cmd bash REQUIRED) + endif() + + # Used by CL + z_prepend_include_path(INCLUDE) + # Used by GCC + 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(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: + # error while loading shared libraries: VCRUNTIME140D_APP.dll: + # cannot open shared object file: No such file or directory + # IMPORTANT: The only way to pass linker flags through libtool AND the compile wrapper + # is to use the CL and LINK environment variables !!! + # (This is due to libtool and compiler wrapper using the same set of options to pass those variables around) + string(REPLACE "\\" "/" VCToolsInstallDir "$ENV{VCToolsInstallDir}") + # Can somebody please check if CMake's compiler flags for UWP are correct? + set(ENV{_CL_} "$ENV{_CL_} /D_UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB_ -FU\"${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\"") + string(APPEND VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE " -ZW:nostdlib") + string(APPEND VCPKG_DETECTED_CMAKE_CXX_FLAGS_DEBUG " -ZW:nostdlib") + set(ENV{_LINK_} "$ENV{_LINK_} ${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES} /MANIFEST /DYNAMICBASE /WINMD:NO /APPCONTAINER") + endif() + endif() + + 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(x_vcpkg_transform_libs ON) + if(VCPKG_TARGET_IS_UWP) + 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(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") + endif() + list(TRANSFORM all_libs_list REPLACE "^(${l_prefix})" "") + endif() + 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}") + endif() + + 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}") + else() + set(ENV{LIBS} "${all_libs_string}") + endif() + endif() + debug_message("ENV{LIBS}:$ENV{LIBS}") + vcpkg_find_acquire_program(PKGCONFIG) + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" AND NOT PKGCONFIG STREQUAL "--static") + set(PKGCONFIG "${PKGCONFIG} --static") # Is this still required or was the PR changing the pc files accordingly merged? + endif() + + # Run autoconf if necessary + if (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\")") + endif() + message(STATUS "Generating configure for ${TARGET_TRIPLET}") + if (CMAKE_HOST_WIN32) + vcpkg_execute_required_process( + COMMAND ${base_cmd} -c "autoreconf -vfi" + WORKING_DIRECTORY "${src_dir}" + LOGNAME "autoconf-${TARGET_TRIPLET}" + ) + else() + vcpkg_execute_required_process( + COMMAND "${AUTORECONF}" -vfi + WORKING_DIRECTORY "${src_dir}" + LOGNAME "autoconf-${TARGET_TRIPLET}" + ) + endif() + message(STATUS "Finished generating configure for ${TARGET_TRIPLET}") + endif() + 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}" + ) + else() + vcpkg_execute_required_process( + COMMAND "./autogen.sh" + WORKING_DIRECTORY "${src_dir}" + LOGNAME "autoconf-${TARGET_TRIPLET}" + ) + endif() + message(STATUS "Finished generating configure for ${TARGET_TRIPLET}") + endif() + + if (arg_PRERUN_SHELL) + message(STATUS "Prerun shell with ${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 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}}") + else() # dynamic + set(LINKER_FLAGS_${var_suffix} "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${var_suffix}}") + endif() + 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${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}}") + else() + set(LINK_ENV_${var_suffix} "${LINKER_FLAGS_${var_suffix}}") + endif() + else() + 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_required_dirs "${link_required_dirs} -L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib/manual-link") + endif() + string(STRIP "${link_required_dirs}" link_required_dirs) + set(LDFLAGS_${var_suffix} "${link_required_dirs} ${LINKER_FLAGS_${var_suffix}}") + endif() + 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 all_buildtypes ${var_suffix}) + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + 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}}") + endif() + 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${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}}") + else() + set(LINK_ENV_${var_suffix} "${LINKER_FLAGS_${var_suffix}}") + endif() + else() + 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_required_dirs "${link_required_dirs} -L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib/manual-link") + endif() + string(STRIP "${link_required_dirs}" link_required_dirs) + set(LDFLAGS_${var_suffix} "${link_required_dirs} ${LINKER_FLAGS_${var_suffix}}") + endif() + unset(var_suffix) + endif() + + 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}") + vcpkg_list(APPEND tmp "\"${element}\"") + endforeach() + vcpkg_list(JOIN tmp " " "${var}") + endforeach() + + 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}}") + endif() + set(ENV{${ENV_VAR}} "${${ENV_VAR}_${current_buildtype}}") + endforeach() + + 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(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_${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_${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}") + endif() + + # Setup environment + 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, + # and libtool tries to avoid versioning for shared libraries and no symbolic links are created. + if(VCPKG_TARGET_IS_ANDROID) + set(ENV{LDFLAGS} "-avoid-version $ENV{LDFLAGS}") + endif() + + if(LINK_ENV_${current_buildtype}) + set(link_config_backup "$ENV{_LINK_}") + set(ENV{_LINK_} "${LINK_ENV_${current_buildtype}}") + endif() + set(ENV{PKG_CONFIG} "${PKGCONFIG}") + + 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_${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() + endforeach() + unset(lib_env_vars) + + set(command "${base_cmd}" -c "${configure_env} ./${relative_build_path}/configure ${arg_BUILD_TRIPLET} ${arg_OPTIONS} ${arg_OPTIONS_${current_buildtype}}") + + 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 arg_SKIP_CONFIGURE) + message(STATUS "Configuring ${TARGET_TRIPLET}-${short_name_${current_buildtype}}") + vcpkg_execute_required_process( + COMMAND ${command} + 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 "${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 "${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_${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_${current_buildtype}) + + if(link_config_backup) + set(ENV{_LINK_} "${link_config_backup}") + unset(link_config_backup) + endif() + + if(arg_ADD_BIN_TO_PATH) + set(ENV{PATH} "${path_backup}") + endif() + # Restore environment (config dependent) + 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() + endforeach() + endforeach() + + # Export matching make program for vcpkg_make_build (cache variable) + if(CMAKE_HOST_WIN32 AND MSYS_ROOT) + find_program(Z_VCPKG_MAKE make PATHS "${MSYS_ROOT}/usr/bin" NO_DEFAULT_PATH REQUIRED) + elseif(VCPKG_HOST_IS_OPENBSD) + find_program(Z_VCPKG_MAKE gmake REQUIRED) + else() + find_program(Z_VCPKG_MAKE make REQUIRED) + endif() + + # Restore environment + vcpkg_restore_env_variables(VARS ${cm_FLAGS} LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) + + set(_VCPKG_PROJECT_SOURCE_PATH ${arg_SOURCE_PATH} PARENT_SCOPE) + set(_VCPKG_PROJECT_SUBPATH ${arg_PROJECT_SUBPATH} PARENT_SCOPE) +endfunction() diff --git a/ports/vcpkg-make/vcpkg_make_install.cmake b/ports/vcpkg-make/vcpkg_make_install.cmake new file mode 100644 index 00000000000000..6527da1c336b5f --- /dev/null +++ b/ports/vcpkg-make/vcpkg_make_install.cmake @@ -0,0 +1,35 @@ +#[===[.md: +# vcpkg_install_make + +Build and install a make project. + +```cmake +vcpkg_make_install( + [DISABLE_PARALLEL] + [ADD_BIN_TO_PATH] +) +``` + +`vcpkg_make_install` transparently forwards to [`vcpkg_make_build()`], +with additional parameters to set `ENABLE_INSTALL`, +and to set the `LOGFILE_BASE` to `install` as well. + +[`vcpkg_make_build()`]: vcpkg_make_build.cmake + +## Examples + +* [x264](https://github.com/Microsoft/vcpkg/blob/master/ports/x264/portfile.cmake) +#]===] + +if(Z_VCPKG_MAKE_INSTALL_GUARD) + return() +endif() +set(Z_VCPKG_MAKE_INSTALL_GUARD ON CACHE INTERNAL "guard variable") + +function(vcpkg_make_install) + vcpkg_make_build( + ${ARGN} + LOGFILE_BASE install + ENABLE_INSTALL + ) +endfunction() diff --git a/ports/x264/portfile.cmake b/ports/x264/portfile.cmake index b64c9ad6e55384..9562877c896780 100644 --- a/ports/x264/portfile.cmake +++ b/ports/x264/portfile.cmake @@ -34,7 +34,7 @@ if(VCPKG_TARGET_IS_LINUX) list(APPEND OPTIONS --enable-pic) endif() -vcpkg_configure_make( +vcpkg_make_configure( SOURCE_PATH ${SOURCE_PATH} NO_ADDITIONAL_PATHS OPTIONS @@ -50,7 +50,7 @@ vcpkg_configure_make( ) -vcpkg_install_make() +vcpkg_make_install() if(NOT VCPKG_TARGET_IS_UWP) vcpkg_copy_tools(TOOL_NAMES x264 AUTO_CLEAN) diff --git a/ports/x264/vcpkg.json b/ports/x264/vcpkg.json index 41aa4b91809fab..b9b85a7d9277dc 100644 --- a/ports/x264/vcpkg.json +++ b/ports/x264/vcpkg.json @@ -1,7 +1,7 @@ { "name": "x264", "version-string": "157-303c484ec828ed0", - "port-version": 16, + "port-version": 17, "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", @@ -9,6 +9,10 @@ { "name": "pthread", "platform": "linux & osx" + }, + { + "name": "vcpkg-make", + "host": true } ] } diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index aa105fe6cd4fee..dc407d613de465 100755 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -1,3 +1,4 @@ +# DEPRECATED BY ports/vcpkg-make/vcpkg_make_build #[===[.md: # vcpkg_build_make @@ -51,6 +52,10 @@ You can use the alias [`vcpkg_install_make()`](vcpkg_install_make.md) function i #]===] function(vcpkg_build_make) + if(Z_VCPKG_MAKE_BUILD_GUARD) + message(FATAL_ERROR "The ${PORT} port already depends on vcpkg-make; using both vcpkg-make and vcpkg_build_make in the same port is unsupported.") + endif() + z_vcpkg_get_cmake_vars(cmake_vars_file) include("${cmake_vars_file}") diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index da0fd2aad39159..e55ea2a84439e1 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -1,3 +1,4 @@ +# DEPRECATED BY ports/vcpkg-make/vcpkg_make_configure #[===[.md: # vcpkg_configure_make @@ -233,6 +234,10 @@ function(vcpkg_configure_make) "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;CONFIGURE_ENVIRONMENT_VARIABLES;CONFIG_DEPENDENT_ENVIRONMENT;ADDITIONAL_MSYS_PACKAGES" ) + if(NOT arg_Z_GET_MAKE_VARS_USAGE AND Z_VCPKG_MAKE_CONFIGURE_GUARD) + message(FATAL_ERROR "The ${PORT} port already depends on vcpkg-make; using both vcpkg-make and vcpkg_configure_make in the same port is unsupported.") + endif() + z_vcpkg_get_cmake_vars(cmake_vars_file) debug_message("Including cmake vars from: ${cmake_vars_file}") include("${cmake_vars_file}") diff --git a/scripts/cmake/vcpkg_install_make.cmake b/scripts/cmake/vcpkg_install_make.cmake index f622edd406ad6b..2f260ade56dd8a 100644 --- a/scripts/cmake/vcpkg_install_make.cmake +++ b/scripts/cmake/vcpkg_install_make.cmake @@ -1,3 +1,4 @@ +# DEPRECATED BY ports/vcpkg-make/vcpkg_make_install #[===[.md: # vcpkg_install_make @@ -23,6 +24,9 @@ This command transparently forwards to [`vcpkg_build_make()`](vcpkg_build_make.m #]===] function(vcpkg_install_make) + if(Z_VCPKG_MAKE_INSTALL_GUARD) + message(FATAL_ERROR "The ${PORT} port already depends on vcpkg-make; using both vcpkg-make and vcpkg_install_make in the same port is unsupported.") + endif() vcpkg_build_make( ${ARGN} LOGFILE_ROOT diff --git a/versions/a-/apr-util.json b/versions/a-/apr-util.json index a2629d38521bba..48d655e25b62ce 100644 --- a/versions/a-/apr-util.json +++ b/versions/a-/apr-util.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "6e039df30db545141c59425a585296777b110c7d", + "version-string": "1.6.1", + "port-version": 5 + }, { "git-tree": "cf1a0e97d00a5748dc58db7d0a5da0fd7d5efb66", "version-string": "1.6.1", diff --git a/versions/a-/apr.json b/versions/a-/apr.json index d652415aa93e90..c73d5fc3d2ed50 100644 --- a/versions/a-/apr.json +++ b/versions/a-/apr.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "f3cb36f13b9cab10318f247494b23e5d2009f2ed", + "version": "1.7.0", + "port-version": 5 + }, { "git-tree": "b9e93acdaa680398eaed361f1df530096ded84ff", "version": "1.7.0", diff --git a/versions/baseline.json b/versions/baseline.json index 029eb935b9ed07..35786670494af1 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -110,11 +110,11 @@ }, "apr": { "baseline": "1.7.0", - "port-version": 4 + "port-version": 5 }, "apr-util": { "baseline": "1.6.1", - "port-version": 4 + "port-version": 5 }, "apsi": { "baseline": "0.3.1", @@ -2350,7 +2350,7 @@ }, "gdal": { "baseline": "3.3.2", - "port-version": 2 + "port-version": 3 }, "gdcm": { "baseline": "3.0.7", @@ -2402,7 +2402,7 @@ }, "gettext": { "baseline": "0.21", - "port-version": 6 + "port-version": 7 }, "gettimeofday": { "baseline": "2017-10-14", @@ -2650,7 +2650,7 @@ }, "healpix": { "baseline": "1.12.10", - "port-version": 8 + "port-version": 9 }, "hedley": { "baseline": "15", @@ -2694,7 +2694,7 @@ }, "hunspell": { "baseline": "1.7.0", - "port-version": 5 + "port-version": 6 }, "hwloc": { "baseline": "2.5.0", @@ -2714,7 +2714,7 @@ }, "icu": { "baseline": "69.1", - "port-version": 15 + "port-version": 16 }, "ideviceinstaller": { "baseline": "1.1.2.23", @@ -3506,7 +3506,7 @@ }, "libiconv": { "baseline": "1.16", - "port-version": 11 + "port-version": 12 }, "libics": { "baseline": "1.6.5", @@ -3950,7 +3950,7 @@ }, "liburing": { "baseline": "2.0", - "port-version": 0 + "port-version": 1 }, "libusb": { "baseline": "1.0.24", @@ -4594,7 +4594,7 @@ }, "ncurses": { "baseline": "6.2", - "port-version": 1 + "port-version": 2 }, "neargye-semver": { "baseline": "0.3.0", @@ -6454,7 +6454,7 @@ }, "starlink-ast": { "baseline": "9.2.4", - "port-version": 2 + "port-version": 3 }, "status-code": { "baseline": "1.0.0-ab3cd821", @@ -6988,6 +6988,10 @@ "baseline": "3", "port-version": 1 }, + "vcpkg-make": { + "baseline": "2021-08-25", + "port-version": 0 + }, "vcpkg-pkgconfig-get-modules": { "baseline": "2021-04-02", "port-version": 1 @@ -7154,7 +7158,7 @@ }, "x264": { "baseline": "157-303c484ec828ed0", - "port-version": 16 + "port-version": 17 }, "x265": { "baseline": "3.4", diff --git a/versions/g-/gdal.json b/versions/g-/gdal.json index ecf85e5587787b..49d2a5a3b3d15c 100644 --- a/versions/g-/gdal.json +++ b/versions/g-/gdal.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "0ba46f63f70a8d7ef1ff2253e48d4e45b0b0f629", + "version-semver": "3.3.2", + "port-version": 3 + }, { "git-tree": "354c2bfa5d4de64d6894cb74f47e6801fd02af8d", "version-semver": "3.3.2", diff --git a/versions/g-/gettext.json b/versions/g-/gettext.json index adb7fea987cdb4..fbc69139491fe6 100644 --- a/versions/g-/gettext.json +++ b/versions/g-/gettext.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "d1eba48f67dbbd9a07b89b0850e1e42777a409b2", + "version": "0.21", + "port-version": 7 + }, { "git-tree": "72394a1e7b0ea6333d78849f864c4b7bc8c7e8dc", "version": "0.21", diff --git a/versions/h-/healpix.json b/versions/h-/healpix.json index a85f5293c2107b..87a3d6364e0b4a 100644 --- a/versions/h-/healpix.json +++ b/versions/h-/healpix.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "0eb7e3ec2016e2f927cb7c943f9434b5252366ec", + "version-string": "1.12.10", + "port-version": 9 + }, { "git-tree": "38bd9d397f3ba4e227f09a36ecb0af034f5f0c98", "version-string": "1.12.10", diff --git a/versions/h-/hunspell.json b/versions/h-/hunspell.json index af5756c9447935..c5b4354f7ca218 100644 --- a/versions/h-/hunspell.json +++ b/versions/h-/hunspell.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "3d6529e3845ea7ae9aadc6abeef30985d863e91e", + "version": "1.7.0", + "port-version": 6 + }, { "git-tree": "2a0514dd8b3893b6d3a502fbf55156e9e971d6f7", "version": "1.7.0", diff --git a/versions/i-/icu.json b/versions/i-/icu.json index 17f2df336b4293..851300c8c156a8 100644 --- a/versions/i-/icu.json +++ b/versions/i-/icu.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "50a938c3cad21f9ede4746d59348e9810c54aef8", + "version": "69.1", + "port-version": 16 + }, { "git-tree": "2d08c0ceb1777074f3b31fe51e386c9ece0ca8cd", "version": "69.1", diff --git a/versions/l-/libiconv.json b/versions/l-/libiconv.json index 9423b2719d2fcf..7ecf38d519aa5c 100644 --- a/versions/l-/libiconv.json +++ b/versions/l-/libiconv.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "534ed78492de209c5a752b53ef6567b61a577c3d", + "version": "1.16", + "port-version": 12 + }, { "git-tree": "f82980bff6c23bcccd043300679ebf8afa3e0a22", "version": "1.16", diff --git a/versions/l-/liburing.json b/versions/l-/liburing.json index 0ec46a4a754a02..3cf5fcb96e0400 100644 --- a/versions/l-/liburing.json +++ b/versions/l-/liburing.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "9eea2e30573c9bc095a193076d15896a98c6324d", + "version": "2.0", + "port-version": 1 + }, { "git-tree": "b4d90242721d15d6dc5287690c3b8d42c2e8d0f0", "version": "2.0", diff --git a/versions/n-/ncurses.json b/versions/n-/ncurses.json index 135f3c3b5ec239..1ef2b997836481 100644 --- a/versions/n-/ncurses.json +++ b/versions/n-/ncurses.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "dcdfbaf6aaf3b24ac3c4c189b05d82c0f6954d90", + "version-string": "6.2", + "port-version": 2 + }, { "git-tree": "f196044f9f7779e0bdb54015dbd3be84aaa00820", "version-string": "6.2", diff --git a/versions/s-/starlink-ast.json b/versions/s-/starlink-ast.json index 0ba8d7525f3ba6..ebd410fb2def2d 100644 --- a/versions/s-/starlink-ast.json +++ b/versions/s-/starlink-ast.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "5de775aeb50b0553ac45537e3597fdbb4ecd8505", + "version-semver": "9.2.4", + "port-version": 3 + }, { "git-tree": "487c5e318ce957c09647d0d74a2b5b4a4e99ffef", "version-semver": "9.2.4", diff --git a/versions/v-/vcpkg-make.json b/versions/v-/vcpkg-make.json new file mode 100644 index 00000000000000..ed5e754cc03201 --- /dev/null +++ b/versions/v-/vcpkg-make.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "be3d7001f8dd0c6e75b9a604c74f73edf4d202be", + "version-date": "2021-08-25", + "port-version": 0 + } + ] +} diff --git a/versions/x-/x264.json b/versions/x-/x264.json index 7ca11279e98699..cae2f1f24362e1 100644 --- a/versions/x-/x264.json +++ b/versions/x-/x264.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "d95c7bd4f42aa5f0ce47b7e68fc8aad1de9566d7", + "version-string": "157-303c484ec828ed0", + "port-version": 17 + }, { "git-tree": "e8f14328cb425b2a7450bf36f731f97d41564fed", "version-string": "157-303c484ec828ed0",