mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-29 20:23:41 +08:00
3217e25596
* Update meson to a recent commit to fix a bug with 0.56 * rename static libraries built by meson by default on windows * apply cmake variables detection to meson. use native/cross files make arm builds work. * update munit * fix fribidi * fix _FLAGS variables * set env SDKROOT and MACOSX_DEPLOYMENT_TARGET in configure_meson * need osx env while building and configuring * - remove unused env backup functions - rename internal functions to be prefixed with _vcpkg_ - fix VCPKG_CHAINLOAD_TOOLCHAIN_FILE for ios/freebsd * replace _vcpkg with vcpkg since _ has special meaning in functions * rename functions to vcpkg_internal_meson_generate * update control tool-meson
129 lines
5.4 KiB
CMake
129 lines
5.4 KiB
CMake
cmake_minimum_required(VERSION 3.17)
|
|
|
|
set(VCPKG_LANGUAGES "C;CXX" CACHE STRING "Languages to enables for this project")
|
|
|
|
set(OUTPUT_STRING)
|
|
# Build default checklists
|
|
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_CROSSCOMPILING
|
|
CMAKE_SYSTEM_NAME
|
|
CMAKE_HOST_SYSTEM_NAME
|
|
CMAKE_SYSTEM_PROCESSOR
|
|
CMAKE_HOST_SYSTEM_PROCESSOR)
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_OSX_DEPLOYMENT_TARGET
|
|
CMAKE_OSX_SYSROOT)
|
|
endif()
|
|
# Programs to check
|
|
set(PROGLIST AR RANLIB STRIP NM OBJDUMP DLLTOOL MT LINKER)
|
|
foreach(prog IN LISTS PROGLIST)
|
|
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog})
|
|
endforeach()
|
|
set(COMPILERS ${VCPKG_LANGUAGES} RC)
|
|
foreach(prog IN LISTS COMPILERS)
|
|
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog}_COMPILER)
|
|
endforeach()
|
|
# Variables to check
|
|
foreach(_lang IN LISTS VCPKG_LANGUAGES)
|
|
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_STANDARD_INCLUDE_DIRECTORIES)
|
|
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_STANDARD_LIBRARIES)
|
|
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_STANDARD)
|
|
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_COMPILE_FEATURES)
|
|
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_EXTENSION)
|
|
# Probably never required since implicit.
|
|
#list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES)
|
|
#list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_INCLUDE_DIRECTORIES)
|
|
#list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_DIRECTORIES)
|
|
#list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_LIBRARIES)
|
|
endforeach()
|
|
list(REMOVE_DUPLICATES VCPKG_DEFAULT_VARS_TO_CHECK)
|
|
|
|
# Environment variables to check.
|
|
list(APPEND VCPKG_DEFAULT_ENV_VARS_TO_CHECK PATH INCLUDE C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH)
|
|
list(REMOVE_DUPLICATES VCPKG_DEFAULT_ENV_VARS_TO_CHECK)
|
|
|
|
#Flags to check. Flags are a bit special since they are configuration aware.
|
|
set(FLAGS ${VCPKG_LANGUAGES} RC SHARED_LINKER STATIC_LINKER EXE_LINKER)
|
|
foreach(flag IN LISTS FLAGS)
|
|
list(APPEND VCPKG_DEFAULT_FLAGS_TO_CHECK CMAKE_${flag}_FLAGS)
|
|
endforeach()
|
|
list(REMOVE_DUPLICATES VCPKG_DEFAULT_FLAGS_TO_CHECK)
|
|
|
|
# TODO if ever necessary: Properties to check
|
|
|
|
set(VCPKG_VAR_PREFIX "VCPKG_DETECTED" CACHE STRING "Variable prefix to use for detected flags")
|
|
set(VCPKG_VARS_TO_CHECK "${VCPKG_DEFAULT_VARS_TO_CHECK}" CACHE STRING "Variables to check. If not given there is a list of defaults")
|
|
set(VCPKG_FLAGS_TO_CHECK "${VCPKG_DEFAULT_FLAGS_TO_CHECK}" CACHE STRING "Variables to check. If not given there is a list of defaults")
|
|
set(VCPKG_ENV_VARS_TO_CHECK "${VCPKG_DEFAULT_ENV_VARS_TO_CHECK}" CACHE STRING "Variables to check. If not given there is a list of defaults")
|
|
|
|
if(NOT VCPKG_OUTPUT_FILE)
|
|
message(FATAL_ERROR "VCPKG_OUTPUT_FILE is required to be defined")
|
|
endif()
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
message(FATAL_ERROR "CMAKE_BUILD_TYPE is required to be defined")
|
|
else()
|
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" VCPKG_CONFIGS)
|
|
endif()
|
|
|
|
|
|
project(get_cmake_vars LANGUAGES ${VCPKG_LANGUAGES})
|
|
|
|
foreach(VAR IN LISTS VCPKG_VARS_TO_CHECK)
|
|
string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${VAR} \"${${VAR}}\")\n")
|
|
endforeach()
|
|
|
|
foreach(_env IN LISTS VCPKG_ENV_VARS_TO_CHECK)
|
|
IF(WIN32)
|
|
string(REPLACE "\\" "/" ENV_${_env} "$ENV{${_env}}")
|
|
string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_ENV_${_env} \"${ENV_${_env}}\")\n")
|
|
else()
|
|
string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_ENV_${_env} \"$ENV{${_env}}\")\n")
|
|
endif()
|
|
endforeach()
|
|
|
|
foreach(flag IN LISTS VCPKG_FLAGS_TO_CHECK)
|
|
string(STRIP "${${flag}}" ${flag}) # Strip leading and trailing whitespaces
|
|
if(MSVC) # Transform MSVC /flags to -flags due to bash scripts intepreting /flag as a path.
|
|
string(REGEX REPLACE "(^| )/" "\\1-" ${flag} "${${flag}}")
|
|
endif()
|
|
string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag} \" ${${flag}}\")\n")
|
|
foreach(config IN LISTS VCPKG_CONFIGS)
|
|
string(STRIP "${${flag}_${config}}" ${flag}_${config})
|
|
if(MSVC)
|
|
string(REGEX REPLACE "(^| )/" "\\1-" ${flag}_${config} "${${flag}_${config}}")
|
|
endif()
|
|
string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag}_${config} \"${CMAKE_${flag}_FLAGS_${config}}\")\n")
|
|
set(COMBINED_${flag}_${config} "${${flag}} ${${flag}_${config}}")
|
|
string(STRIP "${COMBINED_${flag}_${config}}" COMBINED_${flag}_${config})
|
|
string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${flag}_${config} \"${COMBINED_${flag}_${config}}\")\n")
|
|
endforeach()
|
|
endforeach()
|
|
|
|
|
|
file(WRITE "${VCPKG_OUTPUT_FILE}" "${OUTPUT_STRING}")
|
|
|
|
# Programs:
|
|
# CMAKE_AR
|
|
# CMAKE_<LANG>_COMPILER_AR (Wrapper)
|
|
# CMAKE_RANLIB
|
|
# CMAKE_<LANG>_COMPILER_RANLIB
|
|
# CMAKE_STRIP
|
|
# CMAKE_NM
|
|
# CMAKE_OBJDUMP
|
|
# CMAKE_DLLTOOL
|
|
# CMAKE_MT
|
|
# CMAKE_LINKER
|
|
# CMAKE_C_COMPILER
|
|
# CMAKE_CXX_COMPILER
|
|
# CMAKE_RC_COMPILER
|
|
|
|
# Flags:
|
|
# CMAKE_<LANG>_FLAGS
|
|
# CMAKE_<LANG>_FLAGS_<CONFIG>
|
|
# CMAKE_RC_FLAGS
|
|
# CMAKE_SHARED_LINKER_FLAGS
|
|
# CMAKE_STATIC_LINKER_FLAGS
|
|
# CMAKE_STATIC_LINKER_FLAGS_<CONFIG>
|
|
# CMAKE_EXE_LINKER_FLAGS
|
|
# CMAKE_EXE_LINKER_FLAGS_<CONFIG>
|