diff --git a/ports/libepoxy/CONTROL b/ports/libepoxy/CONTROL new file mode 100644 index 00000000000000..8ac70cd2242670 --- /dev/null +++ b/ports/libepoxy/CONTROL @@ -0,0 +1,3 @@ +Source: libepoxy +Version: 1.4.0-2432daf +Description: Epoxy is a library for handling OpenGL function pointer management for you diff --git a/ports/libepoxy/portfile.cmake b/ports/libepoxy/portfile.cmake new file mode 100644 index 00000000000000..add95b480fa6ef --- /dev/null +++ b/ports/libepoxy/portfile.cmake @@ -0,0 +1,17 @@ + +include(vcpkg_common_functions) +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libepoxy-2432daf4cf58b5ff11e008ca34811588285c43b3) +vcpkg_download_distfile(ARCHIVE + URLS "https://github.com/anholt/libepoxy/archive/2432daf4cf58b5ff11e008ca34811588285c43b3.zip" + FILENAME "libepoxy-2432daf4cf58b5ff11e008ca34811588285c43b3.zip" + SHA512 70b59b6c5722eb87522927fdedab44f74ffd2d71d2ae42509de07b0c3e13f71320b25da0d4c75dca75c4208ea7a525483267d6ccb8acd5274728c015c7ac4006) + +vcpkg_extract_source_archive(${ARCHIVE}) + +vcpkg_configure_meson(SOURCE_PATH ${SOURCE_PATH}) +vcpkg_install_meson() + +vcpkg_copy_pdbs() + +file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libepoxy) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/libepoxy/COPYING ${CURRENT_PACKAGES_DIR}/share/libepoxy/copyright) diff --git a/scripts/cmake/vcpkg_common_functions.cmake b/scripts/cmake/vcpkg_common_functions.cmake index 6e60bf2bc35a66..fb626efe8ae71a 100644 --- a/scripts/cmake/vcpkg_common_functions.cmake +++ b/scripts/cmake/vcpkg_common_functions.cmake @@ -7,7 +7,9 @@ include(vcpkg_build_cmake) include(vcpkg_build_msbuild) include(vcpkg_build_qmake) include(vcpkg_install_cmake) +include(vcpkg_install_meson) include(vcpkg_configure_cmake) +include(vcpkg_configure_meson) include(vcpkg_configure_qmake) include(vcpkg_apply_patches) include(vcpkg_copy_pdbs) diff --git a/scripts/cmake/vcpkg_configure_meson.cmake b/scripts/cmake/vcpkg_configure_meson.cmake new file mode 100644 index 00000000000000..277f91e11776b5 --- /dev/null +++ b/scripts/cmake/vcpkg_configure_meson.cmake @@ -0,0 +1,72 @@ +function(vcpkg_configure_meson) + cmake_parse_arguments(_vcm "" "SOURCE_PATH" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ARGN}) + + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + + # use the same compiler options as in vcpkg_configure_cmake + set(MESON_COMMON_CFLAGS "${MESON_COMMON_CFLAGS} /DWIN32 /D_WINDOWS /W3 /utf-8") + set(MESON_COMMON_CXXFLAGS "${MESON_COMMON_CXXFLAGS} /DWIN32 /D_WINDOWS /W3 /utf-8 /GR /EHsc") + + if(DEFINED VCPKG_CRT_LINKAGE AND VCPKG_CRT_LINKAGE STREQUAL dynamic) + set(MESON_DEBUG_CFLAGS "${MESON_DEBUG_CFLAGS} /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1") + set(MESON_DEBUG_CXXFLAGS "${MESON_DEBUG_CXXFLAGS} /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1") + + set(MESON_RELEASE_CFLAGS "${MESON_RELEASE_CFLAGS} /MD /O2 /Oi /Gy /DNDEBUG /Zi") + set(MESON_RELEASE_CXXFLAGS "${MESON_RELEASE_CXXFLAGS} /MD /O2 /Oi /Gy /DNDEBUG /Zi") + elseif(DEFINED VCPKG_CRT_LINKAGE AND VCPKG_CRT_LINKAGE STREQUAL static) + set(MESON_DEBUG_CFLAGS "${MESON_DEBUG_CFLAGS} /D_DEBUG /MTd /Zi /Ob0 /Od /RTC1") + set(MESON_DEBUG_CXXFLAGS "${MESON_DEBUG_CXXFLAGS} /D_DEBUG /MTd /Zi /Ob0 /Od /RTC1") + + set(MESON_RELEASE_CFLAGS "${MESON_RELEASE_CFLAGS} /MT /O2 /Oi /Gy /DNDEBUG /Zi") + set(MESON_RELEASE_CXXFLAGS "${MESON_RELEASE_CXXFLAGS} /MT /O2 /Oi /Gy /DNDEBUG /Zi") + endif() + + set(MESON_COMMON_LDFLAGS "${MESON_COMMON_LDFLAGS} /DEBUG") + set(MESON_RELEASE_LDFLAGS "${MESON_RELEASE_LDFLAGS} /INCREMENTAL:NO /OPT:REF /OPT:ICF") + + # select meson cmd-line options + list(APPEND _vcm_OPTIONS --buildtype plain --backend ninja) + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + list(APPEND _vcm_OPTIONS --default-library shared) + else() + list(APPEND _vcm_OPTIONS --default-library static) + endif() + + list(APPEND _vcm_OPTIONS_DEBUG --prefix ${CURRENT_PACKAGES_DIR}/debug --includedir ../include) + list(APPEND _vcm_OPTIONS_RELEASE --prefix ${CURRENT_PACKAGES_DIR}) + + vcpkg_find_acquire_program(MESON) + vcpkg_find_acquire_program(NINJA) + get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) + set(ENV{PATH} "$ENV{PATH};${NINJA_PATH}") + + # configure release + message(STATUS "Configuring ${TARGET_TRIPLET}-rel") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) + set(ENV{CFLAGS} "${MESON_COMMON_CFLAGS} ${MESON_RELEASE_CFLAGS}") + set(ENV{CXXFLAGS} "${MESON_COMMON_CXXFLAGS} ${MESON_RELEASE_CXXFLAGS}") + set(ENV{LDFLAGS} "${MESON_COMMON_LDFLAGS} ${MESON_RELEASE_LDFLAGS}") + set(ENV{CPPFLAGS} "${MESON_COMMON_CPPFLAGS} ${MESON_RELEASE_CPPFLAGS}") + vcpkg_execute_required_process( + COMMAND ${MESON} ${_vcm_OPTIONS} ${_vcm_OPTIONS_RELEASE} ${_vcm_SOURCE_PATH} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel + LOGNAME config-${TARGET_TRIPLET}-rel + ) + message(STATUS "Configuring ${TARGET_TRIPLET}-rel done") + + # configure debug + message(STATUS "Configuring ${TARGET_TRIPLET}-dbg") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + set(ENV{CFLAGS} "${MESON_COMMON_CFLAGS} ${MESON_DEBUG_CFLAGS}") + set(ENV{CXXFLAGS} "${MESON_COMMON_CXXFLAGS} ${MESON_DEBUG_CXXFLAGS}") + set(ENV{LDFLAGS} "${MESON_COMMON_LDFLAGS} ${MESON_DEBUG_LDFLAGS}") + set(ENV{CPPFLAGS} "${MESON_COMMON_CPPFLAGS} ${MESON_DEBUG_CPPFLAGS}") + vcpkg_execute_required_process( + COMMAND ${MESON} ${_vcm_OPTIONS} ${_vcm_OPTIONS_DEBUG} ${_vcm_SOURCE_PATH} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg + LOGNAME config-${TARGET_TRIPLET}-dbg + ) + message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done") + +endfunction() diff --git a/scripts/cmake/vcpkg_find_acquire_program.cmake b/scripts/cmake/vcpkg_find_acquire_program.cmake index 044291382934d2..b9a397fcc8769e 100644 --- a/scripts/cmake/vcpkg_find_acquire_program.cmake +++ b/scripts/cmake/vcpkg_find_acquire_program.cmake @@ -5,6 +5,7 @@ function(vcpkg_find_acquire_program VAR) unset(NOEXTRACT) unset(SUBDIR) + unset(REQUIRED_INTERPRETER) if(VAR MATCHES "PERL") set(PROGNAME perl) @@ -70,12 +71,30 @@ function(vcpkg_find_acquire_program VAR) set(PATHS ${DOWNLOADS}/tools/ninja/${SUBDIR}) set(URL "https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-win.zip") set(ARCHIVE "ninja-win.zip") - set(HASH cccab9281b274c564f9ad77a2115be1f19be67d7b2ee14a55d1db1b27f3b68db8e76076e4f804b61eb8e573e26a8ecc9985675a8dcf03fd7a77b7f57234f1393) + set(HASH cccab9281b274c564f9ad77a2115be1f19be67d7b2ee14a55d1db1b27f3b68db8e76076e4f804b61eb8e573e26a8ecc9985675a8dcf03fd7a77b7f57234f1393) + elseif(VAR MATCHES "MESON") + set(PROGNAME meson) + set(REQUIRED_INTERPRETER PYTHON3) + set(SCRIPTNAME meson.py) + set(PATHS ${DOWNLOADS}/tools/meson/meson-0.38.1) + set(URL "https://github.com/mesonbuild/meson/archive/0.38.1.zip") + set(ARCHIVE "meson-0.38.1.zip") + set(HASH 89642b1d976af7e29e9ca2b1a378510ce286ebd90a8234e898f3dd9dd7151538fdfc61fba770681605dad843b77b344fee94f992f18328655669d5f603c7fee5) else() message(FATAL "unknown tool ${VAR} -- unable to acquire.") endif() - find_program(${VAR} ${PROGNAME} PATHS ${PATHS}) + macro(do_find) + if(NOT DEFINED REQUIRED_INTERPRETER) + find_program(${VAR} ${PROGNAME} PATHS ${PATHS}) + else() + vcpkg_find_acquire_program(${REQUIRED_INTERPRETER}) + find_file(SCIRPT ${SCRIPTNAME} PATHS ${PATHS}) + set(${VAR} ${${REQUIRED_INTERPRETER}} ${SCIRPT}) + endif() + endmacro() + + do_find() if(${VAR} MATCHES "-NOTFOUND") file(DOWNLOAD ${URL} ${DOWNLOADS}/${ARCHIVE} EXPECTED_HASH SHA512=${HASH} @@ -102,7 +121,7 @@ function(vcpkg_find_acquire_program VAR) endif() endif() - find_program(${VAR} ${PROGNAME} PATHS ${PATHS}) + do_find() endif() set(${VAR} ${${VAR}} PARENT_SCOPE) diff --git a/scripts/cmake/vcpkg_install_meson.cmake b/scripts/cmake/vcpkg_install_meson.cmake new file mode 100644 index 00000000000000..21737bdc9edd3f --- /dev/null +++ b/scripts/cmake/vcpkg_install_meson.cmake @@ -0,0 +1,23 @@ +function(vcpkg_install_meson) + + vcpkg_find_acquire_program(NINJA) + + unset(ENV{DESTDIR}) # installation directory was already specified with '--prefix' option + + message(STATUS "Package ${TARGET_TRIPLET}-rel") + vcpkg_execute_required_process( + COMMAND ${NINJA} install -v + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel + LOGNAME package-${TARGET_TRIPLET}-rel + ) + message(STATUS "Package ${TARGET_TRIPLET}-rel done") + + message(STATUS "Package ${TARGET_TRIPLET}-dbg") + vcpkg_execute_required_process( + COMMAND ${NINJA} install -v + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg + LOGNAME package-${TARGET_TRIPLET}-dbg + ) + message(STATUS "Package ${TARGET_TRIPLET}-dbg done") + +endfunction()