mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 18:31:15 +08:00
[vcpkg/scripts] Add a way to get cmake compiler settings/flags (#12936)
* add function get_cmake_vars * fine tuning. * apply to make based ports. * add log suffix on not windows platforms * fix c&p error * add previous LINK env * setup env on windows and extract cpp flags correctly. * Apply suggestions from code review * commit changes from fontconfig PR * Apply suggestions from code review Co-authored-by: nicole mazzuca <mazzucan@outlook.com> * cleanup docs * add conversion from somelib.lib to -lsomelib * add missing ar-lib wrapper * small but important regex correction * add latest changes from update_fontconfig PR * Apply suggestions from code review first set which don't need special attention Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com> * Apply suggestions from code review one more simple change Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com> * [x264] set env AS * fix bugs due to refactor * use subpath everywhere * apply changes from CR * remove unnecessary lines 41 & 44 * remove flag transformation * reintroduce the flag / to - transformation for MSVC * Apply suggestions from code review Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com> * rename the function * rename function/variables * transform flags list * Apply suggestions from code review * fix vcpkg_build_make due to the variable name change * fix another case of function renaming regressions * only rename config.log if it exists * actually add the script after vcpkg_common_functions was deleted. * remove setting of ldflags if path contains spaces Co-authored-by: nicole mazzuca <mazzucan@outlook.com> Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com>
This commit is contained in:
parent
202ada4fcf
commit
8de4ee858f
@ -1,6 +1,6 @@
|
|||||||
Source: x264
|
Source: x264
|
||||||
Version: 157-303c484ec828ed0
|
Version: 157-303c484ec828ed0
|
||||||
Port-Version: 12
|
Port-Version: 13
|
||||||
Homepage: https://github.com/mirror/x264
|
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
|
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)
|
Build-Depends: pthread (linux&osx)
|
||||||
|
@ -21,6 +21,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
|
|||||||
_vcpkg_determine_autotools_target_cpu(HOST_ARCH)
|
_vcpkg_determine_autotools_target_cpu(HOST_ARCH)
|
||||||
list(APPEND OPTIONS --build=${BUILD_ARCH}-pc-mingw32)
|
list(APPEND OPTIONS --build=${BUILD_ARCH}-pc-mingw32)
|
||||||
list(APPEND OPTIONS --host=${HOST_ARCH}-pc-mingw32)
|
list(APPEND OPTIONS --host=${HOST_ARCH}-pc-mingw32)
|
||||||
|
set(ENV{AS} "${NASM}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(VCPKG_TARGET_IS_UWP)
|
if(VCPKG_TARGET_IS_UWP)
|
||||||
|
130
scripts/buildsystems/make_wrapper/windres-rc
Normal file
130
scripts/buildsystems/make_wrapper/windres-rc
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# Wrapper for windres to rc which do not understand '-i -o --output-format'.
|
||||||
|
# cvtres is invoked by the linker
|
||||||
|
scriptversion=2020-08-17.03; # UTC
|
||||||
|
|
||||||
|
|
||||||
|
nl='
|
||||||
|
'
|
||||||
|
|
||||||
|
# We need space, tab and new line, in precisely that order. Quoting is
|
||||||
|
# there to prevent tools from complaining about whitespace usage.
|
||||||
|
IFS=" "" $nl"
|
||||||
|
|
||||||
|
file_conv=
|
||||||
|
|
||||||
|
# func_file_conv build_file lazy
|
||||||
|
# Convert a $build file to $host form and store it in $file
|
||||||
|
# Currently only supports Windows hosts. If the determined conversion
|
||||||
|
# type is listed in (the comma separated) LAZY, no conversion will
|
||||||
|
# take place.
|
||||||
|
func_file_conv ()
|
||||||
|
{
|
||||||
|
file=$1
|
||||||
|
case $file in
|
||||||
|
/ | /[!/]*) # absolute file, and not a UNC file
|
||||||
|
if test -z "$file_conv"; then
|
||||||
|
# lazily determine how to convert abs files
|
||||||
|
case `uname -s` in
|
||||||
|
MINGW*)
|
||||||
|
file_conv=mingw
|
||||||
|
;;
|
||||||
|
CYGWIN* | MSYS*)
|
||||||
|
file_conv=cygwin
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
file_conv=wine
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
case $file_conv/,$2, in
|
||||||
|
*,$file_conv,*)
|
||||||
|
;;
|
||||||
|
mingw/*)
|
||||||
|
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||||
|
;;
|
||||||
|
cygwin/* | msys/*)
|
||||||
|
file=`cygpath -m "$file" || echo "$file"`
|
||||||
|
;;
|
||||||
|
wine/*)
|
||||||
|
file=`winepath -w "$file" || echo "$file"`
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# func_windres_wrapper rc args...
|
||||||
|
# Adjust compile command to suit rc instead of windres
|
||||||
|
func_windres_wrapper ()
|
||||||
|
{
|
||||||
|
echo "FROM WINDRESWRAPPER FUNCTION:$@"
|
||||||
|
echo "RCFLAGS:$(RCFLAGS)"
|
||||||
|
# Assume a capable shell
|
||||||
|
in=
|
||||||
|
out=
|
||||||
|
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
if test -n "$eat"; then
|
||||||
|
eat=
|
||||||
|
else
|
||||||
|
case $1 in
|
||||||
|
-o)
|
||||||
|
eat=1
|
||||||
|
func_file_conv "$2"
|
||||||
|
out="$file"
|
||||||
|
echo "OUTPUT:$file"
|
||||||
|
set x "$@"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*.obj)
|
||||||
|
func_file_conv "$1"
|
||||||
|
out="$file"
|
||||||
|
echo "OUTPUT:$file"
|
||||||
|
set x "$@"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--output-format=*)
|
||||||
|
set x "$@"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-i)
|
||||||
|
eat=1
|
||||||
|
func_file_conv "$2" mingw
|
||||||
|
in="$file"
|
||||||
|
echo "INPUT:$file"
|
||||||
|
set x "$@"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
set x "$@" "${1//\\\"/\"}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
echo "$@" -fo "$out" "$in"
|
||||||
|
exec "$@" -fo "$out" "$in"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
eat=
|
||||||
|
|
||||||
|
func_windres_wrapper "$@"
|
||||||
|
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||||
|
# time-stamp-start: "scriptversion="
|
||||||
|
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||||
|
# time-stamp-time-zone: "UTC0"
|
||||||
|
# time-stamp-end: "; # UTC"
|
||||||
|
# End:
|
@ -27,6 +27,9 @@
|
|||||||
## ### DISABLE_PARALLEL
|
## ### DISABLE_PARALLEL
|
||||||
## The underlying buildsystem will be instructed to not parallelize
|
## The underlying buildsystem will be instructed to not parallelize
|
||||||
##
|
##
|
||||||
|
## ### SUBPATH
|
||||||
|
## Additional subdir to invoke make in. Useful if only parts of a port should be built.
|
||||||
|
##
|
||||||
## ## Notes:
|
## ## Notes:
|
||||||
## This command should be preceeded by a call to [`vcpkg_configure_make()`](vcpkg_configure_make.md).
|
## This command should be preceeded by a call to [`vcpkg_configure_make()`](vcpkg_configure_make.md).
|
||||||
## You can use the alias [`vcpkg_install_make()`](vcpkg_configure_make.md) function if your CMake script supports the
|
## You can use the alias [`vcpkg_install_make()`](vcpkg_configure_make.md) function if your CMake script supports the
|
||||||
@ -39,8 +42,9 @@
|
|||||||
## * [freexl](https://github.com/Microsoft/vcpkg/blob/master/ports/freexl/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)
|
## * [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake)
|
||||||
function(vcpkg_build_make)
|
function(vcpkg_build_make)
|
||||||
|
include("${_VCPKG_CMAKE_VARS_FILE}")
|
||||||
# parse parameters such that semicolons in options arguments to COMMAND don't get erased
|
# parse parameters such that semicolons in options arguments to COMMAND don't get erased
|
||||||
cmake_parse_arguments(PARSE_ARGV 0 _bc "ADD_BIN_TO_PATH;ENABLE_INSTALL;DISABLE_PARALLEL" "LOGFILE_ROOT;BUILD_TARGET" "")
|
cmake_parse_arguments(PARSE_ARGV 0 _bc "ADD_BIN_TO_PATH;ENABLE_INSTALL;DISABLE_PARALLEL" "LOGFILE_ROOT;BUILD_TARGET;SUBPATH" "")
|
||||||
|
|
||||||
if(NOT _bc_LOGFILE_ROOT)
|
if(NOT _bc_LOGFILE_ROOT)
|
||||||
set(_bc_LOGFILE_ROOT "build")
|
set(_bc_LOGFILE_ROOT "build")
|
||||||
@ -109,15 +113,38 @@ function(vcpkg_build_make)
|
|||||||
set(PATH_SUFFIX "")
|
set(PATH_SUFFIX "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}")
|
set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}${_bc_SUBPATH}")
|
||||||
|
|
||||||
message(STATUS "Building ${TARGET_TRIPLET}${SHORT_BUILDTYPE}")
|
message(STATUS "Building ${TARGET_TRIPLET}${SHORT_BUILDTYPE}")
|
||||||
|
|
||||||
|
_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags(${CMAKE_BUILDTYPE})
|
||||||
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
||||||
|
set(LINKER_FLAGS_${CMAKE_BUILDTYPE} "${VCPKG_DETECTED_STATIC_LINKERFLAGS_${CMAKE_BUILDTYPE}}")
|
||||||
|
else() # dynamic
|
||||||
|
set(LINKER_FLAGS_${CMAKE_BUILDTYPE} "${VCPKG_DETECTED_SHARED_LINKERFLAGS_${CMAKE_BUILDTYPE}}")
|
||||||
|
endif()
|
||||||
|
if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_C_COMPILER MATCHES "cl.exe")
|
||||||
|
set(LDFLAGS_${CMAKE_BUILDTYPE} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/manual-link")
|
||||||
|
set(LINK_ENV_${CMAKE_BUILDTYPE} "$ENV{_LINK_} ${LINKER_FLAGS_${CMAKE_BUILDTYPE}}")
|
||||||
|
else()
|
||||||
|
set(LDFLAGS_${CMAKE_BUILDTYPE} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX}/lib/manual-link ${LINKER_FLAGS_${CMAKE_BUILDTYPE}}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Setup environment
|
||||||
|
set(ENV{CPPFLAGS} "${CPPFLAGS_${CMAKE_BUILDTYPE}}")
|
||||||
|
set(ENV{CFLAGS} "${CFLAGS_${CMAKE_BUILDTYPE}}")
|
||||||
|
set(ENV{CXXFLAGS} "${CXXFLAGS_${CMAKE_BUILDTYPE}}")
|
||||||
|
set(ENV{RCFLAGS} "${VCPKG_DETECTED_CMAKE_RC_FLAGS_${CMAKE_BUILDTYPE}}")
|
||||||
|
set(ENV{LDFLAGS} "${LDFLAGS_${CMAKE_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{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{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{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}")
|
#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(LINK_ENV_${_VAR_SUFFIX})
|
||||||
|
set(_LINK_CONFIG_BACKUP "$ENV{_LINK_}")
|
||||||
|
set(ENV{_LINK_} "${LINK_ENV_${_VAR_SUFFIX}}")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(_bc_ADD_BIN_TO_PATH)
|
if(_bc_ADD_BIN_TO_PATH)
|
||||||
set(_BACKUP_ENV_PATH "$ENV{PATH}")
|
set(_BACKUP_ENV_PATH "$ENV{PATH}")
|
||||||
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX}/bin")
|
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX}/bin")
|
||||||
@ -130,6 +157,7 @@ function(vcpkg_build_make)
|
|||||||
set(MAKE_CMD_LINE ${MAKE_COMMAND} ${MAKE_OPTS})
|
set(MAKE_CMD_LINE ${MAKE_COMMAND} ${MAKE_OPTS})
|
||||||
set(NO_PARALLEL_MAKE_CMD_LINE ${MAKE_COMMAND} ${NO_PARALLEL_MAKE_OPTS})
|
set(NO_PARALLEL_MAKE_CMD_LINE ${MAKE_COMMAND} ${NO_PARALLEL_MAKE_OPTS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (_bc_DISABLE_PARALLEL)
|
if (_bc_DISABLE_PARALLEL)
|
||||||
vcpkg_execute_build_process(
|
vcpkg_execute_build_process(
|
||||||
COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE}
|
COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE}
|
||||||
@ -137,12 +165,31 @@ function(vcpkg_build_make)
|
|||||||
LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}"
|
LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}"
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
vcpkg_execute_build_process(
|
vcpkg_execute_build_process(
|
||||||
|
COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE}
|
||||||
|
NO_PARALLEL_COMMAND ${MAKE_BASH} ${NO_PARALLEL_MAKE_CMD_LINE}
|
||||||
|
WORKING_DIRECTORY "${WORKING_DIRECTORY}"
|
||||||
|
LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (_bc_ENABLE_INSTALL)
|
||||||
|
message(STATUS "Installing ${TARGET_TRIPLET}${SHORT_BUILDTYPE}")
|
||||||
|
if(MAKE_BASH)
|
||||||
|
set(MAKE_CMD_LINE "${MAKE_COMMAND} ${INSTALL_OPTS}")
|
||||||
|
else()
|
||||||
|
set(MAKE_CMD_LINE ${MAKE_COMMAND} ${INSTALL_OPTS})
|
||||||
|
endif()
|
||||||
|
vcpkg_execute_build_process(
|
||||||
COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE}
|
COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE}
|
||||||
NO_PARALLEL_COMMAND ${MAKE_BASH} ${NO_PARALLEL_MAKE_CMD_LINE}
|
|
||||||
WORKING_DIRECTORY "${WORKING_DIRECTORY}"
|
WORKING_DIRECTORY "${WORKING_DIRECTORY}"
|
||||||
LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}"
|
LOGNAME "install-${TARGET_TRIPLET}${SHORT_BUILDTYPE}"
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(_LINK_CONFIG_BACKUP)
|
||||||
|
set(ENV{_LINK_} "${_LINK_CONFIG_BACKUP}")
|
||||||
|
unset(_LINK_CONFIG_BACKUP)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(_bc_ADD_BIN_TO_PATH)
|
if(_bc_ADD_BIN_TO_PATH)
|
||||||
@ -152,40 +199,6 @@ function(vcpkg_build_make)
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if (_bc_ENABLE_INSTALL)
|
if (_bc_ENABLE_INSTALL)
|
||||||
foreach(BUILDTYPE "debug" "release")
|
|
||||||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL BUILDTYPE)
|
|
||||||
if(BUILDTYPE STREQUAL "debug")
|
|
||||||
# Skip debug generate
|
|
||||||
if (_VCPKG_NO_DEBUG)
|
|
||||||
continue()
|
|
||||||
endif()
|
|
||||||
set(SHORT_BUILDTYPE "-dbg")
|
|
||||||
else()
|
|
||||||
# In NO_DEBUG mode, we only use ${TARGET_TRIPLET} directory.
|
|
||||||
if (_VCPKG_NO_DEBUG)
|
|
||||||
set(SHORT_BUILDTYPE "")
|
|
||||||
else()
|
|
||||||
set(SHORT_BUILDTYPE "-rel")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
message(STATUS "Installing ${TARGET_TRIPLET}${SHORT_BUILDTYPE}")
|
|
||||||
|
|
||||||
if(MAKE_BASH)
|
|
||||||
set(MAKE_CMD_LINE "${MAKE_COMMAND} ${INSTALL_OPTS}")
|
|
||||||
else()
|
|
||||||
set(MAKE_CMD_LINE ${MAKE_COMMAND} ${INSTALL_OPTS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}")
|
|
||||||
vcpkg_execute_build_process(
|
|
||||||
COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE}
|
|
||||||
WORKING_DIRECTORY "${WORKING_DIRECTORY}"
|
|
||||||
LOGNAME "install-${TARGET_TRIPLET}${SHORT_BUILDTYPE}"
|
|
||||||
)
|
|
||||||
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_INSTALL_PREFIX "${CURRENT_INSTALLED_DIR}")
|
string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_INSTALL_PREFIX "${CURRENT_INSTALLED_DIR}")
|
||||||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}_tmp")
|
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}_tmp")
|
||||||
file(RENAME "${CURRENT_PACKAGES_DIR}" "${CURRENT_PACKAGES_DIR}_tmp")
|
file(RENAME "${CURRENT_PACKAGES_DIR}" "${CURRENT_PACKAGES_DIR}_tmp")
|
||||||
|
File diff suppressed because it is too large
Load Diff
58
scripts/cmake/vcpkg_internal_get_cmake_vars.cmake
Normal file
58
scripts/cmake/vcpkg_internal_get_cmake_vars.cmake
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
## # vcpkg_internal_get_cmake_vars
|
||||||
|
##
|
||||||
|
## **Only for internal use in vcpkg helpers. Behavior and arguments will change without notice.**
|
||||||
|
## Runs a cmake configure with a dummy project to extract certain cmake variables
|
||||||
|
##
|
||||||
|
## ## Usage
|
||||||
|
## ```cmake
|
||||||
|
## vcpkg_internal_get_cmake_vars(
|
||||||
|
## [OUTPUT_FILE <output_file_with_vars>]
|
||||||
|
## [OPTIONS <-DUSE_THIS_IN_ALL_BUILDS=1>...]
|
||||||
|
## )
|
||||||
|
## ```
|
||||||
|
##
|
||||||
|
## ## Parameters
|
||||||
|
## ### OPTIONS
|
||||||
|
## Additional options to pass to the test configure call
|
||||||
|
##
|
||||||
|
## ### OUTPUT_FILE
|
||||||
|
## Variable to return the path to the generated cmake file with the detected `CMAKE_` variables set as `VCKPG_DETECTED_`
|
||||||
|
##
|
||||||
|
## ## Notes
|
||||||
|
## If possible avoid usage in portfiles.
|
||||||
|
##
|
||||||
|
## ## Examples
|
||||||
|
##
|
||||||
|
## * [vcpkg_configure_make](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_configure_make.cmake)
|
||||||
|
|
||||||
|
function(vcpkg_internal_get_cmake_vars)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 0 _gcv "" "OUTPUT_FILE" "OPTIONS")
|
||||||
|
|
||||||
|
if(_gcv_UNPARSED_ARGUMENTS)
|
||||||
|
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed unparsed arguments: '${_gcv_UNPARSED_ARGUMENTS}'")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT _gcv_OUTPUT_FILE)
|
||||||
|
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} requires parameter OUTPUT_FILE!")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(${_gcv_OUTPUT_FILE})
|
||||||
|
debug_message("OUTPUT_FILE ${${_gcv_OUTPUT_FILE}}")
|
||||||
|
else()
|
||||||
|
set(DEFAULT_OUT "${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}.cmake.log") # So that the file gets included in CI artifacts.
|
||||||
|
set(${_gcv_OUTPUT_FILE} "${DEFAULT_OUT}" PARENT_SCOPE)
|
||||||
|
set(${_gcv_OUTPUT_FILE} "${DEFAULT_OUT}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
vcpkg_configure_cmake(
|
||||||
|
SOURCE_PATH "${SCRIPTS}/get_cmake_vars"
|
||||||
|
OPTIONS ${_gcv_OPTIONS} "-DVCPKG_BUILD_TYPE=${VCPKG_BUILD_TYPE}"
|
||||||
|
OPTIONS_DEBUG "-DVCPKG_OUTPUT_FILE:PATH=${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}-dbg.cmake.log"
|
||||||
|
OPTIONS_RELEASE "-DVCPKG_OUTPUT_FILE:PATH=${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}-rel.cmake.log"
|
||||||
|
PREFER_NINJA
|
||||||
|
LOGNAME get-cmake-vars-${TARGET_TRIPLET}
|
||||||
|
)
|
||||||
|
|
||||||
|
file(WRITE "${${_gcv_OUTPUT_FILE}}" "include(\"${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}-dbg.cmake.log\")\ninclude(\"${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}-rel.cmake.log\")")
|
||||||
|
|
||||||
|
endfunction()
|
124
scripts/get_cmake_vars/CMakeLists.txt
Normal file
124
scripts/get_cmake_vars/CMakeLists.txt
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
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)
|
||||||
|
# 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>
|
@ -129,6 +129,7 @@ if(CMD MATCHES "^BUILD$")
|
|||||||
include(vcpkg_install_msbuild)
|
include(vcpkg_install_msbuild)
|
||||||
include(vcpkg_install_nmake)
|
include(vcpkg_install_nmake)
|
||||||
include(vcpkg_install_qmake)
|
include(vcpkg_install_qmake)
|
||||||
|
include(vcpkg_internal_get_cmake_vars)
|
||||||
include(vcpkg_prettify_command)
|
include(vcpkg_prettify_command)
|
||||||
include(vcpkg_replace_string)
|
include(vcpkg_replace_string)
|
||||||
include(vcpkg_test_cmake)
|
include(vcpkg_test_cmake)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user