|
| 1 | +function(vcpkg_mesonpy_prepare_build_options) |
| 2 | + cmake_parse_arguments(PARSE_ARGV 0 arg |
| 3 | + "" |
| 4 | + "OUTPUT" |
| 5 | + "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;LANGUAGES;ADDITIONAL_BINARIES;ADDITIONAL_NATIVE_BINARIES;ADDITIONAL_CROSS_BINARIES;ADDITIONAL_PROPERTIES" |
| 6 | + ) |
| 7 | + if(NOT arg_LANGUAGES) |
| 8 | + set(arg_LANGUAGES C CXX) |
| 9 | + endif() |
| 10 | + if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE) |
| 11 | + z_vcpkg_select_default_vcpkg_chainload_toolchain() |
| 12 | + endif() |
| 13 | + z_vcpkg_get_cmake_vars(cmake_vars_file) |
| 14 | + debug_message("Including cmake vars from: ${cmake_vars_file}") |
| 15 | + include("${cmake_vars_file}") |
| 16 | + |
| 17 | + set(ENV{MESON} "${SCRIPT_MESON}") |
| 18 | + |
| 19 | + get_filename_component(CMAKE_PATH "${CMAKE_COMMAND}" DIRECTORY) |
| 20 | + vcpkg_add_to_path("${CMAKE_PATH}") # Make CMake invokeable for Meson |
| 21 | + |
| 22 | + vcpkg_find_acquire_program(NINJA) |
| 23 | + get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) |
| 24 | + vcpkg_add_to_path(PREPEND "${NINJA_PATH}") # Prepend to use the correct ninja. |
| 25 | + |
| 26 | + vcpkg_find_acquire_program(PYTHON3) |
| 27 | + x_vcpkg_get_python_packages( |
| 28 | + PYTHON_VERSION 3 |
| 29 | + PYTHON_EXECUTABLE ${PYTHON3} |
| 30 | + PACKAGES gpep517 setuptools-scm |
| 31 | + OUT_PYTHON_VAR PYTHON3 |
| 32 | + ) |
| 33 | +<<<<<<< HEAD |
| 34 | +======= |
| 35 | + get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) |
| 36 | + vcpkg_add_to_path(PREPEND "${PYTHON3_DIR}") |
| 37 | +>>>>>>> 08d29ce (python path) |
| 38 | + |
| 39 | + set(buildname "RELEASE") |
| 40 | + vcpkg_list(APPEND buildtypes "${buildname}") |
| 41 | + set(path_suffix_${buildname} "") |
| 42 | + set(suffix_${buildname} "rel") |
| 43 | + set(meson_input_file_${buildname} "${CURRENT_BUILDTREES_DIR}/meson-${TARGET_TRIPLET}-${suffix_${buildname}}.log") |
| 44 | + |
| 45 | + vcpkg_list(APPEND arg_OPTIONS --backend ninja --wrap-mode nodownload -Dbuildtype=plain -Doptimization=plain) |
| 46 | + |
| 47 | + z_vcpkg_get_build_and_host_system(MESON_HOST_MACHINE MESON_BUILD_MACHINE IS_CROSS) |
| 48 | + |
| 49 | + if(IS_CROSS) |
| 50 | + # VCPKG_CROSSCOMPILING is not used since it regresses a lot of ports in x64-windows-x triplets |
| 51 | + # For consistency this should proably be changed in the future? |
| 52 | + vcpkg_list(APPEND arg_OPTIONS --native "${SCRIPTS}/buildsystems/meson/none.txt") |
| 53 | + vcpkg_list(APPEND arg_OPTIONS_DEBUG --cross "${meson_input_file_DEBUG}") |
| 54 | + vcpkg_list(APPEND arg_OPTIONS_RELEASE --cross "${meson_input_file_RELEASE}") |
| 55 | + else() |
| 56 | + vcpkg_list(APPEND arg_OPTIONS_DEBUG --native "${meson_input_file_DEBUG}") |
| 57 | + vcpkg_list(APPEND arg_OPTIONS_RELEASE --native "${meson_input_file_RELEASE}") |
| 58 | + endif() |
| 59 | + |
| 60 | + # User provided cross/native files |
| 61 | + if(VCPKG_MESON_NATIVE_FILE) |
| 62 | + vcpkg_list(APPEND arg_OPTIONS_RELEASE --native "${VCPKG_MESON_NATIVE_FILE}") |
| 63 | + endif() |
| 64 | + if(VCPKG_MESON_NATIVE_FILE_RELEASE) |
| 65 | + vcpkg_list(APPEND arg_OPTIONS_RELEASE --native "${VCPKG_MESON_NATIVE_FILE_RELEASE}") |
| 66 | + endif() |
| 67 | + if(VCPKG_MESON_NATIVE_FILE_DEBUG) |
| 68 | + vcpkg_list(APPEND arg_OPTIONS_DEBUG --native "${VCPKG_MESON_NATIVE_FILE_DEBUG}") |
| 69 | + endif() |
| 70 | + if(VCPKG_MESON_CROSS_FILE) |
| 71 | + vcpkg_list(APPEND arg_OPTIONS_RELEASE --cross "${VCPKG_MESON_CROSS_FILE}") |
| 72 | + endif() |
| 73 | + if(VCPKG_MESON_CROSS_FILE_RELEASE) |
| 74 | + vcpkg_list(APPEND arg_OPTIONS_RELEASE --cross "${VCPKG_MESON_CROSS_FILE_RELEASE}") |
| 75 | + endif() |
| 76 | + if(VCPKG_MESON_CROSS_FILE_DEBUG) |
| 77 | + vcpkg_list(APPEND arg_OPTIONS_DEBUG --cross "${VCPKG_MESON_CROSS_FILE_DEBUG}") |
| 78 | + endif() |
| 79 | + |
| 80 | + if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") |
| 81 | + set(MESON_DEFAULT_LIBRARY shared) |
| 82 | + else() |
| 83 | + set(MESON_DEFAULT_LIBRARY static) |
| 84 | + endif() |
| 85 | + |
| 86 | + vcpkg_list(APPEND arg_OPTIONS --libdir lib) # else meson install into an architecture describing folder |
| 87 | + vcpkg_list(APPEND arg_OPTIONS_DEBUG -Ddebug=true --prefix "${CURRENT_PACKAGES_DIR}/debug" --includedir ../include) |
| 88 | + vcpkg_list(APPEND arg_OPTIONS_RELEASE -Ddebug=false --prefix "${CURRENT_PACKAGES_DIR}") |
| 89 | + |
| 90 | + # select meson cmd-line options |
| 91 | + if(VCPKG_TARGET_IS_WINDOWS) |
| 92 | + vcpkg_list(APPEND arg_OPTIONS_DEBUG "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}/debug','${CURRENT_INSTALLED_DIR}/share']") |
| 93 | + vcpkg_list(APPEND arg_OPTIONS_RELEASE "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}','${CURRENT_INSTALLED_DIR}/share']") |
| 94 | + else() |
| 95 | + vcpkg_list(APPEND arg_OPTIONS_DEBUG "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}/debug','${CURRENT_INSTALLED_DIR}']") |
| 96 | + vcpkg_list(APPEND arg_OPTIONS_RELEASE "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}']") |
| 97 | + endif() |
| 98 | + |
| 99 | + # Allow overrides / additional configuration variables from triplets |
| 100 | + if(DEFINED VCPKG_MESON_CONFIGURE_OPTIONS) |
| 101 | + vcpkg_list(APPEND arg_OPTIONS ${VCPKG_MESON_CONFIGURE_OPTIONS}) |
| 102 | + endif() |
| 103 | + if(DEFINED VCPKG_MESON_CONFIGURE_OPTIONS_RELEASE) |
| 104 | + vcpkg_list(APPEND arg_OPTIONS_RELEASE ${VCPKG_MESON_CONFIGURE_OPTIONS_RELEASE}) |
| 105 | + endif() |
| 106 | + if(DEFINED VCPKG_MESON_CONFIGURE_OPTIONS_DEBUG) |
| 107 | + vcpkg_list(APPEND arg_OPTIONS_DEBUG ${VCPKG_MESON_CONFIGURE_OPTIONS_DEBUG}) |
| 108 | + endif() |
| 109 | + |
| 110 | + # configure build |
| 111 | + foreach(buildtype IN LISTS buildtypes) |
| 112 | + message(STATUS "Configuring ${TARGET_TRIPLET}-${suffix_${buildtype}}") |
| 113 | + file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${suffix_${buildtype}}") |
| 114 | + #setting up PKGCONFIG |
| 115 | + if(NOT arg_NO_PKG_CONFIG) |
| 116 | + z_vcpkg_setup_pkgconfig_path(CONFIG "${buildtype}") |
| 117 | + endif() |
| 118 | + |
| 119 | + z_vcpkg_meson_setup_variables(${buildtype}) |
| 120 | + configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../vcpkg-tool-meson/meson.template.in" "${meson_input_file_${buildtype}}" @ONLY) |
| 121 | + |
| 122 | + message(STATUS "Configuring ${TARGET_TRIPLET}-${suffix_${buildtype}} done") |
| 123 | + |
| 124 | + if(NOT arg_NO_PKG_CONFIG) |
| 125 | + z_vcpkg_restore_pkgconfig_path() |
| 126 | + endif() |
| 127 | + endforeach() |
| 128 | + |
| 129 | + set("${arg_OUTPUT}" ${arg_OPTIONS} ${arg_OPTIONS_RELEASE} PARENT_SCOPE) |
| 130 | +endfunction() |
0 commit comments