2017-02-10 01:13:52 +08:00
|
|
|
function(vcpkg_install_meson)
|
2021-11-09 04:27:18 +08:00
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 arg "ADD_BIN_TO_PATH" "" "")
|
|
|
|
|
2017-02-10 01:13:52 +08:00
|
|
|
vcpkg_find_acquire_program(NINJA)
|
2017-02-10 01:15:57 +08:00
|
|
|
unset(ENV{DESTDIR}) # installation directory was already specified with '--prefix' option
|
|
|
|
|
2020-11-19 05:36:20 +08:00
|
|
|
if(VCPKG_TARGET_IS_OSX)
|
2021-11-09 04:27:18 +08:00
|
|
|
vcpkg_backup_env_variables(VARS SDKROOT MACOSX_DEPLOYMENT_TARGET)
|
2020-11-19 05:36:20 +08:00
|
|
|
set(ENV{SDKROOT} "${VCPKG_DETECTED_CMAKE_OSX_SYSROOT}")
|
|
|
|
set(ENV{MACOSX_DEPLOYMENT_TARGET} "${VCPKG_DETECTED_CMAKE_OSX_DEPLOYMENT_TARGET}")
|
|
|
|
endif()
|
|
|
|
|
2021-11-09 04:27:18 +08:00
|
|
|
foreach(buildtype IN ITEMS "debug" "release")
|
|
|
|
if(DEFINED VCPKG_BUILD_TYPE AND NOT VCPKG_BUILD_TYPE STREQUAL buildtype)
|
2021-04-01 02:54:44 +08:00
|
|
|
continue()
|
|
|
|
endif()
|
2021-02-02 11:27:34 +08:00
|
|
|
|
2021-11-09 04:27:18 +08:00
|
|
|
if(buildtype STREQUAL "debug")
|
|
|
|
set(short_buildtype "dbg")
|
2021-04-01 02:54:44 +08:00
|
|
|
else()
|
2021-11-09 04:27:18 +08:00
|
|
|
set(short_buildtype "rel")
|
2021-04-01 02:54:44 +08:00
|
|
|
endif()
|
|
|
|
|
2021-11-09 04:27:18 +08:00
|
|
|
message(STATUS "Package ${TARGET_TRIPLET}-${short_buildtype}")
|
|
|
|
if(arg_ADD_BIN_TO_PATH)
|
|
|
|
vcpkg_backup_env_variables(VARS PATH)
|
|
|
|
if(buildtype STREQUAL "debug")
|
2021-04-01 02:54:44 +08:00
|
|
|
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/debug/bin")
|
|
|
|
else()
|
|
|
|
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/bin")
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-02-02 11:27:34 +08:00
|
|
|
vcpkg_execute_required_process(
|
2021-11-09 04:27:18 +08:00
|
|
|
COMMAND "${NINJA}" install -v
|
|
|
|
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_buildtype}"
|
|
|
|
LOGNAME package-${TARGET_TRIPLET}-${short_buildtype}
|
2021-02-02 11:27:34 +08:00
|
|
|
)
|
2021-11-09 04:27:18 +08:00
|
|
|
if(arg_ADD_BIN_TO_PATH)
|
|
|
|
vcpkg_restore_env_variables(VARS PATH)
|
2021-04-01 02:54:44 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2020-11-19 05:36:20 +08:00
|
|
|
|
2021-11-09 04:27:18 +08:00
|
|
|
vcpkg_list(SET renamed_libs)
|
2021-09-14 11:22:04 +08:00
|
|
|
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL static AND NOT VCPKG_TARGET_IS_MINGW)
|
2020-11-19 05:36:20 +08:00
|
|
|
# Meson names all static libraries lib<name>.a which basically breaks the world
|
2021-11-09 04:27:18 +08:00
|
|
|
file(GLOB_RECURSE gen_libraries "${CURRENT_PACKAGES_DIR}*/**/lib*.a")
|
|
|
|
foreach(gen_library IN LISTS gen_libraries)
|
|
|
|
get_filename_component(libdir "${gen_library}" DIRECTORY)
|
|
|
|
get_filename_component(libname "${gen_library}" NAME)
|
|
|
|
string(REGEX REPLACE ".a$" ".lib" fixed_librawname "${libname}")
|
|
|
|
string(REGEX REPLACE "^lib" "" fixed_librawname "${fixed_librawname}")
|
|
|
|
file(RENAME "${gen_library}" "${libdir}/${fixed_librawname}")
|
2021-02-02 11:27:34 +08:00
|
|
|
# For cmake fixes.
|
2021-11-09 04:27:18 +08:00
|
|
|
string(REGEX REPLACE ".a$" "" origin_librawname "${libname}")
|
|
|
|
string(REGEX REPLACE ".lib$" "" fixed_librawname "${fixed_librawname}")
|
|
|
|
vcpkg_list(APPEND renamed_libs ${fixed_librawname})
|
|
|
|
set(${librawname}_old ${origin_librawname})
|
|
|
|
set(${librawname}_new ${fixed_librawname})
|
2020-11-19 05:36:20 +08:00
|
|
|
endforeach()
|
2021-11-09 04:27:18 +08:00
|
|
|
file(GLOB_RECURSE cmake_files "${CURRENT_PACKAGES_DIR}*/*.cmake")
|
|
|
|
foreach(cmake_file IN LISTS cmake_files)
|
|
|
|
foreach(current_lib IN LISTS renamed_libs)
|
2024-06-20 05:07:05 +08:00
|
|
|
vcpkg_replace_string("${cmake_file}" "${${current_lib}_old}" "${${current_lib}_new}" IGNORE_UNCHANGED)
|
2020-11-19 05:36:20 +08:00
|
|
|
endforeach()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(VCPKG_TARGET_IS_OSX)
|
2021-11-09 04:27:18 +08:00
|
|
|
vcpkg_restore_env_variables(VARS SDKROOT MACOSX_DEPLOYMENT_TARGET)
|
2020-11-19 05:36:20 +08:00
|
|
|
endif()
|
2017-02-10 01:13:52 +08:00
|
|
|
endfunction()
|