diff --git a/ports/farmhash/CONTROL b/ports/farmhash/CONTROL index f27140fbd01d5a..7d7f4d386f528c 100644 --- a/ports/farmhash/CONTROL +++ b/ports/farmhash/CONTROL @@ -1,5 +1,6 @@ Source: farmhash -Version: 1.1-1 +Version: 1.1 +Port-Version: 2 Homepage: https://github.com/google/farmhash Description: FarmHash, a family of hash functions. Supports: !arm diff --git a/ports/farmhash/portfile.cmake b/ports/farmhash/portfile.cmake index d9bcc924063610..801e0570651319 100644 --- a/ports/farmhash/portfile.cmake +++ b/ports/farmhash/portfile.cmake @@ -14,6 +14,7 @@ if((VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX) AND NOT ENV{CXX_FLAGS}) # This endif() file(REMOVE_RECURSE "${SOURCE_PATH}/configure") vcpkg_configure_make( + AUTOCONFIG SOURCE_PATH ${SOURCE_PATH} ) diff --git a/ports/freexl/CONTROL b/ports/freexl/CONTROL index 68d0d291fc6b88..1a887b1932ad42 100644 --- a/ports/freexl/CONTROL +++ b/ports/freexl/CONTROL @@ -1,5 +1,6 @@ Source: freexl -Version: 1.0.4-9 +Version: 1.0.4 +Port-Version: 10 Homepage: https://www.gaia-gis.it/gaia-sins/freexl-sources Description: FreeXL is an open source library to extract valid data from within an Excel (.xls) spreadsheet Build-Depends: libiconv diff --git a/ports/freexl/portfile.cmake b/ports/freexl/portfile.cmake index 3c4629dce5137f..6a79451dd77d95 100644 --- a/ports/freexl/portfile.cmake +++ b/ports/freexl/portfile.cmake @@ -64,6 +64,7 @@ elseif (CMAKE_HOST_UNIX OR CMAKE_HOST_APPLE) # Build in UNIX ) file(REMOVE_RECURSE "${SOURCE_PATH}/configure") vcpkg_configure_make( + AUTOCONFIG SOURCE_PATH ${SOURCE_PATH} OPTIONS_DEBUG INSTALLED_ROOT="${CURRENT_INSTALLED_DIR}" diff --git a/ports/healpix/CONTROL b/ports/healpix/CONTROL index 629b095ee45004..8b1e856e2a947f 100644 --- a/ports/healpix/CONTROL +++ b/ports/healpix/CONTROL @@ -1,5 +1,6 @@ Source: healpix -Version: 1.12.10-5 +Version: 1.12.10 +Port-Version: 6 Homepage: http://healpix.sourceforge.net/ Description: HEALPix is an acronym for Hierarchical Equal Area isoLatitude Pixelation of a sphere. Build-Depends: cfitsio diff --git a/ports/healpix/portfile.cmake b/ports/healpix/portfile.cmake index 8b1a401517b07b..c1fa90f368a628 100644 --- a/ports/healpix/portfile.cmake +++ b/ports/healpix/portfile.cmake @@ -10,6 +10,7 @@ vcpkg_from_sourceforge( ) vcpkg_configure_make( + AUTOCONFIG SOURCE_PATH ${SOURCE_PATH} PROJECT_SUBPATH src/cxx COPY_SOURCE diff --git a/ports/libb2/portfile.cmake b/ports/libb2/portfile.cmake index 2401cf0c1e2e62..992c59f4be3eb5 100644 --- a/ports/libb2/portfile.cmake +++ b/ports/libb2/portfile.cmake @@ -14,6 +14,7 @@ if(CMAKE_HOST_WIN32) endif() vcpkg_configure_make( + AUTOCONFIG SOURCE_PATH ${SOURCE_PATH} OPTIONS ${OPTIONS} ) diff --git a/ports/libb2/vcpkg.json b/ports/libb2/vcpkg.json index 1d2f19db823e96..dbe8dc265e8ed7 100644 --- a/ports/libb2/vcpkg.json +++ b/ports/libb2/vcpkg.json @@ -1,7 +1,7 @@ { "name": "libb2", "version-string": "0.98.1", - "port-version": 3, + "port-version": 4, "description": "C library providing BLAKE2b, BLAKE2s, BLAKE2bp, BLAKE2sp", "homepage": "https://github.com/BLAKE2/libb2", "supports": "!windows" diff --git a/ports/libcrafter/CONTROL b/ports/libcrafter/CONTROL index b8ebac0bf72624..47538dae935abe 100644 --- a/ports/libcrafter/CONTROL +++ b/ports/libcrafter/CONTROL @@ -1,5 +1,6 @@ Source: libcrafter -Version: 0.3-1 +Version: 0.3 +Port-Version: 2 Homepage: https://github.com/pellegre/libcrafter Description: Libcrafter is a high level library for C++ designed to create and decode network packets. -Build-Depends: libpcap \ No newline at end of file +Build-Depends: libpcap diff --git a/ports/libcrafter/portfile.cmake b/ports/libcrafter/portfile.cmake index 9965b7d3c9f0e9..565a0c3462a575 100644 --- a/ports/libcrafter/portfile.cmake +++ b/ports/libcrafter/portfile.cmake @@ -8,6 +8,7 @@ vcpkg_from_github( ) vcpkg_configure_make( + AUTOCONFIG SOURCE_PATH ${SOURCE_PATH} PROJECT_SUBPATH libcrafter OPTIONS diff --git a/ports/libmagic/CONTROL b/ports/libmagic/CONTROL index 07fce2a682e2b0..750b6513901124 100644 --- a/ports/libmagic/CONTROL +++ b/ports/libmagic/CONTROL @@ -1,4 +1,5 @@ Source: libmagic -Version: 5.37-1 +Version: 5.37 +Port-Version: 2 Homepage: https://github.com/file/file -Description: This library can be used to classify files according to magic number tests. \ No newline at end of file +Description: This library can be used to classify files according to magic number tests. diff --git a/ports/libmagic/portfile.cmake b/ports/libmagic/portfile.cmake index 65fe8d8ab6cbfe..363fa148f3f4da 100644 --- a/ports/libmagic/portfile.cmake +++ b/ports/libmagic/portfile.cmake @@ -7,6 +7,7 @@ vcpkg_from_github( ) vcpkg_configure_make( + AUTOCONFIG SOURCE_PATH ${SOURCE_PATH} ) vcpkg_install_make() diff --git a/ports/libwandio/CONTROL b/ports/libwandio/CONTROL index 5fc36ba357f7f2..1150b06ec140fb 100644 --- a/ports/libwandio/CONTROL +++ b/ports/libwandio/CONTROL @@ -1,5 +1,7 @@ Source: libwandio -Version: 4.2.1-2 +Version: 4.2.1 +Port-Version: 3 Homepage: https://github.com/wanduow/wandio Description: C library for simple and efficient file IO. -Build-Depends: zlib, zstd, liblzma, lz4, curl, pthread, bzip2 \ No newline at end of file +Build-Depends: zlib, zstd, liblzma, lzo, lz4, curl, pthread, bzip2 +Supports: !windows diff --git a/ports/libwandio/configure.lib.patch b/ports/libwandio/configure.lib.patch index 57719581ea09ac..3898836b7bc082 100644 --- a/ports/libwandio/configure.lib.patch +++ b/ports/libwandio/configure.lib.patch @@ -120,21 +120,3 @@ index 4579fbb3d..f6be008c8 100644 fi AC_DEFINE(HAVE_LIBLZ4S, 1, "Compiled with lz4 stream support") with_lz4=streamapi -@@ -296,12 +304,14 @@ AC_ARG_WITH([http], - AS_IF([test "x$with_http" != "xno"], - [ - # we need curl_easy_pause which was added in 7.18.0 -- AC_CHECK_LIB(curl, curl_easy_pause, have_curl=yes, have_curl=no) -+ AC_SEARCH_LIBS(curl_easy_pause, [curl curl-d], have_curl=yes, have_curl=no, [-lssl -lcrypto $ac_cv_search_pthread_create -ldl]) -+ # AC_CHECK_LIB(curl, curl_easy_pause, have_curl=yes, have_curl=no) - ], [have_curl=no]) - - AS_IF([test "x$have_curl" = "xyes"], [ -- if test "$ac_cv_lib_curl_curl_easy_pause" != "none required"; then -- LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lcurl" -+ if test "$ac_cv_search_curl_easy_pause" != "none required"; then -+ LIBWANDIO_LIBS="$LIBWANDIO_LIBS $ac_cv_search_curl_easy_pause -lssl -lcrypto $ac_cv_search_pthread_create -ldl" -+ LIBS="$LIBS -lssl -lcrypto $ac_cv_search_pthread_create -ldl" - fi - AC_DEFINE(HAVE_HTTP, 1, "Compiled with http support") - with_http=yes], diff --git a/ports/libwandio/configure.patch b/ports/libwandio/configure.patch new file mode 100644 index 00000000000000..929662d6703296 --- /dev/null +++ b/ports/libwandio/configure.patch @@ -0,0 +1,14 @@ +diff --git a/configure.ac b/configure.ac +index e250c0c31..0465120ba 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -83,7 +83,7 @@ ADD_INCLS="" + ADD_LDFLAGS="$ADD_LDFLAGS -L\$(abs_top_srcdir)/lib" + LIBWANDIO_LIBS="" + +-CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wextra -DLT_BUILDING_DLL=1" ++CFLAGS="$CFLAGS -Wall -DLT_BUILDING_DLL=1 -DNOMINMAX" +-CXXFLAGS="$CXXFLAGS -Wall -DLT_BUILDING_DLL=1" ++CXXFLAGS="$CXXFLAGS -Wall -DLT_BUILDING_DLL=1 -DNOMINMAX" + + # Check for -fvisibility diff --git a/ports/libwandio/curl.patch b/ports/libwandio/curl.patch new file mode 100644 index 00000000000000..326700ed0bb142 --- /dev/null +++ b/ports/libwandio/curl.patch @@ -0,0 +1,22 @@ +diff --git a/configure.ac b/configure.ac +index 4579fbb3d..f6be008c8 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -296,12 +304,14 @@ AC_ARG_WITH([http], + AS_IF([test "x$with_http" != "xno"], + [ + # we need curl_easy_pause which was added in 7.18.0 +- AC_CHECK_LIB(curl, curl_easy_pause, have_curl=yes, have_curl=no) ++ AC_SEARCH_LIBS(curl_easy_pause, [curl curl-d libcurl libcurl-d], have_curl=yes, have_curl=no, [-lCrypt32 -lWldap32 -lWs2_32 -ladvapi32]) ++ # AC_CHECK_LIB(curl, curl_easy_pause, have_curl=yes, have_curl=no) + ], [have_curl=no]) + + AS_IF([test "x$have_curl" = "xyes"], [ +- if test "$ac_cv_lib_curl_curl_easy_pause" != "none required"; then +- LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lcurl" ++ if test "$ac_cv_search_curl_easy_pause" != "none required"; then ++ LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lCrypt32 -lWldap32 -lWs2_32 -ladvapi32 $ac_cv_search_curl_easy_pause" ++ LIBS="$LIBS" + fi + AC_DEFINE(HAVE_HTTP, 1, "Compiled with http support") + with_http=yes], diff --git a/ports/libwandio/openssl.patch b/ports/libwandio/openssl.patch new file mode 100644 index 00000000000000..586cdfab569bf9 --- /dev/null +++ b/ports/libwandio/openssl.patch @@ -0,0 +1,22 @@ +diff --git a/configure.ac b/configure.ac +index 4579fbb3d..f6be008c8 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -296,12 +304,14 @@ AC_ARG_WITH([http], + AS_IF([test "x$with_http" != "xno"], + [ + # we need curl_easy_pause which was added in 7.18.0 +- AC_CHECK_LIB(curl, curl_easy_pause, have_curl=yes, have_curl=no) ++ AC_SEARCH_LIBS(curl_easy_pause, [curl curl-d], have_curl=yes, have_curl=no, [-lssl -lcrypto $ac_cv_search_pthread_create -ldl]) ++ # AC_CHECK_LIB(curl, curl_easy_pause, have_curl=yes, have_curl=no) + ], [have_curl=no]) + + AS_IF([test "x$have_curl" = "xyes"], [ +- if test "$ac_cv_lib_curl_curl_easy_pause" != "none required"; then +- LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lcurl" ++ if test "$ac_cv_search_curl_easy_pause" != "none required"; then ++ LIBWANDIO_LIBS="$LIBWANDIO_LIBS $ac_cv_search_curl_easy_pause -lssl -lcrypto $ac_cv_search_pthread_create -ldl" ++ LIBS="$LIBS -lssl -lcrypto $ac_cv_search_pthread_create -ldl" + fi + AC_DEFINE(HAVE_HTTP, 1, "Compiled with http support") + with_http=yes], diff --git a/ports/libwandio/portfile.cmake b/ports/libwandio/portfile.cmake index c9be34be64f4ae..a03d5c79f2c768 100644 --- a/ports/libwandio/portfile.cmake +++ b/ports/libwandio/portfile.cmake @@ -1,3 +1,11 @@ +if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + set(PATCHES curl.patch) + #TODO: Still does not work. Requires proper "signal" support and "unistd" +else() + set(PATCHES openssl.patch) # needed if curl is using openssl +endif() + vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO wanduow/wandio @@ -5,9 +13,12 @@ vcpkg_from_github( SHA512 e94a82038902c34933c4256f8bd4d7ef3f2cf32fea46f8e31a25df34cc90d3a275ff56d3bc9892aca0c85e6d875e696f96a836cc1444fe165db8364331e6e77d HEAD_REF master PATCHES configure.lib.patch # This is how configure.ac files with dependencies get fixed. + configure.patch + ${PATCHES} ) vcpkg_configure_make( + AUTOCONFIG SOURCE_PATH ${SOURCE_PATH} COPY_SOURCE ) diff --git a/ports/lzokay/vcpkg.json b/ports/lzokay/vcpkg.json index 60e52a0ed5d2ac..fb2b0787a587db 100644 --- a/ports/lzokay/vcpkg.json +++ b/ports/lzokay/vcpkg.json @@ -1,6 +1,6 @@ { "name": "lzokay", "version-string": "2020-07-30", - "homepage": "https://github.com/jackoalan/lzokay", - "description": "lzokay – MIT licensed C++ implementation of LZO compression/decompression algorithm" + "description": "lzokay – MIT licensed C++ implementation of LZO compression/decompression algorithm", + "homepage": "https://github.com/jackoalan/lzokay" } diff --git a/ports/ocilib/CONTROL b/ports/ocilib/CONTROL index c5d4fbb3742c95..a4d44f4a36d902 100644 --- a/ports/ocilib/CONTROL +++ b/ports/ocilib/CONTROL @@ -1,5 +1,6 @@ Source: ocilib -Version: 4.6.4-1 +Version: 4.6.4 +Port-Version: 2 Homepage: https://vrogier.github.io/ocilib/ Description: OCILIB is an open source and cross platform Oracle Driver that delivers efficient access to Oracle databases. Supports: !(arm|uwp) \ No newline at end of file diff --git a/ports/ocilib/portfile.cmake b/ports/ocilib/portfile.cmake index 84912c10f6c5d5..a8a451f484d899 100644 --- a/ports/ocilib/portfile.cmake +++ b/ports/ocilib/portfile.cmake @@ -1,62 +1,64 @@ vcpkg_fail_port_install(ON_ARCH "arm" ON_TARGET "uwp") vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO vrogier/ocilib - REF v4.6.4 - SHA512 83f5614a23c8fb4ab02517dec95d8b490c5ef472302735d5cc4cf483cc51513cc81ae2e1b4618c7c73fb5b071efe422e463b46fa79492ccb4775b511a943295a - HEAD_REF master - PATCHES - out_of_source_build_version_file_configure.patch + OUT_SOURCE_PATH SOURCE_PATH + REPO vrogier/ocilib + REF v4.6.4 + SHA512 83f5614a23c8fb4ab02517dec95d8b490c5ef472302735d5cc4cf483cc51513cc81ae2e1b4618c7c73fb5b071efe422e463b46fa79492ccb4775b511a943295a + HEAD_REF master + PATCHES + out_of_source_build_version_file_configure.patch ) if(VCPKG_TARGET_IS_WINDOWS) - if(VCPKG_PLATFORM_TOOLSET MATCHES "v142") + if(VCPKG_PLATFORM_TOOLSET MATCHES "v142") set(SOLUTION_TYPE vs2019) set(OCILIB_ARCH_X86 x86) set(OCILIB_ARCH_X64 x64) - elseif(VCPKG_PLATFORM_TOOLSET MATCHES "v141") + elseif(VCPKG_PLATFORM_TOOLSET MATCHES "v141") set(SOLUTION_TYPE vs2017) set(OCILIB_ARCH_X86 Win32) set(OCILIB_ARCH_X64 Win64) - else() + else() set(SOLUTION_TYPE vs2015) set(OCILIB_ARCH_X86 Win32) set(OCILIB_ARCH_X64 Win64) - endif() + endif() if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") set(PLATFORM ${OCILIB_ARCH_X86}) else() set(PLATFORM ${OCILIB_ARCH_X64}) endif() - - # There is no debug configuration - # As it is a C library, build the release configuration and copy its output to the debug folder - set(VCPKG_BUILD_TYPE release) - vcpkg_install_msbuild( - SOURCE_PATH ${SOURCE_PATH} - PROJECT_SUBPATH proj/dll/ocilib_dll_${SOLUTION_TYPE}.sln - INCLUDES_SUBPATH include - LICENSE_SUBPATH LICENSE - RELEASE_CONFIGURATION "Release - ANSI" - PLATFORM ${PLATFORM} - USE_VCPKG_INTEGRATION - ALLOW_ROOT_INCLUDES) + + # There is no debug configuration + # As it is a C library, build the release configuration and copy its output to the debug folder + set(VCPKG_BUILD_TYPE release) + vcpkg_install_msbuild( + SOURCE_PATH ${SOURCE_PATH} + PROJECT_SUBPATH proj/dll/ocilib_dll_${SOLUTION_TYPE}.sln + INCLUDES_SUBPATH include + LICENSE_SUBPATH LICENSE + RELEASE_CONFIGURATION "Release - ANSI" + PLATFORM ${PLATFORM} + USE_VCPKG_INTEGRATION + ALLOW_ROOT_INCLUDES) - file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug) - file(COPY ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug) + file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug) + file(COPY ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug) else() - vcpkg_configure_make( - SOURCE_PATH ${SOURCE_PATH} - OPTIONS - --with-oracle-import=runtime - ) + vcpkg_configure_make( + COPY_SOURCE + AUTOCONFIG + SOURCE_PATH ${SOURCE_PATH} + OPTIONS + --with-oracle-import=runtime + ) - vcpkg_install_make() + vcpkg_install_make() - file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) - file(RENAME ${CURRENT_PACKAGES_DIR}/share/doc/${PORT} ${CURRENT_PACKAGES_DIR}/share/${PORT}) - file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/share/doc) - file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) + file(RENAME ${CURRENT_PACKAGES_DIR}/share/doc/${PORT} ${CURRENT_PACKAGES_DIR}/share/${PORT}) + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/share/doc) + file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) endif() diff --git a/ports/openmpi/CONTROL b/ports/openmpi/CONTROL index 4da1df53ed4e66..37fe14b0ca97c2 100644 --- a/ports/openmpi/CONTROL +++ b/ports/openmpi/CONTROL @@ -1,5 +1,6 @@ Source: openmpi Version: 4.0.3 +Port-Version: 2 Homepage: https://www.open-mpi.org/ Description: The Open MPI Project is an open source Message Passing Interface implementation that is developed and maintained by a consortium of academic, research, and industry partners. Open MPI is therefore able to combine the expertise, technologies, and resources from all across the High Performance Computing community in order to build the best MPI library available. Open MPI offers advantages for system and software vendors, application developers and computer science researchers. Supports: !(windows|uwp) diff --git a/ports/openmpi/portfile.cmake b/ports/openmpi/portfile.cmake index 6dbb01127c78ae..0ef3c3c6a57cd7 100644 --- a/ports/openmpi/portfile.cmake +++ b/ports/openmpi/portfile.cmake @@ -21,6 +21,7 @@ get_filename_component(PERL_PATH ${PERL} DIRECTORY) vcpkg_add_to_path(${PERL_PATH}) vcpkg_configure_make( + COPY_SOURCE SOURCE_PATH ${SOURCE_PATH} OPTIONS --with-hwloc=internal diff --git a/ports/pbc/CONTROL b/ports/pbc/CONTROL index 06aa2ca5c996ad..e7f0cc3c06c3e1 100644 --- a/ports/pbc/CONTROL +++ b/ports/pbc/CONTROL @@ -1,7 +1,7 @@ Source: pbc Version: 0.5.14 -Port-Version: 3 -Build-Depends: mpir (windows), gmp(!windows) +Port-Version: 4 +Build-Depends: mpir (windows), gmp (!windows) Homepage: https://crypto.stanford.edu/pbc Description: Pairing-Based Crypto library provides low-level routines for pairing-based cryptosystems. Supports: !uwp diff --git a/ports/x264/CONTROL b/ports/x264/CONTROL index b49bf0a7729147..0a4af3912f140f 100644 --- a/ports/x264/CONTROL +++ b/ports/x264/CONTROL @@ -1,5 +1,6 @@ Source: x264 -Version: 157-303c484ec828ed0-8 +Version: 157-303c484ec828ed0 +Port-Version: 9 Homepage: https://github.com/mirror/x264 Description: x264 is a free software library and application for encoding video streams into the H.264/MPEG-4 AVC compression format -Build-Depends: pthread (linux&osx) \ No newline at end of file +Build-Depends: pthread (linux&osx) diff --git a/ports/x264/portfile.cmake b/ports/x264/portfile.cmake index d7aff89d7b49b5..1c9e32e9251816 100644 --- a/ports/x264/portfile.cmake +++ b/ports/x264/portfile.cmake @@ -12,9 +12,24 @@ vcpkg_from_github( "uwp-cflags.patch" ) +if(VCPKG_TARGET_IS_WINDOWS) + _vcpkg_determine_autotools_host_cpu(BUILD_ARCH) + _vcpkg_determine_autotools_target_cpu(HOST_ARCH) + list(APPEND OPTIONS --build=${BUILD_ARCH}-pc-mingw32) + list(APPEND OPTIONS --host=${HOST_ARCH}-pc-mingw32) +endif() + +if(VCPKG_TARGET_IS_UWP) + list(APPEND OPTIONS --extra-cflags=-DWINAPI_FAMILY=WINAPI_FAMILY_APP --extra-cflags=-D_WIN32_WINNT=0x0A00) + list(APPEND OPTIONS --extra-ldflags=-APPCONTAINER --extra-ldflags=WindowsApp.lib) +endif() + + vcpkg_configure_make( SOURCE_PATH ${SOURCE_PATH} + NO_ADDITIONAL_PATHS OPTIONS + ${OPTIONS} --enable-strip --disable-lavf --disable-swscale @@ -24,21 +39,17 @@ vcpkg_configure_make( --disable-lsmash --disable-asm --enable-debug + ) vcpkg_install_make() -vcpkg_fixup_pkgconfig(SYSTEM_LIBRARIES -lpthread -lm -ldl) +vcpkg_copy_tools(TOOL_NAMES x264 AUTO_CLEAN) -file(REMOVE_RECURSE - ${CURRENT_PACKAGES_DIR}/lib/pkgconfig - ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig - ${CURRENT_PACKAGES_DIR}/debug/bin/x264.exe - ${CURRENT_PACKAGES_DIR}/debug/include -) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") - file(RENAME ${CURRENT_PACKAGES_DIR}/lib/libx264.dll.lib ${CURRENT_PACKAGES_DIR}/lib/libx264.lib) - file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/libx264.dll.lib ${CURRENT_PACKAGES_DIR}/debug/lib/libx264.lib) + file(RENAME ${CURRENT_PACKAGES_DIR}/lib/libx264.dll.lib ${CURRENT_PACKAGES_DIR}/lib/x264.lib) + file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/libx264.dll.lib ${CURRENT_PACKAGES_DIR}/debug/lib/x264.lib) else() # force U_STATIC_IMPLEMENTATION macro file(READ ${CURRENT_PACKAGES_DIR}/include/x264.h HEADER_CONTENTS) @@ -51,6 +62,8 @@ else() ) endif() +vcpkg_fixup_pkgconfig(SYSTEM_LIBRARIES -lpthread -lm -ldl) + vcpkg_copy_pdbs() file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index 17a755890f6360..545e6d7653ebb6 100644 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -59,17 +59,9 @@ function(vcpkg_build_make) set(INSTALL_OPTS ) if (CMAKE_HOST_WIN32) set(PATH_GLOBAL "$ENV{PATH}") - # These should be moved into the portfile! - # vcpkg_find_acquire_program(YASM) - # get_filename_component(YASM_EXE_PATH ${YASM} DIRECTORY) - # vcpkg_add_to_path("${YASM_EXE_PATH}") - # vcpkg_find_acquire_program(PERL) - # get_filename_component(PERL_EXE_PATH ${PERL} DIRECTORY) - # vcpkg_add_to_path("${PERL_EXE_PATH}") - vcpkg_add_to_path(PREPEND "${SCRIPTS}/buildsystems/make_wrapper") vcpkg_acquire_msys(MSYS_ROOT) - find_program(MAKE make REQUIRED) #mingw32-make + find_program(MAKE make REQUIRED) set(MAKE_COMMAND "${MAKE}") set(MAKE_OPTS ${_bc_MAKE_OPTIONS} -j ${VCPKG_CONCURRENCY} --trace -f Makefile ${_bc_BUILD_TARGET}) @@ -79,7 +71,6 @@ function(vcpkg_build_make) #TODO: optimize for install-data (release) and install-exec (release/debug) else() # Compiler requriements - # set(MAKE_BASH) find_program(MAKE make REQUIRED) set(MAKE_COMMAND "${MAKE}") # Set make command and install command @@ -87,41 +78,8 @@ function(vcpkg_build_make) set(INSTALL_OPTS -j ${VCPKG_CONCURRENCY} install DESTDIR=${CURRENT_PACKAGES_DIR}) endif() - # Backup enviromnent variables - set(C_FLAGS_BACKUP "$ENV{CFLAGS}") - set(CXX_FLAGS_BACKUP "$ENV{CXXFLAGS}") - set(LD_FLAGS_BACKUP "$ENV{LDFLAGS}") - set(INCLUDE_PATH_BACKUP "$ENV{INCLUDE_PATH}") - set(INCLUDE_BACKUP "$ENV{INCLUDE}") - set(C_INCLUDE_PATH_BACKUP "$ENV{C_INCLUDE_PATH}") - set(CPLUS_INCLUDE_PATH_BACKUP "$ENV{CPLUS_INCLUDE_PATH}") - _vcpkg_backup_env_variable(LD_LIBRARY_PATH) - _vcpkg_backup_env_variable(LIBRARY_PATH) - set(LIBPATH_BACKUP "$ENV{LIBPATH}") - - # Setup include enviromnent - set(ENV{INCLUDE} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${INCLUDE_BACKUP}") - set(ENV{INCLUDE_PATH} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${INCLUDE_PATH_BACKUP}") - set(ENV{C_INCLUDE_PATH} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${C_INCLUDE_PATH_BACKUP}") - set(ENV{CPLUS_INCLUDE_PATH} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${CPLUS_INCLUDE_PATH_BACKUP}") - - # Setup global flags - set(C_FLAGS_GLOBAL "$ENV{CFLAGS} ${VCPKG_C_FLAGS}") - set(CXX_FLAGS_GLOBAL "$ENV{CXXFLAGS} ${VCPKG_CXX_FLAGS}") - set(LD_FLAGS_GLOBAL "$ENV{LDFLAGS} ${VCPKG_LINKER_FLAGS}") - if(NOT VCPKG_TARGET_IS_WINDOWS) - string(APPEND C_FLAGS_GLOBAL " -fPIC") - string(APPEND CXX_FLAGS_GLOBAL " -fPIC") - else() - string(APPEND C_FLAGS_GLOBAL " /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN /DWIN32 /D_WINDOWS") - string(APPEND CXX_FLAGS_GLOBAL " /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN /DWIN32 /D_WINDOWS") - string(APPEND LD_FLAGS_GLOBAL " /VERBOSE -no-undefined") - if(VCPKG_TARGET_ARCHITECTURE STREQUAL x64) - string(APPEND LD_FLAGS_GLOBAL " /machine:x64") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL x86) - string(APPEND LD_FLAGS_GLOBAL " /machine:x86") - endif() - endif() + # Since includes are buildtype independent those are setup by vcpkg_configure_make + _vcpkg_backup_env_variables(LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) foreach(BUILDTYPE "debug" "release") if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL BUILDTYPE) @@ -132,6 +90,7 @@ function(vcpkg_build_make) endif() 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) @@ -140,56 +99,21 @@ function(vcpkg_build_make) set(SHORT_BUILDTYPE "-rel") endif() 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}") + 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}") + if(_bc_ADD_BIN_TO_PATH) set(_BACKUP_ENV_PATH "$ENV{PATH}") - if(BUILDTYPE STREQUAL "debug") - vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/debug/bin") - else() - vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/bin") - endif() - endif() - - if (CMAKE_HOST_WIN32) - set(TMP_CFLAGS "${C_FLAGS_GLOBAL} ${VCPKG_C_FLAGS_${CMAKE_BUILDTYPE}}") - string(REGEX REPLACE "[ \t]+/" " -" TMP_CFLAGS "${TMP_CFLAGS}") - set(ENV{CFLAGS} ${TMP_CFLAGS}) - - set(TMP_CXXFLAGS "${CXX_FLAGS_GLOBAL} ${VCPKG_CXX_FLAGS_${CMAKE_BUILDTYPE}}") - string(REGEX REPLACE "[ \t]+/" " -" TMP_CXXFLAGS "${TMP_CXXFLAGS}") - set(ENV{CXXFLAGS} ${TMP_CXXFLAGS}) - - set(TMP_LDFLAGS "${LD_FLAGS_GLOBAL} ${VCPKG_LINKER_FLAGS_${CMAKE_BUILDTYPE}}") - string(REGEX REPLACE "[ \t]+/" " -" TMP_LDFLAGS "${TMP_LDFLAGS}") - set(ENV{LDFLAGS} ${TMP_LDFLAGS}) - - string(REPLACE " " "\ " _VCPKG_INSTALLED_PKGCONF "${CURRENT_INSTALLED_DIR}") - string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_INSTALLED_PKGCONF "${_VCPKG_INSTALLED_PKGCONF}") - string(REPLACE "\\" "/" _VCPKG_INSTALLED_PKGCONF "${_VCPKG_INSTALLED_PKGCONF}") - if(BUILDTYPE STREQUAL "debug") - set(ENV{VCPKG_PKG_PREFIX} ${_VCPKG_INSTALLED_PKGCONF}/debug) - else() - set(ENV{VCPKG_PKG_PREFIX} ${_VCPKG_INSTALLED_PKGCONF}) - endif() - - else() - set(ENV{CFLAGS} "${C_FLAGS_GLOBAL} ${VCPKG_C_FLAGS_${CMAKE_BUILDTYPE}}") - set(ENV{CXXFLAGS} "${CXX_FLAGS_GLOBAL} ${VCPKG_CXX_FLAGS_${CMAKE_BUILDTYPE}}") - - if(BUILDTYPE STREQUAL "debug") - set(ENV{LDFLAGS} "-L${_VCPKG_INSTALLED}/debug/lib/ -L${_VCPKG_INSTALLED}/debug/lib/manual-link/ ${LD_FLAGS_GLOBAL} ${VCPKG_LINKER_FLAGS_${CMAKE_BUILDTYPE}}") - set(ENV{LIBRARY_PATH} "${_VCPKG_INSTALLED}/debug/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}/debug/lib/manual-link/${LIBRARY_PATH_PATHLIKE_CONCAT}") - set(ENV{LD_LIBRARY_PATH} "${_VCPKG_INSTALLED}/debug/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}/debug/lib/manual-link/${LD_LIBRARY_PATH_PATHLIKE_CONCAT}") - else() - set(ENV{LDFLAGS} "-L${_VCPKG_INSTALLED}/lib/ -L${_VCPKG_INSTALLED}/lib/manual-link/ ${LD_FLAGS_GLOBAL} ${VCPKG_LINKER_FLAGS_${CMAKE_BUILDTYPE}}") - set(ENV{LIBRARY_PATH} "${_VCPKG_INSTALLED}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}/lib/manual-link/${LIBRARY_PATH_PATHLIKE_CONCAT}") - set(ENV{LD_LIBRARY_PATH} "${_VCPKG_INSTALLED}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}/lib/manual-link/${LD_LIBRARY_PATH_PATHLIKE_CONCAT}") - endif() + vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX}/bin") endif() if(MAKE_BASH) @@ -251,21 +175,9 @@ function(vcpkg_build_make) file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}_tmp") endif() - # Restore enviromnent - set(ENV{CFLAGS} "${C_FLAGS_BACKUP}") - set(ENV{CXXFLAGS} "${CXX_FLAGS_BACKUP}") - set(ENV{LDFLAGS} "${LD_FLAGS_BACKUP}") - - set(ENV{INCLUDE} "${INCLUDE_BACKUP}") - set(ENV{INCLUDE_PATH} "${INCLUDE_PATH_BACKUP}") - set(ENV{C_INCLUDE_PATH} "${C_INCLUDE_PATH_BACKUP}") - set(ENV{CPLUS_INCLUDE_PATH} "${CPLUS_INCLUDE_PATH_BACKUP}") - _vcpkg_restore_env_variable(LIBRARY_PATH) - _vcpkg_restore_env_variable(LD_LIBRARY_PATH) - if (CMAKE_HOST_WIN32) set(ENV{PATH} "${PATH_GLOBAL}") endif() - + _vcpkg_restore_env_variables(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 0e47b948b8a296..52000e36d85e0c 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -7,6 +7,11 @@ ## vcpkg_configure_make( ## SOURCE_PATH <${SOURCE_PATH}> ## [AUTOCONFIG] +## [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}>] @@ -29,12 +34,24 @@ ## ### SKIP_CONFIGURE ## Skip configure process ## +## ### BUILD_TRIPLET +## Used to pass custom --build/--target/--host to configure. Can be globally overwritten by VCPKG_MAKE_BUILD_TRIPLET +## +## ### NO_ADDITIONAL_PATHS +## Don't pass any additional paths except for --prefix to the configure call +## ## ### AUTOCONFIG ## Need to use autoconfig to generate configure file. ## ## ### PRERUN_SHELL ## Script that needs to be called before configuration (do not use for batch files which simply call autoconf or configure) ## +## ### ADD_BIN_TO_PATH +## Adds the appropriate Release and Debug `bin\` directories to the path during configure such that executables can run against the in-tree DLLs. +## +## ## DISABLE_VERBOSE_FLAGS +## do not pass '--disable-silent-rules --verbose' to configure +## ## ### OPTIONS ## Additional options passed to configure during the configuration. ## @@ -44,6 +61,14 @@ ## ### OPTIONS_DEBUG ## Additional options passed to configure during the Debug configuration. These are in addition to `OPTIONS`. ## +## ### CONFIG_DEPENDENT_ENVIRONMENT +## List of additional configuration dependent environment variables to set. +## Pass SOMEVAR to set the environment and have SOMEVAR_(DEBUG|RELEASE) set in the portfile to the appropriate values +## General environment variables can be set from within the portfile itself. +## +## ### CONFIGURE_ENVIRONMENT_VARIABLES +## List of additional environment variables to pass via the configure call. +## ## ## Notes ## This command supplies many common arguments to configure. To see the full list, examine the source. ## @@ -53,96 +78,145 @@ ## * [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) -macro(_vcpkg_determine_host) - # --build: the machine you are building on - # --host: the machine you are building for - # --target: the machine that GCC will produce binary for - set(HOST_ARCH $ENV{PROCESSOR_ARCHITECTURE}) - set(MINGW_W w64) - set(MINGW_PACKAGES) - #message(STATUS "${HOST_ARCH}") +macro(_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(MSYS_HOST x86_64) - set(HOST_ARCH x64) - set(BITS 64) - #list(APPEND MINGW_PACKAGES mingw-w64-x86_64-cccl) + set(${out_var} mingw64) elseif(HOST_ARCH MATCHES "(x|X)86") - set(MSYS_HOST i686) - set(HOST_ARCH x86) - set(BITS 32) - #list(APPEND MINGW_PACKAGES mingw-w64-i686-cccl) + set(${out_var} mingw32) + else() + message(FATAL_ERROR "Unsupported mingw architecture ${HOST_ARCH} in _vcpkg_determine_autotools_host_cpu!" ) + endif() + unset(HOST_ARCH) +endmacro() + +macro(_vcpkg_determine_autotools_host_cpu 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} x86_64) + elseif(HOST_ARCH MATCHES "(x|X)86") + set(${out_var} i686) elseif(HOST_ARCH MATCHES "^(ARM|arm)64$") - set(MSYS_HOST arm) - set(HOST_ARCH arm) - set(BITS 32) - #list(APPEND MINGW_PACKAGES mingw-w64-i686-cccl) + set(${out_var} aarch64) elseif(HOST_ARCH MATCHES "^(ARM|arm)$") - set(MSYS_HOST arm) - set(HOST_ARCH arm) - set(BITS 32) - #list(APPEND MINGW_PACKAGES mingw-w64-i686-cccl) - message(FATAL_ERROR "Unsupported host architecture ${HOST_ARCH} in _vcpkg_get_msys_toolchain!" ) + set(${out_var} arm) else() - message(FATAL_ERROR "Unsupported host architecture ${HOST_ARCH} in _vcpkg_get_msys_toolchain!" ) + message(FATAL_ERROR "Unsupported host architecture ${HOST_ARCH} in _vcpkg_determine_autotools_host_cpu!" ) + endif() + unset(HOST_ARCH) +endmacro() + +macro(_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 _vcpkg_determine_autotools_target_cpu!" ) endif() - set(TARGET_ARCH ${VCPKG_TARGET_ARCHITECTURE}) endmacro() macro(_vcpkg_backup_env_variable envvar) - if(ENV{${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}) + 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() function(vcpkg_configure_make) cmake_parse_arguments(_csc - "AUTOCONFIG;SKIP_CONFIGURE;COPY_SOURCE" - "SOURCE_PATH;PROJECT_SUBPATH;PRERUN_SHELL" - "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" + "AUTOCONFIG;SKIP_CONFIGURE;COPY_SOURCE;DISABLE_VERBOSE_FLAGS;NO_ADDITIONAL_PATHS;ADD_BIN_TO_PATH" + "SOURCE_PATH;PROJECT_SUBPATH;PRERUN_SHELL;BUILD_TRIPLET" + "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;CONFIGURE_ENVIRONMENT_VARIABLES;CONFIG_DEPENDENT_ENVIRONMENT" ${ARGN} ) - # Backup enviromnent variables - set(C_FLAGS_BACKUP "$ENV{CFLAGS}") - set(CXX_FLAGS_BACKUP "$ENV{CXXFLAGS}") - set(LD_FLAGS_BACKUP "$ENV{LDFLAGS}") - set(INCLUDE_PATH_BACKUP "$ENV{INCLUDE_PATH}") - set(INCLUDE_BACKUP "$ENV{INCLUDE}") - set(C_INCLUDE_PATH_BACKUP "$ENV{C_INCLUDE_PATH}") - set(CPLUS_INCLUDE_PATH_BACKUP "$ENV{CPLUS_INCLUDE_PATH}") - #set(LD_LIBRARY_PATH_BACKUP "$ENV{LD_LIBRARY_PATH}") - _vcpkg_backup_env_variable(LD_LIBRARY_PATH) - #set(LIBRARY_PATH_BACKUP "$ENV{LIBRARY_PATH}") - _vcpkg_backup_env_variable(LIBRARY_PATH) - set(LIBPATH_BACKUP "$ENV{LIBPATH}") - - if(${CURRENT_PACKAGES_DIR} MATCHES " " OR ${CURRENT_INSTALLED_DIR} MATCHES " ") + if(DEFINED VCPKG_MAKE_BUILD_TRIPLET) + set(_csc_BUILD_TRIPLET ${VCPKG_MAKE_BUILD_TRIPLET}) # Triplet overwrite for crosscompiling + endif() + + set(SRC_DIR "${_csc_SOURCE_PATH}/${_csc_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 + if(NOT VCPKG_MAINTAINER_SKIP_AUTOCONFIG) # If fixing bugs skipping autoconfig saves a lot of time + set(REQUIRES_AUTOCONFIG TRUE) + file(REMOVE "${SRC_DIR}/configure") # remove possible autodated configure scripts + set(_csc_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) + else() + message(FATAL_ERROR "Could not determine method to configure make") + endif() + + debug_message("REQUIRES_AUTOGEN:${REQUIRES_AUTOGEN}") + debug_message("REQUIRES_AUTOCONFIG:${REQUIRES_AUTOCONFIG}") + # Backup environment variables + # CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJCXX R UPC Y + set(FLAGPREFIXES CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJXX R UPC Y) + foreach(_prefix IN LISTS FLAGPREFIXES) + _vcpkg_backup_env_variable(${prefix}FLAGS) + endforeach() + + # FC fotran compiler | FF Fortran 77 compiler + # LDFLAGS -> pass -L flags + # LIBS -> pass -l flags + + #Used by gcc/linux + _vcpkg_backup_env_variables(C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH) + + #Used by cl + _vcpkg_backup_env_variables(INCLUDE LIB LIBPATH) + + 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") endif() # Pre-processing windows configure requirements if (CMAKE_HOST_WIN32) - # YASM and PERL are not strictly required by all ports. - # So this should probably be moved into the portfile - # vcpkg_find_acquire_program(YASM) - # get_filename_component(YASM_EXE_PATH ${YASM} DIRECTORY) - # vcpkg_add_to_path("${YASM_EXE_PATH}") - - # vcpkg_find_acquire_program(PERL) - # get_filename_component(PERL_EXE_PATH ${PERL} DIRECTORY) - # vcpkg_add_to_path("${PERL_EXE_PATH}") + _vcpkg_determine_autotools_host_cpu(BUILD_ARCH) # VCPKG_HOST => machine you are building on => --build= list(APPEND MSYS_REQUIRE_PACKAGES diffutils pkg-config @@ -150,16 +224,36 @@ function(vcpkg_configure_make) libtool gettext gettext-devel - make) + ) + list(APPEND MSYS_REQUIRE_PACKAGES make) if (_csc_AUTOCONFIG) list(APPEND MSYS_REQUIRE_PACKAGES autoconf autoconf-archive automake m4 ) + # --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 _csc_BUILD_TRIPLET) + set(_csc_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 + _vcpkg_determine_autotools_target_cpu(TARGET_ARCH) + if(NOT TARGET_ARCH MATCHES "${BUILD_ARCH}") # we do not need to specify the additional flags if we build nativly. + 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) + endif() + if(VCPKG_TARGET_IS_UWP AND NOT _csc_BUILD_TRIPLET MATCHES "--host") + # Needs to be different from --build to enable cross builds. + string(APPEND _csc_BUILD_TRIPLET " --host=${TARGET_ARCH}-unknown-mingw32") + endif() + endif() + debug_message("Using make triplet: ${_csc_BUILD_TRIPLET}") endif() vcpkg_acquire_msys(MSYS_ROOT PACKAGES ${MSYS_REQUIRE_PACKAGES}) vcpkg_add_to_path("${MSYS_ROOT}/usr/bin") + set(BASH "${MSYS_ROOT}/usr/bin/bash.exe") # This is required because PATH contains sort and find from Windows but the MSYS versions are needed @@ -167,40 +261,42 @@ function(vcpkg_configure_make) file(CREATE_LINK "${MSYS_ROOT}/usr/bin/sort.exe" "${SCRIPTS}/buildsystems/make_wrapper/sort.exe" COPY_ON_ERROR) file(CREATE_LINK "${MSYS_ROOT}/usr/bin/find.exe" "${SCRIPTS}/buildsystems/make_wrapper/find.exe" COPY_ON_ERROR) vcpkg_add_to_path(PREPEND "${SCRIPTS}/buildsystems/make_wrapper") # Other required wrappers are also located there + vcpkg_add_to_path(PREPEND "${MSYS_ROOT}/usr/share/automake-1.16") # Required wrappers are located here (compile ar-lib) - # --build: the machine you are building on - # --host: the machine you are building for - # --target: the machine that CC will produce binaries for - _vcpkg_determine_host() # VCPKG_HOST => machine you are building on => --build= - if(VCPKG_TARGET_ARCHITECTURE STREQUAL x86) - set(BUILD_TARGET "--build=${MSYS_HOST}-pc-mingw32 --target=i686-pc-mingw32 --host=i686-pc-mingw32") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL x64) - set(BUILD_TARGET "--build=${MSYS_HOST}-pc-mingw32 --target=x86_64-pc-mingw32 --host=x86_64-pc-mingw32") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm) - set(BUILD_TARGET "--build=${MSYS_HOST}-pc-mingw32 --target=arm-pc-mingw32 --host=i686-pc-mingw32") - endif() - macro(_vcpkg_append_to_configure_environment inoutstring var defaultval) - # Allows to overwrite settings in custom triplets via the enviromnent - if(ENV{${var}}) + # Allows to overwrite settings in custom triplets via the environment + if(DEFINED ENV{${var}}) string(APPEND ${inoutstring} " ${var}='$ENV{${var}}'") else() string(APPEND ${inoutstring} " ${var}='${defaultval}'") endif() endmacro() - set(CONFIGURE_ENV "") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "${MSYS_ROOT}/usr/share/automake-1.16/compile cl.exe -nologo") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "${MSYS_ROOT}/usr/share/automake-1.16/compile cl.exe -nologo") + set(CONFIGURE_ENV "V=1") + if (_csc_AUTOCONFIG) # 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 + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "compile cl.exe -nologo -E") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "compile cl.exe -nologo") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "compile cl.exe -nologo") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "ar-lib lib.exe -verbose") + else() + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "cl.exe -nologo -E") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "cl.exe -nologo") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "cl.exe -nologo") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "lib.exe -verbose") + endif() _vcpkg_append_to_configure_environment(CONFIGURE_ENV LD "link.exe -verbose") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "${MSYS_ROOT}/usr/share/automake-1.16/ar-lib lib.exe -verbose") _vcpkg_append_to_configure_environment(CONFIGURE_ENV RANLIB ":") # Trick to ignore the RANLIB call + #_vcpkg_append_to_configure_environment(CONFIGURE_ENV OBJDUMP ":") ' Objdump is required to make shared libraries. Otherwise define lt_cv_deplibs_check_method=pass_all _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 NM "dumpbin.exe -symbols -headers -all") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV STRIP ":") # If required set the ENV variable STRIP in the portfile correctly + _vcpkg_append_to_configure_environment(CONFIGURE_ENV NM "dumpbin.exe -symbols -headers") # 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 DLLTOOL "link.exe -verbose -dll") - + + foreach(_env IN LISTS _csc_CONFIGURE_ENVIRONMENT_VARIABLES) + _vcpkg_append_to_configure_environment(CONFIGURE_ENV ${_env} "${${_env}}") + endforeach() # 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. @@ -228,11 +324,11 @@ function(vcpkg_configure_make) "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}") - set(ENV{V} "1") #Enable Verbose MODE - # Set configure paths - set(_csc_OPTIONS_RELEASE ${_csc_OPTIONS_RELEASE} - "--prefix=${EXTRA_QUOTES}${_VCPKG_PREFIX}${EXTRA_QUOTES}" + set(_csc_OPTIONS_RELEASE ${_csc_OPTIONS_RELEASE} "--prefix=${EXTRA_QUOTES}${_VCPKG_PREFIX}${EXTRA_QUOTES}") + set(_csc_OPTIONS_DEBUG ${_csc_OPTIONS_DEBUG} "--prefix=${EXTRA_QUOTES}${_VCPKG_PREFIX}/debug${EXTRA_QUOTES}") + if(NOT _csc_NO_ADDITIONAL_PATHS) + set(_csc_OPTIONS_RELEASE ${_csc_OPTIONS_RELEASE} # Important: These should all be relative to prefix! "--bindir=${prefix_var}/tools/${PORT}/bin" "--sbindir=${prefix_var}/tools/${PORT}/sbin" @@ -241,25 +337,25 @@ function(vcpkg_configure_make) "--mandir=${prefix_var}/share/${PORT}" "--docdir=${prefix_var}/share/${PORT}" "--datarootdir=${prefix_var}/share/${PORT}") - set(_csc_OPTIONS_DEBUG ${_csc_OPTIONS_DEBUG} - "--prefix=${EXTRA_QUOTES}${_VCPKG_PREFIX}/debug${EXTRA_QUOTES}" + set(_csc_OPTIONS_DEBUG ${_csc_OPTIONS_DEBUG} # Important: These should all be relative to prefix! "--bindir=${prefix_var}/../tools/${PORT}/debug/bin" "--sbindir=${prefix_var}/../tools/${PORT}/debug/sbin" #"--libdir='\${prefix}'/lib" # already the default! "--includedir=${prefix_var}/../include" "--datarootdir=${prefix_var}/share/${PORT}") - + endif() # Setup common options + if(NOT DISABLE_VERBOSE_FLAGS) + list(APPEND _csc_OPTIONS --disable-silent-rules --verbose) + endif() + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - list(APPEND _csc_OPTIONS --disable-silent-rules --verbose --enable-shared --disable-static) - if (VCPKG_TARGET_IS_UWP) - list(APPEND _csc_OPTIONS --extra-ldflags=-APPCONTAINER --extra-ldflags=WindowsApp.lib) - endif() + list(APPEND _csc_OPTIONS --enable-shared --disable-static) else() - list(APPEND _csc_OPTIONS --disable-silent-rules --verbose --enable-static --disable-shared) + list(APPEND _csc_OPTIONS --disable-shared --enable-static) endif() - + file(RELATIVE_PATH RELATIVE_BUILD_PATH "${CURRENT_BUILDTREES_DIR}" "${_csc_SOURCE_PATH}/${_csc_PROJECT_SUBPATH}") set(base_cmd) @@ -270,39 +366,50 @@ function(vcpkg_configure_make) set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake") endif() include("${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}") - if(VCPKG_TARGET_IS_UWP) - # Flags should be set in the toolchain instead - set(ENV{LIBPATH} "$ENV{LIBPATH};$ENV{_WKITS10}references\\windows.foundation.foundationcontract\\2.0.0.0\\;$ENV{_WKITS10}references\\windows.foundation.universalapicontract\\3.0.0.0\\") - set(_csc_OPTIONS ${_csc_OPTIONS} --extra-cflags=-DWINAPI_FAMILY=WINAPI_FAMILY_APP --extra-cflags=-D_WIN32_WINNT=0x0A00) - endif() #Join the options list as a string with spaces between options list(JOIN _csc_OPTIONS " " _csc_OPTIONS) list(JOIN _csc_OPTIONS_RELEASE " " _csc_OPTIONS_RELEASE) list(JOIN _csc_OPTIONS_DEBUG " " _csc_OPTIONS_DEBUG) endif() - # Setup include enviromnent + # Setup include environment (since these are buildtype independent restoring them is unnecessary) + # Used by CL set(ENV{INCLUDE} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${INCLUDE_BACKUP}") - set(ENV{INCLUDE_PATH} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${INCLUDE_PATH_BACKUP}") + # Used by GCC set(ENV{C_INCLUDE_PATH} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${C_INCLUDE_PATH_BACKUP}") set(ENV{CPLUS_INCLUDE_PATH} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${CPLUS_INCLUDE_PATH_BACKUP}") # Setup global flags -> TODO: Further improve with toolchain file in mind! + set(CPP_FLAGS_GLOBAL "$ENV{CPPFLAGS} -I${_VCPKG_INSTALLED}/include") set(C_FLAGS_GLOBAL "$ENV{CFLAGS} ${VCPKG_C_FLAGS}") set(CXX_FLAGS_GLOBAL "$ENV{CXXFLAGS} ${VCPKG_CXX_FLAGS}") set(LD_FLAGS_GLOBAL "$ENV{LDFLAGS} ${VCPKG_LINKER_FLAGS}") - # Flags should be set in the toolchain instead + # 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(NOT VCPKG_TARGET_IS_WINDOWS) string(APPEND C_FLAGS_GLOBAL " -fPIC") string(APPEND CXX_FLAGS_GLOBAL " -fPIC") else() - string(APPEND C_FLAGS_GLOBAL " /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN /DWIN32 /D_WINDOWS") - string(APPEND CXX_FLAGS_GLOBAL " /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN /DWIN32 /D_WINDOWS") - string(APPEND LD_FLAGS_GLOBAL " /VERBOSE -no-undefined") + # TODO: Should be CPP flags instead -> rewrite when vcpkg_determined_cmake_compiler_flags defined + string(APPEND CPP_FLAGS_GLOBAL " /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN /DWIN32 /D_WINDOWS") + 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}") + set(ENV{_CL_} "$ENV{_CL_} /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB_ -FU\"${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\"") + set(ENV{_LINK_} "$ENV{_LINK_} /MANIFEST /DYNAMICBASE WindowsApp.lib /WINMD:NO /APPCONTAINER") + endif() if(VCPKG_TARGET_ARCHITECTURE STREQUAL x64) - string(APPEND LD_FLAGS_GLOBAL " /machine:x64") + set(ENV{_LINK_} "$ENV{_LINK_} -MACHINE:x64") elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL x86) - string(APPEND LD_FLAGS_GLOBAL " /machine:x86") + set(ENV{_LINK_} "$ENV{_LINK_} -MACHINE:x86") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm) + set(ENV{_LINK_} "$ENV{_LINK_} -MACHINE:ARM") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm64) + set(ENV{_LINK_} "$ENV{_LINK_} -MACHINE:ARM64") endif() endif() @@ -316,20 +423,10 @@ function(vcpkg_configure_make) debug_message("ENV{PKG_CONFIG} found! Using: $ENV{PKG_CONFIG}") set(PKGCONFIG $ENV{PKG_CONFIG}) endif() - - set(SRC_DIR "${_csc_SOURCE_PATH}/${_csc_PROJECT_SUBPATH}") - - # Run autoconf if necessary - if(EXISTS "${SRC_DIR}/configure" AND NOT _csc_SKIP_CONFIGURE) - set(REQUIRES_AUTOCONFIG FALSE) # use autotools and configure.ac - set(REQUIRES_AUTOGEN FALSE) # use autogen.sh - elseif(EXISTS "${SRC_DIR}/configure.ac") - set(REQUIRES_AUTOCONFIG TRUE) - set(REQUIRES_AUTOGEN FALSE) - elseif(EXISTS "${SRC_DIR}/autogen.sh") - set(REQUIRES_AUTOGEN TRUE) - set(REQUIRES_AUTOCONFIG FALSE) + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" AND NOT PKGCONFIG STREQUAL "--static") + set(PKGCONFIG "${PKGCONFIG} --static") endif() + # Run autoconf if necessary set(_GENERATED_CONFIGURE FALSE) if (_csc_AUTOCONFIG OR REQUIRES_AUTOCONFIG) find_program(AUTORECONF autoreconf REQUIRED) @@ -393,10 +490,12 @@ function(vcpkg_configure_make) set(SHORT_NAME_${_VAR_SUFFIX} "dbg") list(APPEND _buildtypes ${_VAR_SUFFIX}) if (CMAKE_HOST_WIN32) # Flags should be set in the toolchain instead + string(REGEX REPLACE "[ \t]+/" " -" CPPFLAGS_${_VAR_SUFFIX} "${CPP_FLAGS_GLOBAL}") string(REGEX REPLACE "[ \t]+/" " -" CFLAGS_${_VAR_SUFFIX} "${C_FLAGS_GLOBAL} ${VCPKG_CRT_LINK_FLAG_PREFIX}d /D_DEBUG /Ob0 /Od ${VCPKG_C_FLAGS_${_VAR_SUFFIX}}") string(REGEX REPLACE "[ \t]+/" " -" CXXFLAGS_${_VAR_SUFFIX} "${CXX_FLAGS_GLOBAL} ${VCPKG_CRT_LINK_FLAG_PREFIX}d /D_DEBUG /Ob0 /Od ${VCPKG_CXX_FLAGS_${_VAR_SUFFIX}}") string(REGEX REPLACE "[ \t]+/" " -" LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib ${LD_FLAGS_GLOBAL} ${VCPKG_LINKER_FLAGS_${_VAR_SUFFIX}}") else() + set(CPPFLAGS_${_VAR_SUFFIX} "${CPP_FLAGS_GLOBAL}") set(CFLAGS_${_VAR_SUFFIX} "${C_FLAGS_GLOBAL} ${VCPKG_C_FLAGS_DEBUG}") set(CXXFLAGS_${_VAR_SUFFIX} "${CXX_FLAGS_GLOBAL} ${VCPKG_CXX_FLAGS_DEBUG}") set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/ ${LD_FLAGS_GLOBAL} ${VCPKG_LINKER_FLAGS_${_VAR_SUFFIX}}") @@ -408,11 +507,13 @@ function(vcpkg_configure_make) set(PATH_SUFFIX_${_VAR_SUFFIX} "") set(SHORT_NAME_${_VAR_SUFFIX} "rel") list(APPEND _buildtypes ${_VAR_SUFFIX}) - if (CMAKE_HOST_WIN32) # Flags should be set in the toolchain instead + if (CMAKE_HOST_WIN32) # Flags should be set in the toolchain + string(REGEX REPLACE "[ \t]+/" " -" CPPFLAGS_${_VAR_SUFFIX} "${CPP_FLAGS_GLOBAL}") string(REGEX REPLACE "[ \t]+/" " -" CFLAGS_${_VAR_SUFFIX} "${C_FLAGS_GLOBAL} ${VCPKG_CRT_LINK_FLAG_PREFIX} /O2 /Oi /Gy /DNDEBUG ${VCPKG_C_FLAGS_${_VAR_SUFFIX}}") string(REGEX REPLACE "[ \t]+/" " -" CXXFLAGS_${_VAR_SUFFIX} "${CXX_FLAGS_GLOBAL} ${VCPKG_CRT_LINK_FLAG_PREFIX} /O2 /Oi /Gy /DNDEBUG ${VCPKG_CXX_FLAGS_${_VAR_SUFFIX}}") string(REGEX REPLACE "[ \t]+/" " -" LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib ${LD_FLAGS_GLOBAL} ${VCPKG_LINKER_FLAGS_${_VAR_SUFFIX}}") else() + set(CPPFLAGS_${_VAR_SUFFIX} "${CPP_FLAGS_GLOBAL}") set(CFLAGS_${_VAR_SUFFIX} "${C_FLAGS_GLOBAL} ${VCPKG_C_FLAGS_DEBUG}") set(CXXFLAGS_${_VAR_SUFFIX} "${CXX_FLAGS_GLOBAL} ${VCPKG_CXX_FLAGS_DEBUG}") set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/ ${LD_FLAGS_GLOBAL} ${VCPKG_LINKER_FLAGS_${_VAR_SUFFIX}}") @@ -421,6 +522,13 @@ function(vcpkg_configure_make) endif() foreach(_buildtype IN LISTS _buildtypes) + foreach(ENV_VAR ${_csc_CONFIG_DEPENDENT_ENVIRONMENT}) + if(DEFINED ENV{${ENV_VAR}}) + set(BACKUP_CONFIG_${ENV_VAR} "$ENV{${ENV_VAR}}") + endif() + set(ENV{${ENV_VAR}} "${${ENV_VAR}_${_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}") @@ -440,22 +548,28 @@ function(vcpkg_configure_make) set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}:${PKGCONFIG_INSTALLED_SHARE_DIR}") endif() - # Setup enviromnent + # Setup environment + set(ENV{CPPFLAGS} ${CPPFLAGS_${_buildtype}}) set(ENV{CFLAGS} ${CFLAGS_${_buildtype}}) set(ENV{CXXFLAGS} ${CXXFLAGS_${_buildtype}}) set(ENV{LDFLAGS} ${LDFLAGS_${_buildtype}}) set(ENV{PKG_CONFIG} "${PKGCONFIG} --define-variable=prefix=${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}") - set(ENV{LIBPATH} "${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/lib${VCPKG_HOST_PATH_SEPARATOR}${LIBPATH_BACKUP}") - - set(ENV{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{LIB} "${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/lib/manual-link/${LIB_PATHLIKE_CONCAT}") + set(ENV{LIBPATH} "${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/lib/manual-link/${LIBPATH_PATHLIKE_CONCAT}") + set(ENV{LIBRARY_PATH} "${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/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}") - if (CMAKE_HOST_WIN32) - set(command ${base_cmd} -c "${CONFIGURE_ENV} ./${RELATIVE_BUILD_PATH}/configure ${BUILD_TARGET} ${HOST_TYPE}${_csc_OPTIONS} ${_csc_OPTIONS_${_buildtype}}") + if (CMAKE_HOST_WIN32) + set(command ${base_cmd} -c "${CONFIGURE_ENV} ./${RELATIVE_BUILD_PATH}/configure ${_csc_BUILD_TRIPLET} ${_csc_OPTIONS} ${_csc_OPTIONS_${_buildtype}}") else() - set(command /bin/bash "./${RELATIVE_BUILD_PATH}/configure" ${_csc_OPTIONS} ${_csc_OPTIONS_${_buildtype}}) + set(command /bin/bash "./${RELATIVE_BUILD_PATH}/configure" ${_csc_BUILD_TRIPLET} ${_csc_OPTIONS} ${_csc_OPTIONS_${_buildtype}}) endif() - + if(_csc_ADD_BIN_TO_PATH) + set(PATH_BACKUP $ENV{PATH}) + vcpkg_add_to_path("${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_buildtype}}/bin") + endif() + debug_message("Configure command:'${command}'") if (NOT _csc_SKIP_CONFIGURE) message(STATUS "Configuring ${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}") vcpkg_execute_required_process( @@ -477,20 +591,27 @@ function(vcpkg_configure_make) unset(ENV{PKG_CONFIG_PATH}) endif() unset(BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype}) + + if(_csc_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}}") + else() + unset(ENV{${ENV_VAR}}) + endif() + endforeach() + endforeach() + + # Restore environment + foreach(_prefix IN LISTS FLAGPREFIXES) + _vcpkg_restore_env_variable(${prefix}FLAGS) endforeach() - - # Restore enviromnent - set(ENV{CFLAGS} "${C_FLAGS_BACKUP}") - set(ENV{CXXFLAGS} "${CXX_FLAGS_BACKUP}") - set(ENV{LDFLAGS} "${LD_FLAGS_BACKUP}") - - set(ENV{INCLUDE} "${INCLUDE_BACKUP}") - set(ENV{INCLUDE_PATH} "${INCLUDE_PATH_BACKUP}") - set(ENV{C_INCLUDE_PATH} "${C_INCLUDE_PATH_BACKUP}") - set(ENV{CPLUS_INCLUDE_PATH} "${CPLUS_INCLUDE_PATH_BACKUP}") - _vcpkg_restore_env_variable(LIBRARY_PATH) - _vcpkg_restore_env_variable(LD_LIBRARY_PATH) - set(ENV{LIBPATH} "${LIBPATH_BACKUP}") + + _vcpkg_restore_env_variables(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) endfunction()