From 067387050c5a1fd20d964142fd4861230e442cb6 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 16 Aug 2020 12:16:03 +0200 Subject: [PATCH 01/34] add function get_cmake_vars --- scripts/cmake/vcpkg_common_functions.cmake | 1 + scripts/cmake/vcpkg_get_cmake_vars.cmake | 56 ++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 scripts/cmake/vcpkg_get_cmake_vars.cmake diff --git a/scripts/cmake/vcpkg_common_functions.cmake b/scripts/cmake/vcpkg_common_functions.cmake index 2fad7f0ed9632a..4dfd709bcbdb5f 100644 --- a/scripts/cmake/vcpkg_common_functions.cmake +++ b/scripts/cmake/vcpkg_common_functions.cmake @@ -42,6 +42,7 @@ include(vcpkg_apply_patches) include(vcpkg_copy_pdbs) include(vcpkg_copy_tool_dependencies) include(vcpkg_copy_tools) +include(vcpkg_get_cmake_vars) include(vcpkg_get_program_files_platform_bitness) include(vcpkg_get_windows_sdk) include(vcpkg_replace_string) diff --git a/scripts/cmake/vcpkg_get_cmake_vars.cmake b/scripts/cmake/vcpkg_get_cmake_vars.cmake new file mode 100644 index 00000000000000..a48edd65e55bbe --- /dev/null +++ b/scripts/cmake/vcpkg_get_cmake_vars.cmake @@ -0,0 +1,56 @@ +## # vcpkg_get_cmake_vars +## +## Runs a cmake configure with a dummy project to extract certain cmake variables +## This function is mostliy +## +## ## Usage +## ```cmake +## vcpkg_get_cmake_vars( +## [OUTPUT_FILE ] +## [OPTIONS <-DUSE_THIS_IN_ALL_BUILDS=1>...] +## ) +## ``` +## +## ## Parameters +## ### OPTIONS +## Additional options to pass to the test configure call +## +## ### OUTPUT_FILE +## Variable to hold the +## +## ## Notes +## This command will either alter the settings for `VCPKG_LIBRARY_LINKAGE` or fail, depending on what was requested by the user versus what the library supports. +## +## ## Examples +## +## * [libimobiledevice](https://github.com/Microsoft/vcpkg/blob/master/ports/libimobiledevice/portfile.cmake) + +function(vcpkg_get_cmake_vars) + cmake_parse_arguments(PARSE_ARGV 0 _gcv "OUTPUT_VAR" "OPTIONS" ${ARGN}) + + if(_gcv_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "vcpkg_get_cmake_vars was passed unparsed arguments: '${_gcv_UNPARSED_ARGUMENTS}'") + endif() + + if(NOT _gcv_OUTPUT_VAR) + message(FATAL_ERROR "vcpkg_get_cmake_vars requires parameter OUTPUT_VAR!") + endif() + + if(${_gcv_OUTPUT_VAR}) + list(APPEND "-DVCPKG_OUTPUT_FILE=${${_gcv_OUTPUT_VAR}}") + else() + set(DEFAULT_OUT "${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}.cmake.log") # So that the file gets included in CI artifacts. + list(APPEND "-DVCPKG_OUTPUT_FILE=${CURRENT_BUILDTREES_DIR}/${DEFAULT_OUT}") + set(${_gcv_OUTPUT_VAR} ${DEFAULT_OUT} PARENT_SCOPE) + endif() + + set(VCPKG_BUILD_TYPE release) + vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_PORT_DIR} + OPTIONS ${_gcv_OPTIONS} + PREFER_NINJA + ) + + file(RENAME "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-get-cmake-vars") + file(RENAME "${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}-rel.log" "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}.log") +endfunction() \ No newline at end of file From b5f28f723714d1d2f951fffbdc1d1be44a71cbb1 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 16 Aug 2020 14:41:27 +0200 Subject: [PATCH 02/34] fine tuning. --- scripts/cmake/vcpkg_get_cmake_vars.cmake | 23 ++-- scripts/get_cmake_vars/CMakeLists.txt | 137 +++++++++++++++++++++++ 2 files changed, 151 insertions(+), 9 deletions(-) create mode 100644 scripts/get_cmake_vars/CMakeLists.txt diff --git a/scripts/cmake/vcpkg_get_cmake_vars.cmake b/scripts/cmake/vcpkg_get_cmake_vars.cmake index a48edd65e55bbe..ed4051c57a0cf9 100644 --- a/scripts/cmake/vcpkg_get_cmake_vars.cmake +++ b/scripts/cmake/vcpkg_get_cmake_vars.cmake @@ -26,31 +26,36 @@ ## * [libimobiledevice](https://github.com/Microsoft/vcpkg/blob/master/ports/libimobiledevice/portfile.cmake) function(vcpkg_get_cmake_vars) - cmake_parse_arguments(PARSE_ARGV 0 _gcv "OUTPUT_VAR" "OPTIONS" ${ARGN}) + cmake_parse_arguments(PARSE_ARGV 0 _gcv "" "OUTPUT_FILE" "OPTIONS") if(_gcv_UNPARSED_ARGUMENTS) message(FATAL_ERROR "vcpkg_get_cmake_vars was passed unparsed arguments: '${_gcv_UNPARSED_ARGUMENTS}'") endif() - if(NOT _gcv_OUTPUT_VAR) - message(FATAL_ERROR "vcpkg_get_cmake_vars requires parameter OUTPUT_VAR!") + if(NOT _gcv_OUTPUT_FILE) + message(FATAL_ERROR "vcpkg_get_cmake_vars requires parameter OUTPUT_FILE!") endif() - if(${_gcv_OUTPUT_VAR}) - list(APPEND "-DVCPKG_OUTPUT_FILE=${${_gcv_OUTPUT_VAR}}") + if(${_gcv_OUTPUT_FILE}) + debug_message("OUTPUT_FILE ${${_gcv_OUTPUT_FILE}}") + list(APPEND _gcv_OPTIONS "-DVCPKG_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. - list(APPEND "-DVCPKG_OUTPUT_FILE=${CURRENT_BUILDTREES_DIR}/${DEFAULT_OUT}") - set(${_gcv_OUTPUT_VAR} ${DEFAULT_OUT} PARENT_SCOPE) + list(APPEND _gcv_OPTIONS "-DVCPKG_OUTPUT_FILE:PATH=${DEFAULT_OUT}") + set(${_gcv_OUTPUT_FILE} "${DEFAULT_OUT}" PARENT_SCOPE) endif() set(VCPKG_BUILD_TYPE release) vcpkg_configure_cmake( - SOURCE_PATH ${CURRENT_PORT_DIR} + SOURCE_PATH "${SCRIPTS}/get_cmake_vars" OPTIONS ${_gcv_OPTIONS} PREFER_NINJA ) + file(REMOVE "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}-out.log") + file(REMOVE "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}-err.log") + file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-get-cmake-vars") file(RENAME "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-get-cmake-vars") - file(RENAME "${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}-rel.log" "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}.log") + file(RENAME "${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}-out.log" "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}-out.log") + file(RENAME "${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}-err.log" "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}-err.log") endfunction() \ No newline at end of file diff --git a/scripts/get_cmake_vars/CMakeLists.txt b/scripts/get_cmake_vars/CMakeLists.txt new file mode 100644 index 00000000000000..f26137ce9ecd14 --- /dev/null +++ b/scripts/get_cmake_vars/CMakeLists.txt @@ -0,0 +1,137 @@ +cmake_minimum_required(VERSION 3.17) + +set(VCPKG_LANGUAGES "C;CXX" CACHE STRING "LANGUAGES TO ENABLE FOR THIS PROJECT") +set(VCPKG_VAR_PREFIX "VCPKG_DETECTED" CACHE STRING "Variable prefix to use for detected flags") +set(VCPKG_CONFIGS "DEBUG;RELEASE" CACHE STRING "Configurations to detect flags for") +set(VCPKG_OUTPUT_FILE "${CMAKE_BINARY_DIR}/../detected_flags.cmake.${VCPKG_TARGET_TRIPLET}.log" CACHE STRING "Output CMake files") +set(VCPKG_ADDITIONAL_OUTPUT_VARS "" CACHE STRING "Additional variables to output.") + +set(OUTPUT_STRING) +project(get_cmake_vars LANGUAGES ${VCPKG_LANGUAGES}) + +if(MSVC) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_MSVC TRUE)\n") +endif() +string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_CROSSCOMPILING ${CMAKE_CROSSCOMPILING})\n") +string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_SYSEM_NAME \"${CMAKE_SYSTEM_NAME}\")\n") +string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_SYSTEM_PROCESSOR \"${CMAKE_SYSTEM_PROCESSOR}\")\n") +# other: +# CMAKE_C_STANDARD +# CMAKE_CXX_STANDARD + +set(PROGLIST AR RANLIB STRIP NM OBJDUMP DLLTOOL MT LINKER) +foreach(prog IN LISTS PROGLIST) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${prog} \"${CMAKE_${prog}}\")\n") +endforeach() + +set(COMPILERS ${VCPKG_LANGUAGES} RC) +foreach(prog IN LISTS COMPILERS) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${prog}_COMPILER \"${CMAKE_${prog}_COMPILER}\")\n") +endforeach() + +set(FLAGS ${VCPKG_LANGUAGES} RC SHARED_LINKER STATIC_LINKER EXE_LINKER) +foreach(flag IN LISTS FLAGS) + string(REGEX REPLACE " +" " " CMAKE_${flag}_FLAGS "${CMAKE_${flag}_FLAGS}") + string(REGEX REPLACE "( |^)/" "\\1-" CMAKE_${flag}_FLAGS "${CMAKE_${flag}_FLAGS}") + string(STRIP "${CMAKE_${flag}_FLAGS}" CMAKE_${flag}_FLAGS) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${flag}FLAGS \" ${CMAKE_${flag}_FLAGS}\")\n") + foreach(config IN LISTS VCPKG_CONFIGS) + string(REGEX REPLACE " +" " " CMAKE_${flag}_FLAGS_${config} "${CMAKE_${flag}_FLAGS_${config}}") + string(REGEX REPLACE "( |^)/" "\\1-" CMAKE_${flag}_FLAGS_${config} "${CMAKE_${flag}_FLAGS_${config}}") + string(STRIP "${CMAKE_${flag}_FLAGS_${config}}" CMAKE_${flag}_FLAGS_${config}) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${flag}FLAGS_${config} \"${CMAKE_${flag}_FLAGS_${config}}\")\n") + set(COMBINED_${flag}_${config}_FLAGS "${CMAKE_${flag}_FLAGS} ${CMAKE_${flag}_FLAGS_${config}}") + string(REGEX REPLACE " +" " " COMBINED_${flag}_${config}_FLAGS "${COMBINED_${flag}_${config}_FLAGS}") + string(STRIP "${COMBINED_${flag}_${config}_FLAGS}" COMBINED_${flag}_${config}_FLAGS) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_COMBINED_${flag}FLAGS_${config} \"${COMBINED_${flag}_${config}_FLAGS}\")\n") + endforeach() +endforeach() + +set(additional_vars) +foreach(_lang IN LISTS VCPKG_LANGUAGES) + list(APPEND additional_vars CMAKE_${_lang}_STANDARD_INCLUDE_DIRECTORIES) + list(APPEND additional_vars CMAKE_${_lang}_STANDARD_LIBRARIES) + # Probably not required. + #list(APPEND additional_vars CMAKE_${_lang}_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES) + #list(APPEND additional_vars CMAKE_${_lang}_IMPLICIT_INCLUDE_DIRECTORIES) + #list(APPEND additional_vars CMAKE_${_lang}_IMPLICIT_LINK_DIRECTORIES) + #list(APPEND additional_vars CMAKE_${_lang}_IMPLICIT_LINK_LIBRARIES) +endforeach() +# list(APPEND additional_vars CMAKE_LINK_INTERFACE_LIBRARIES) #deprecated + +foreach(_var IN LISTS additional_vars) + string(REPLACE "CMAKE_" "" outvar "${_var}") + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${outvar} \"${${_var}}\")\n") +endforeach() + +# These seem to be empty. +# set(add_props INCLUDE_DIRECTORIES COMPILE_DEFINITIONS COMPILE_OPTIONS LINK_DIRECTORIES LINK_OPTIONS) +# foreach(prop IN LISTS add_props) + # get_directory_property(${prop} ${prop}) + # string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${prop} ${${prop}})\n") + # foreach(config IN LISTS VCPKG_CONFIGS) + # get_directory_property(${prop}_${config} ${prop}_${config}) + # string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${prop}_${config} ${${prop}_${config}})\n") + # endforeach() +# endforeach() +set(ENV_VARIABLES PATH INCLUDE C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH ) +foreach(_env IN LISTS ENV_VARIABLES) + 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(addvar IN LISTS VCPKG_ADDITIONAL_OUTPUT_VARS) + string(REPLACE "CMAKE_" outvar "${addvar}") + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${outvar} \"${${addvar}}\")\n") +endforeach() + +file(WRITE "${VCPKG_OUTPUT_FILE}" "${OUTPUT_STRING}") + +# Not useful? +# CMAKE__STANDARD_INCLUDE_DIRECTORIES +# CMAKE__STANDARD_LIBRARIES + +# CMAKE__IMPLICIT_LINK_FRAMEWORK_DIRECTORIES +# CMAKE__IMPLICIT_INCLUDE_DIRECTORIES +# CMAKE__IMPLICIT_LINK_DIRECTORIES +# CMAKE__IMPLICIT_LINK_LIBRARIES + +# CMAKE_LINK_INTERFACE_LIBRARIES -> LIBS + +# Dir properties: +# COMPILE_DEFINITIONS(_CONFIG) +# COMPILE_OPTIONS(_CONFIG) +# INCLUDE_DIRECTORIES +# LINK_DIRECTORIES +# LINK_OPTIONS + +# Programs: +# CMAKE_AR +# CMAKE__COMPILER_AR (Wrapper) +# CMAKE_RANLIB¶ +# CMAKE__COMPILER_RANLIB¶ +# CMAKE_STRIP +# CMAKE_NM +# CMAKE_OBJDUMP +# CMAKE_DLLTOOL +# CMAKE_MT +# CMAKE_LINKER + +# CMAKE_C_COMPILER +# CMAKE_CXX_COMPILER +# CMAKE_RC_COMPILER <-- +# CMAKE_RC_FLAGS + +# Flags: +# CMAKE__FLAGS +# CMAKE__FLAGS_ +# CMAKE_SHARED_LINKER_FLAGS +# CMAKE_STATIC_LINKER_FLAGS +# CMAKE_STATIC_LINKER_FLAGS_. +# CMAKE_EXE_LINKER_FLAGS +# CMAKE_EXE_LINKER_FLAGS_ (CMAKE_C_FLAGS_) + From deae3fe4cc81ace68049459e559842a3a6e576ec Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 16 Aug 2020 14:47:47 +0200 Subject: [PATCH 03/34] apply to make based ports. --- scripts/cmake/vcpkg_build_make.cmake | 20 ++++- scripts/cmake/vcpkg_configure_make.cmake | 110 ++++++++++++----------- 2 files changed, 75 insertions(+), 55 deletions(-) diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index 545e6d7653ebb6..0da614e325e4ea 100644 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -37,6 +37,7 @@ ## * [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake) function(vcpkg_build_make) cmake_parse_arguments(_bc "ADD_BIN_TO_PATH;ENABLE_INSTALL" "LOGFILE_ROOT;BUILD_TARGET" "" ${ARGN}) + include("${CMAKE_VARS_FILE}") if(NOT _bc_LOGFILE_ROOT) set(_bc_LOGFILE_ROOT "build") @@ -106,11 +107,28 @@ function(vcpkg_build_make) message(STATUS "Building ${TARGET_TRIPLET}${SHORT_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() + 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{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}") + if(LINK_ENV_${_VAR_SUFFIX}) + _vcpkg_backup_env_variables(_LINK_) + set(ENV{_LINK_} "${LINK_ENV_${_VAR_SUFFIX}}") + endif() + if(_bc_ADD_BIN_TO_PATH) set(_BACKUP_ENV_PATH "$ENV{PATH}") vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX}/bin") @@ -126,7 +144,7 @@ function(vcpkg_build_make) WORKING_DIRECTORY "${WORKING_DIRECTORY}" LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}" ) - + _vcpkg_restore_env_variables(_LINK_) if(_bc_ADD_BIN_TO_PATH) set(ENV{PATH} "${_BACKUP_ENV_PATH}") endif() diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index 52000e36d85e0c..c39cdbeac6984b 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -165,6 +165,14 @@ function(vcpkg_configure_make) "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;CONFIGURE_ENVIRONMENT_VARIABLES;CONFIG_DEPENDENT_ENVIRONMENT" ${ARGN} ) + vcpkg_get_cmake_vars(OUTPUT_FILE CMAKE_VARS_FILE) + set(CMAKE_VARS_FILE "${CMAKE_VARS_FILE}" PARENT_SCOPE) + debug_message("Including cmake vars from: ${CMAKE_VARS_FILE}") + include("${CMAKE_VARS_FILE}") + if(VCPKG_TARGET_IS_WINDOWS) + + endif() + if(DEFINED VCPKG_MAKE_BUILD_TRIPLET) set(_csc_BUILD_TRIPLET ${VCPKG_MAKE_BUILD_TRIPLET}) # Triplet overwrite for crosscompiling endif() @@ -273,15 +281,16 @@ function(vcpkg_configure_make) endmacro() set(CONFIGURE_ENV "V=1") + ## TODO: Add VCPKG_DETECTED vars here! if (_csc_AUTOCONFIG) # without autotools we assume a custom configure script which correctly handles cl and lib. Otherwise the port needs to set CC|CXX|AR and probably CPP - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "compile cl.exe -nologo -E") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "compile cl.exe -nologo") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "compile cl.exe -nologo") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "compile cl.exe -E") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "compile cl.exe ") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "compile cl.exe ") _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "ar-lib lib.exe -verbose") else() - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "cl.exe -nologo -E") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "cl.exe -nologo") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "cl.exe -nologo") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "cl.exe -E") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "cl.exe") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "cl.exe") _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "lib.exe -verbose") endif() _vcpkg_append_to_configure_environment(CONFIGURE_ENV LD "link.exe -verbose") @@ -361,12 +370,6 @@ function(vcpkg_configure_make) set(base_cmd) if(CMAKE_HOST_WIN32) set(base_cmd ${BASH} --noprofile --norc --debug) - # Load toolchains - if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE) - set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake") - endif() - include("${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}") - #Join the options list as a string with spaces between options list(JOIN _csc_OPTIONS " " _csc_OPTIONS) list(JOIN _csc_OPTIONS_RELEASE " " _csc_OPTIONS_RELEASE) list(JOIN _csc_OPTIONS_DEBUG " " _csc_OPTIONS_DEBUG) @@ -379,18 +382,11 @@ function(vcpkg_configure_make) set(ENV{C_INCLUDE_PATH} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${C_INCLUDE_PATH_BACKUP}") set(ENV{CPLUS_INCLUDE_PATH} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${CPLUS_INCLUDE_PATH_BACKUP}") - # Setup global flags -> TODO: Further improve with toolchain file in mind! - set(CPP_FLAGS_GLOBAL "$ENV{CPPFLAGS} -I${_VCPKG_INSTALLED}/include") - set(C_FLAGS_GLOBAL "$ENV{CFLAGS} ${VCPKG_C_FLAGS}") - set(CXX_FLAGS_GLOBAL "$ENV{CXXFLAGS} ${VCPKG_CXX_FLAGS}") - set(LD_FLAGS_GLOBAL "$ENV{LDFLAGS} ${VCPKG_LINKER_FLAGS}") # Flags should be set in the toolchain instead (Setting this up correctly requires a function named vcpkg_determined_cmake_compiler_flags which can also be used to setup CC and CXX etc.) - if(NOT VCPKG_TARGET_IS_WINDOWS) - string(APPEND C_FLAGS_GLOBAL " -fPIC") - string(APPEND CXX_FLAGS_GLOBAL " -fPIC") - else() + if(VCPKG_TARGET_IS_WINDOWS) + _vcpkg_backup_env_variables(_CL_ _LINK_) # TODO: Should be CPP flags instead -> rewrite when vcpkg_determined_cmake_compiler_flags defined - string(APPEND CPP_FLAGS_GLOBAL " /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN /DWIN32 /D_WINDOWS") + #string(APPEND CPP_FLAGS_GLOBAL " /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN /DWIN32 /D_WINDOWS") if(VCPKG_TARGET_IS_UWP) # Be aware that configure thinks it is crosscompiling due to: # error while loading shared libraries: VCRUNTIME140D_APP.dll: @@ -400,17 +396,11 @@ function(vcpkg_configure_make) # (This is due to libtool and compiler wrapper using the same set of options to pass those variables around) string(REPLACE "\\" "/" VCToolsInstallDir "$ENV{VCToolsInstallDir}") set(ENV{_CL_} "$ENV{_CL_} /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB_ -FU\"${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\"") - set(ENV{_LINK_} "$ENV{_LINK_} /MANIFEST /DYNAMICBASE WindowsApp.lib /WINMD:NO /APPCONTAINER") - endif() - if(VCPKG_TARGET_ARCHITECTURE STREQUAL x64) - set(ENV{_LINK_} "$ENV{_LINK_} -MACHINE:x64") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL x86) - set(ENV{_LINK_} "$ENV{_LINK_} -MACHINE:x86") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm) - set(ENV{_LINK_} "$ENV{_LINK_} -MACHINE:ARM") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm64) - set(ENV{_LINK_} "$ENV{_LINK_} -MACHINE:ARM64") + set(ENV{_LINK_} "$ENV{_LINK_} /MANIFEST /DYNAMICBASE /WINMD:NO /APPCONTAINER") endif() + set(ENV{_LINK_} "${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES}") + else() + set(ENV{LIBS} "$ENV{LIBS} ${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES}") endif() if(NOT ENV{PKG_CONFIG}) @@ -489,34 +479,40 @@ function(vcpkg_configure_make) set(PATH_SUFFIX_${_VAR_SUFFIX} "/debug") set(SHORT_NAME_${_VAR_SUFFIX} "dbg") list(APPEND _buildtypes ${_VAR_SUFFIX}) - if (CMAKE_HOST_WIN32) # Flags should be set in the toolchain instead - string(REGEX REPLACE "[ \t]+/" " -" CPPFLAGS_${_VAR_SUFFIX} "${CPP_FLAGS_GLOBAL}") - string(REGEX REPLACE "[ \t]+/" " -" CFLAGS_${_VAR_SUFFIX} "${C_FLAGS_GLOBAL} ${VCPKG_CRT_LINK_FLAG_PREFIX}d /D_DEBUG /Ob0 /Od ${VCPKG_C_FLAGS_${_VAR_SUFFIX}}") - string(REGEX REPLACE "[ \t]+/" " -" CXXFLAGS_${_VAR_SUFFIX} "${CXX_FLAGS_GLOBAL} ${VCPKG_CRT_LINK_FLAG_PREFIX}d /D_DEBUG /Ob0 /Od ${VCPKG_CXX_FLAGS_${_VAR_SUFFIX}}") - string(REGEX REPLACE "[ \t]+/" " -" LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib ${LD_FLAGS_GLOBAL} ${VCPKG_LINKER_FLAGS_${_VAR_SUFFIX}}") + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_STATIC_LINKERFLAGS_${_VAR_SUFFIX}}") + else() # dynamic + set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_SHARED_LINKERFLAGS_${_VAR_SUFFIX}}") + endif() + set(CPPFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") + set(CFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") + set(CXXFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_VAR_SUFFIX}}") + if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_C_COMPILER MATCHES "cl.exe") + set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/") + set(LINK_ENV_${_VAR_SUFFIX} "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}") else() - set(CPPFLAGS_${_VAR_SUFFIX} "${CPP_FLAGS_GLOBAL}") - set(CFLAGS_${_VAR_SUFFIX} "${C_FLAGS_GLOBAL} ${VCPKG_C_FLAGS_DEBUG}") - set(CXXFLAGS_${_VAR_SUFFIX} "${CXX_FLAGS_GLOBAL} ${VCPKG_CXX_FLAGS_DEBUG}") - set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/ ${LD_FLAGS_GLOBAL} ${VCPKG_LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/ ${LINKER_FLAGS_${_VAR_SUFFIX}}") endif() unset(_VAR_SUFFIX) endif() if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - set(_VAR_SUFFIX RELEASE) - set(PATH_SUFFIX_${_VAR_SUFFIX} "") - set(SHORT_NAME_${_VAR_SUFFIX} "rel") + set(_VAR_SUFFIX DEBUG) + set(PATH_SUFFIX_${_VAR_SUFFIX} "/debug") + set(SHORT_NAME_${_VAR_SUFFIX} "dbg") list(APPEND _buildtypes ${_VAR_SUFFIX}) - if (CMAKE_HOST_WIN32) # Flags should be set in the toolchain - string(REGEX REPLACE "[ \t]+/" " -" CPPFLAGS_${_VAR_SUFFIX} "${CPP_FLAGS_GLOBAL}") - string(REGEX REPLACE "[ \t]+/" " -" CFLAGS_${_VAR_SUFFIX} "${C_FLAGS_GLOBAL} ${VCPKG_CRT_LINK_FLAG_PREFIX} /O2 /Oi /Gy /DNDEBUG ${VCPKG_C_FLAGS_${_VAR_SUFFIX}}") - string(REGEX REPLACE "[ \t]+/" " -" CXXFLAGS_${_VAR_SUFFIX} "${CXX_FLAGS_GLOBAL} ${VCPKG_CRT_LINK_FLAG_PREFIX} /O2 /Oi /Gy /DNDEBUG ${VCPKG_CXX_FLAGS_${_VAR_SUFFIX}}") - string(REGEX REPLACE "[ \t]+/" " -" LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib ${LD_FLAGS_GLOBAL} ${VCPKG_LINKER_FLAGS_${_VAR_SUFFIX}}") + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_STATIC_LINKERFLAGS_${_VAR_SUFFIX}}") + else() # dynamic + set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_SHARED_LINKERFLAGS_${_VAR_SUFFIX}}") + endif() + set(CPPFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") + set(CFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") + set(CXXFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_VAR_SUFFIX}}") + if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_C_COMPILER MATCHES "cl.exe") + set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/") + set(LINK_ENV_${_VAR_SUFFIX} "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}") else() - set(CPPFLAGS_${_VAR_SUFFIX} "${CPP_FLAGS_GLOBAL}") - set(CFLAGS_${_VAR_SUFFIX} "${C_FLAGS_GLOBAL} ${VCPKG_C_FLAGS_DEBUG}") - set(CXXFLAGS_${_VAR_SUFFIX} "${CXX_FLAGS_GLOBAL} ${VCPKG_CXX_FLAGS_DEBUG}") - set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/ ${LD_FLAGS_GLOBAL} ${VCPKG_LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/ ${LINKER_FLAGS_${_VAR_SUFFIX}}") endif() unset(_VAR_SUFFIX) endif() @@ -553,6 +549,10 @@ function(vcpkg_configure_make) set(ENV{CFLAGS} ${CFLAGS_${_buildtype}}) set(ENV{CXXFLAGS} ${CXXFLAGS_${_buildtype}}) set(ENV{LDFLAGS} ${LDFLAGS_${_buildtype}}) + if(LINK_ENV_${_VAR_SUFFIX}) + _vcpkg_backup_env_variables(_LINK_) + set(ENV{_LINK_} "${LINK_ENV_${_VAR_SUFFIX}}") + endif() set(ENV{PKG_CONFIG} "${PKGCONFIG} --define-variable=prefix=${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}") set(ENV{LIB} "${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}/lib/manual-link/${LIB_PATHLIKE_CONCAT}") @@ -591,7 +591,9 @@ function(vcpkg_configure_make) unset(ENV{PKG_CONFIG_PATH}) endif() unset(BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype}) - + + _vcpkg_restore_env_variables(_LINK_) + if(_csc_ADD_BIN_TO_PATH) set(ENV{PATH} "${PATH_BACKUP}") endif() From d4d7e21e07db96c948e219f03dcb473e7427fa1d Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 16 Aug 2020 15:13:51 +0200 Subject: [PATCH 04/34] add log suffix on not windows platforms --- scripts/cmake/vcpkg_get_cmake_vars.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/cmake/vcpkg_get_cmake_vars.cmake b/scripts/cmake/vcpkg_get_cmake_vars.cmake index ed4051c57a0cf9..7b1925a08dcd09 100644 --- a/scripts/cmake/vcpkg_get_cmake_vars.cmake +++ b/scripts/cmake/vcpkg_get_cmake_vars.cmake @@ -56,6 +56,9 @@ function(vcpkg_get_cmake_vars) file(REMOVE "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}-err.log") file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-get-cmake-vars") file(RENAME "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-get-cmake-vars") - file(RENAME "${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}-out.log" "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}-out.log") - file(RENAME "${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}-err.log" "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}-err.log") + if(NOT VCPKG_TARGET_IS_WINDOWS) + set(LOGSUFFIX -rel) + endif() + file(RENAME "${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}${LOGSUFFIX}-out.log" "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}-out.log") + file(RENAME "${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}${LOGSUFFIX}-err.log" "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}-err.log") endfunction() \ No newline at end of file From d47399dc012ea3c66388b05ba4289a6420b49e93 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 16 Aug 2020 16:54:16 +0200 Subject: [PATCH 05/34] fix c&p error --- scripts/cmake/vcpkg_configure_make.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index c39cdbeac6984b..fbbd072726b090 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -496,9 +496,9 @@ function(vcpkg_configure_make) unset(_VAR_SUFFIX) endif() if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - set(_VAR_SUFFIX DEBUG) - set(PATH_SUFFIX_${_VAR_SUFFIX} "/debug") - set(SHORT_NAME_${_VAR_SUFFIX} "dbg") + set(_VAR_SUFFIX RELEASE) + set(PATH_SUFFIX_${_VAR_SUFFIX} "") + set(SHORT_NAME_${_VAR_SUFFIX} "rel") list(APPEND _buildtypes ${_VAR_SUFFIX}) if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_STATIC_LINKERFLAGS_${_VAR_SUFFIX}}") From 6ccbae503c58d1726a7bf680a2a1774862472a5e Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 16 Aug 2020 16:55:02 +0200 Subject: [PATCH 06/34] add previous LINK env --- scripts/cmake/vcpkg_build_make.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index 0da614e325e4ea..1bd391ada50577 100644 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -126,7 +126,7 @@ function(vcpkg_build_make) if(LINK_ENV_${_VAR_SUFFIX}) _vcpkg_backup_env_variables(_LINK_) - set(ENV{_LINK_} "${LINK_ENV_${_VAR_SUFFIX}}") + set(ENV{_LINK_} "$ENV{_LINK_} ${LINK_ENV_${_VAR_SUFFIX}}") endif() if(_bc_ADD_BIN_TO_PATH) From 0f2004b8993a59c835cd799efa0dc6aa77c2b575 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 16 Aug 2020 18:18:43 +0200 Subject: [PATCH 07/34] setup env on windows and extract cpp flags correctly. --- scripts/cmake/vcpkg_configure_make.cmake | 100 +++++++++++++++++------ 1 file changed, 76 insertions(+), 24 deletions(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index fbbd072726b090..f6728cbbfce378 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -281,28 +281,60 @@ function(vcpkg_configure_make) endmacro() set(CONFIGURE_ENV "V=1") - ## TODO: Add VCPKG_DETECTED vars here! + # Remove full filepaths due to spaces (compiler needs to be on path) + set(progs VCPKG_DETECTED_C_COMPILER VCPKG_DETECTED_CXX_COMPILER VCPKG_DETECTED_AR VCPKG_DETECTED_LINKER VCPKG_DETECTED_RANLIB VCPKG_DETECTED_OBJDUMP + VCPKG_DETECTED_STRIP VCPKG_DETECTED_NM VCPKG_DETECTED_DLLTOOL VCPKG_DETECTED_RC_COMPILER) + foreach(prog IN LISTS progs) + if(${prog}) + get_filename_component(${prog} "${${prog}}" NAME) + endif() + endforeach() if (_csc_AUTOCONFIG) # without autotools we assume a custom configure script which correctly handles cl and lib. Otherwise the port needs to set CC|CXX|AR and probably CPP - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "compile cl.exe -E") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "compile cl.exe ") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "compile cl.exe ") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "ar-lib lib.exe -verbose") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "compile ${VCPKG_DETECTED_C_COMPILER} -E") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "compile ${VCPKG_DETECTED_C_COMPILER}") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "compile ${VCPKG_DETECTED_CXX_COMPILER}") + if(VCPKG_DETECTED_AR) + _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "${VCPKG_DETECTED_AR}") + else() + _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "ar-lib lib.exe -verbose") + endif() + else() + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "${VCPKG_DETECTED_C_COMPILER} -E") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "${VCPKG_DETECTED_C_COMPILER}") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "${VCPKG_DETECTED_CXX_COMPILER}") + if(VCPKG_DETECTED_AR) + _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "${VCPKG_DETECTED_AR}") + else() + _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "lib.exe -verbose") + endif() + endif() + _vcpkg_append_to_configure_environment(CONFIGURE_ENV LD "${VCPKG_DETECTED_LINKER} -verbose") + if(VCPKG_DETECTED_RANLIB) + _vcpkg_append_to_configure_environment(CONFIGURE_ENV RANLIB "${VCPKG_DETECTED_RANLIB}") # Trick to ignore the RANLIB call + else() + _vcpkg_append_to_configure_environment(CONFIGURE_ENV RANLIB ":") + endif() + if(VCPKG_DETECTED_OBJDUMP) #Objdump is required to make shared libraries. Otherwise define lt_cv_deplibs_check_method=pass_all + _vcpkg_append_to_configure_environment(CONFIGURE_ENV OBJDUMP "${VCPKG_DETECTED_OBJDUMP}") # Trick to ignore the RANLIB call + endif() + if(VCPKG_DETECTED_STRIP) # If required set the ENV variable STRIP in the portfile correctly + _vcpkg_append_to_configure_environment(CONFIGURE_ENV STRIP "${VCPKG_DETECTED_STRIP}") else() - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "cl.exe -E") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "cl.exe") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "cl.exe") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "lib.exe -verbose") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV STRIP ":") + endif() + if(VCPKG_DETECTED_NM) # If required set the ENV variable NM in the portfile correctly + _vcpkg_append_to_configure_environment(CONFIGURE_ENV NM "${VCPKG_DETECTED_NM}") + else() + # Would be better to have a true nm here! Some symbols (mainly exported variables) get not properly imported with dumpbin as nm + # and require __declspec(dllimport) for some reason (same problem CMake has with WINDOWS_EXPORT_ALL_SYMBOLS) + _vcpkg_append_to_configure_environment(CONFIGURE_ENV NM "dumpbin.exe -symbols -headers") + endif() + if(VCPKG_DETECTED_DLLTOOL) # If required set the ENV variable DLLTOOL in the portfile correctly + _vcpkg_append_to_configure_environment(CONFIGURE_ENV DLLTOOL "${VCPKG_DETECTED_DLLTOOL}") + else() + _vcpkg_append_to_configure_environment(CONFIGURE_ENV DLLTOOL "link.exe -verbose -dll") endif() - _vcpkg_append_to_configure_environment(CONFIGURE_ENV LD "link.exe -verbose") - _vcpkg_append_to_configure_environment(CONFIGURE_ENV RANLIB ":") # Trick to ignore the RANLIB call - #_vcpkg_append_to_configure_environment(CONFIGURE_ENV OBJDUMP ":") ' Objdump is required to make shared libraries. Otherwise define lt_cv_deplibs_check_method=pass_all _vcpkg_append_to_configure_environment(CONFIGURE_ENV CCAS ":") # If required set the ENV variable CCAS in the portfile correctly - _vcpkg_append_to_configure_environment(CONFIGURE_ENV STRIP ":") # If required set the ENV variable STRIP in the portfile correctly - _vcpkg_append_to_configure_environment(CONFIGURE_ENV NM "dumpbin.exe -symbols -headers") - # Would be better to have a true nm here! Some symbols (mainly exported variables) get not properly imported with dumpbin as nm - # and require __declspec(dllimport) for some reason (same problem CMake has with WINDOWS_EXPORT_ALL_SYMBOLS) - _vcpkg_append_to_configure_environment(CONFIGURE_ENV DLLTOOL "link.exe -verbose -dll") - foreach(_env IN LISTS _csc_CONFIGURE_ENVIRONMENT_VARIABLES) _vcpkg_append_to_configure_environment(CONFIGURE_ENV ${_env} "${${_env}}") endforeach() @@ -474,6 +506,30 @@ function(vcpkg_configure_make) ) endif() + macro(extract_cpp_flags_and_set_cflags_and_cxxflags) + string(REGEX MATCHALL "( |^)-[^ ]+" CPPFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") + string(REGEX MATCHALL "( |^)-[^ ]+" CXXPPFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_VAR_SUFFIX}}") + list(JOIN CXXPPFLAGS_${_VAR_SUFFIX} "|" CXXREGEX) + if(CXXREGEX) + list(FILTER CPPFLAGS_${_VAR_SUFFIX} INCLUDE REGEX "(${CXXREGEX})") + else() + set(CPPFLAGS_${_VAR_SUFFIX}) + endif() + list(JOIN CPPFLAGS_${_VAR_SUFFIX} "|" CPPREGEX) + list(JOIN CPPFLAGS_${_VAR_SUFFIX} " " CPPFLAGS_${_VAR_SUFFIX}) + set(CPPFLAGS_${_VAR_SUFFIX} " ${CPPFLAGS_${_VAR_SUFFIX}}") + if(CPPREGEX) + string(REGEX REPLACE "(${CPPREGEX})" "" CFLAGS_${_VAR_SUFFIX} " ${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") + string(REGEX REPLACE "(${CPPREGEX})" "" CXXFLAGS_${_VAR_SUFFIX} " ${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_VAR_SUFFIX}}") + else() + set(CFLAGS_${_VAR_SUFFIX} " ${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") + set(CXXFLAGS_${_VAR_SUFFIX} " ${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_VAR_SUFFIX}}") + endif() + debug_message("CPPFLAGS_${_VAR_SUFFIX}: ${CPPFLAGS_${_VAR_SUFFIX}}") + debug_message("CFLAGS_${_VAR_SUFFIX}: ${CFLAGS_${_VAR_SUFFIX}}") + debug_message("CXXFLAGS_${_VAR_SUFFIX}: ${CXXFLAGS_${_VAR_SUFFIX}}") + endmacro() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" AND NOT _csc_NO_DEBUG) set(_VAR_SUFFIX DEBUG) set(PATH_SUFFIX_${_VAR_SUFFIX} "/debug") @@ -484,9 +540,7 @@ function(vcpkg_configure_make) else() # dynamic set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_SHARED_LINKERFLAGS_${_VAR_SUFFIX}}") endif() - set(CPPFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") - set(CFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") - set(CXXFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_VAR_SUFFIX}}") + extract_cpp_flags_and_set_cflags_and_cxxflags() if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_C_COMPILER MATCHES "cl.exe") set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/") set(LINK_ENV_${_VAR_SUFFIX} "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}") @@ -505,9 +559,7 @@ function(vcpkg_configure_make) else() # dynamic set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_SHARED_LINKERFLAGS_${_VAR_SUFFIX}}") endif() - set(CPPFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") - set(CFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") - set(CXXFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_VAR_SUFFIX}}") + extract_cpp_flags_and_set_cflags_and_cxxflags() if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_C_COMPILER MATCHES "cl.exe") set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/") set(LINK_ENV_${_VAR_SUFFIX} "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}") From f811525bc4e5ec701bac4adcb0b0a3baef5ea91d Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Mon, 17 Aug 2020 10:55:50 +0200 Subject: [PATCH 08/34] Apply suggestions from code review --- scripts/cmake/vcpkg_configure_make.cmake | 5 ----- scripts/get_cmake_vars/CMakeLists.txt | 19 ------------------- 2 files changed, 24 deletions(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index f6728cbbfce378..b428787e9ca96e 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -169,10 +169,6 @@ function(vcpkg_configure_make) set(CMAKE_VARS_FILE "${CMAKE_VARS_FILE}" PARENT_SCOPE) debug_message("Including cmake vars from: ${CMAKE_VARS_FILE}") include("${CMAKE_VARS_FILE}") - if(VCPKG_TARGET_IS_WINDOWS) - - endif() - if(DEFINED VCPKG_MAKE_BUILD_TRIPLET) set(_csc_BUILD_TRIPLET ${VCPKG_MAKE_BUILD_TRIPLET}) # Triplet overwrite for crosscompiling endif() @@ -418,7 +414,6 @@ function(vcpkg_configure_make) if(VCPKG_TARGET_IS_WINDOWS) _vcpkg_backup_env_variables(_CL_ _LINK_) # TODO: Should be CPP flags instead -> rewrite when vcpkg_determined_cmake_compiler_flags defined - #string(APPEND CPP_FLAGS_GLOBAL " /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN /DWIN32 /D_WINDOWS") if(VCPKG_TARGET_IS_UWP) # Be aware that configure thinks it is crosscompiling due to: # error while loading shared libraries: VCRUNTIME140D_APP.dll: diff --git a/scripts/get_cmake_vars/CMakeLists.txt b/scripts/get_cmake_vars/CMakeLists.txt index f26137ce9ecd14..dab84f4bc081f3 100644 --- a/scripts/get_cmake_vars/CMakeLists.txt +++ b/scripts/get_cmake_vars/CMakeLists.txt @@ -91,24 +91,6 @@ endforeach() file(WRITE "${VCPKG_OUTPUT_FILE}" "${OUTPUT_STRING}") -# Not useful? -# CMAKE__STANDARD_INCLUDE_DIRECTORIES -# CMAKE__STANDARD_LIBRARIES - -# CMAKE__IMPLICIT_LINK_FRAMEWORK_DIRECTORIES -# CMAKE__IMPLICIT_INCLUDE_DIRECTORIES -# CMAKE__IMPLICIT_LINK_DIRECTORIES -# CMAKE__IMPLICIT_LINK_LIBRARIES - -# CMAKE_LINK_INTERFACE_LIBRARIES -> LIBS - -# Dir properties: -# COMPILE_DEFINITIONS(_CONFIG) -# COMPILE_OPTIONS(_CONFIG) -# INCLUDE_DIRECTORIES -# LINK_DIRECTORIES -# LINK_OPTIONS - # Programs: # CMAKE_AR # CMAKE__COMPILER_AR (Wrapper) @@ -134,4 +116,3 @@ file(WRITE "${VCPKG_OUTPUT_FILE}" "${OUTPUT_STRING}") # CMAKE_STATIC_LINKER_FLAGS_. # CMAKE_EXE_LINKER_FLAGS # CMAKE_EXE_LINKER_FLAGS_ (CMAKE_C_FLAGS_) - From eb2ef40f2e84c960460faa3b02a3ccc478c2731d Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 20 Aug 2020 10:47:41 +0200 Subject: [PATCH 09/34] commit changes from fontconfig PR --- scripts/buildsystems/make_wrapper/windres-rc | 130 +++++++++++ scripts/cmake/vcpkg_build_make.cmake | 91 ++++---- scripts/cmake/vcpkg_configure_make.cmake | 220 +++++++++++-------- 3 files changed, 313 insertions(+), 128 deletions(-) create mode 100644 scripts/buildsystems/make_wrapper/windres-rc diff --git a/scripts/buildsystems/make_wrapper/windres-rc b/scripts/buildsystems/make_wrapper/windres-rc new file mode 100644 index 00000000000000..88cc8425f72b7a --- /dev/null +++ b/scripts/buildsystems/make_wrapper/windres-rc @@ -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: diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index 1bd391ada50577..29b5191af0d285 100644 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -24,6 +24,9 @@ ## The target passed to the make build command (`./make `). If not specified, the 'all' target will ## be passed. ## +## ### DISABLE_PARALLEL +## The underlying buildsystem will be instructed to not parallelize +## ## ## Notes: ## 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 @@ -36,8 +39,8 @@ ## * [freexl](https://github.com/Microsoft/vcpkg/blob/master/ports/freexl/portfile.cmake) ## * [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake) function(vcpkg_build_make) - cmake_parse_arguments(_bc "ADD_BIN_TO_PATH;ENABLE_INSTALL" "LOGFILE_ROOT;BUILD_TARGET" "" ${ARGN}) include("${CMAKE_VARS_FILE}") + cmake_parse_arguments(PARSE_ARGV 0 _bc "ADD_BIN_TO_PATH;ENABLE_INSTALL;DISABLE_PARALLEL" "LOGFILE_ROOT;BUILD_TARGET" "") if(NOT _bc_LOGFILE_ROOT) set(_bc_LOGFILE_ROOT "build") @@ -65,6 +68,7 @@ function(vcpkg_build_make) find_program(MAKE make REQUIRED) set(MAKE_COMMAND "${MAKE}") set(MAKE_OPTS ${_bc_MAKE_OPTIONS} -j ${VCPKG_CONCURRENCY} --trace -f Makefile ${_bc_BUILD_TARGET}) + set(NO_PARALLEL_MAKE_OPTS ${_bc_MAKE_OPTIONS} -j 1 --trace -f Makefile ${_bc_BUILD_TARGET}) string(REPLACE " " "\\\ " _VCPKG_PACKAGE_PREFIX ${CURRENT_PACKAGES_DIR}) string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_PACKAGE_PREFIX "${_VCPKG_PACKAGE_PREFIX}") @@ -76,6 +80,7 @@ function(vcpkg_build_make) set(MAKE_COMMAND "${MAKE}") # Set make command and install command set(MAKE_OPTS ${_bc_MAKE_OPTIONS} V=1 -j ${VCPKG_CONCURRENCY} -f Makefile ${_bc_BUILD_TARGET}) + set(NO_PARALLEL_MAKE_OPTS ${_bc_MAKE_OPTIONS} V=1 -j 1 -f Makefile ${_bc_BUILD_TARGET}) set(INSTALL_OPTS -j ${VCPKG_CONCURRENCY} install DESTDIR=${CURRENT_PACKAGES_DIR}) endif() @@ -104,29 +109,35 @@ function(vcpkg_build_make) endif() set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}") - message(STATUS "Building ${TARGET_TRIPLET}${SHORT_BUILDTYPE}") + 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(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}}") + 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_COMBINED_RCFLAGS_${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{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{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}) - _vcpkg_backup_env_variables(_LINK_) - set(ENV{_LINK_} "$ENV{_LINK_} ${LINK_ENV_${_VAR_SUFFIX}}") + set(_LINK_CONFIG_BACKUP "$ENV{_LINK_}") + set(ENV{_LINK_} "${LINK_ENV_${_VAR_SUFFIX}}") endif() if(_bc_ADD_BIN_TO_PATH) @@ -136,56 +147,60 @@ function(vcpkg_build_make) if(MAKE_BASH) set(MAKE_CMD_LINE "${MAKE_COMMAND} ${MAKE_OPTS}") + set(NO_PARALLEL_MAKE_CMD_LINE "${MAKE_COMMAND} ${NO_PARALLEL_MAKE_OPTS}") else() set(MAKE_CMD_LINE ${MAKE_COMMAND} ${MAKE_OPTS}) + set(NO_PARALLEL_MAKE_CMD_LINE ${MAKE_COMMAND} ${NO_PARALLEL_MAKE_OPTS}) endif() - vcpkg_execute_build_process( - COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE} - WORKING_DIRECTORY "${WORKING_DIRECTORY}" - LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}" + + # foreach(_envar IN LISTS printvars) + # message(STATUS "ENV{${_envar}} : '$ENV{${_envar}}'") + # endforeach() + + if (_bc_DISABLE_PARALLEL) + vcpkg_execute_build_process( + COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE} + WORKING_DIRECTORY "${WORKING_DIRECTORY}" + LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}" + ) + else() + 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}" ) - _vcpkg_restore_env_variables(_LINK_) - if(_bc_ADD_BIN_TO_PATH) - set(ENV{PATH} "${_BACKUP_ENV_PATH}") endif() - endif() - endforeach() - - 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() + 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() - - set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}") + # foreach(_envar IN LISTS printvars) + # message(STATUS "ENV{${_envar}} : '$ENV{${_envar}}'") + # endforeach() vcpkg_execute_build_process( COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE} WORKING_DIRECTORY "${WORKING_DIRECTORY}" LOGNAME "install-${TARGET_TRIPLET}${SHORT_BUILDTYPE}" ) + endif() + + if(_LINK_CONFIG_BACKUP) + set(ENV{_LINK_} "${_LINK_CONFIG_BACKUP}") + unset(_LINK_CONFIG_BACKUP) + endif() + if(_bc_ADD_BIN_TO_PATH) + set(ENV{PATH} "${_BACKUP_ENV_PATH}") endif() - endforeach() + endif() + endforeach() + + if (_bc_ENABLE_INSTALL) string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_INSTALL_PREFIX "${CURRENT_INSTALLED_DIR}") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}_tmp") file(RENAME "${CURRENT_PACKAGES_DIR}" "${CURRENT_PACKAGES_DIR}_tmp") diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index f6728cbbfce378..d214c761edd15f 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -6,7 +6,9 @@ ## ```cmake ## vcpkg_configure_make( ## SOURCE_PATH <${SOURCE_PATH}> -## [AUTOCONFIG] +## [AUTOCONFIG] +## [USE_WRAPPERS] +## [DETERMINE_BUILD_TRIPLET] ## [BUILD_TRIPLET "--host=x64 --build=i686-unknown-pc"] ## [NO_ADDITIONAL_PATHS] ## [CONFIG_DEPENDENT_ENVIRONMENT ...] @@ -34,9 +36,15 @@ ## ### SKIP_CONFIGURE ## Skip configure process ## +## ### USE_WRAPPERS +## Use autotools ar-lib and compile wrappers (only applies to windows cl and lib) +## ## ### BUILD_TRIPLET ## Used to pass custom --build/--target/--host to configure. Can be globally overwritten by VCPKG_MAKE_BUILD_TRIPLET ## +## ### DETERMINE_BUILD_TRIPLET +## For ports having a configure script following the autotools rules +## ## ### NO_ADDITIONAL_PATHS ## Don't pass any additional paths except for --prefix to the configure call ## @@ -78,6 +86,8 @@ ## * [tcl](https://github.com/Microsoft/vcpkg/blob/master/ports/tcl/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) +set(printvars PATH _LINK_ _CL_ CPPFLAGS CFLAGS CXXFLAGS LDFLAGS LIBS INCLUDE LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) + macro(_vcpkg_determine_host_mingw out_var) if(DEFINED ENV{PROCESSOR_ARCHITEW6432}) set(HOST_ARCH $ENV{PROCESSOR_ARCHITEW6432}) @@ -158,9 +168,44 @@ macro(_vcpkg_restore_env_variables) endforeach() endmacro() +macro(extract_cpp_flags_and_set_cflags_and_cxxflags _SUFFIX) + string(REGEX MATCHALL "( |^)-D[^ ]+" CPPFLAGS_${_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_SUFFIX}}") + string(REGEX MATCHALL "( |^)-D[^ ]+" CXXPPFLAGS_${_SUFFIX} "${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_SUFFIX}}") + list(JOIN CXXPPFLAGS_${_SUFFIX} "|" CXXREGEX) + if(CXXREGEX) + list(FILTER CPPFLAGS_${_SUFFIX} INCLUDE REGEX "(${CXXREGEX})") + else() + set(CPPFLAGS_${_SUFFIX}) + endif() + list(JOIN CPPFLAGS_${_SUFFIX} "|" CPPREGEX) + list(JOIN CPPFLAGS_${_SUFFIX} " " CPPFLAGS_${_SUFFIX}) + set(CPPFLAGS_${_SUFFIX} "${CPPFLAGS_${_SUFFIX}}") + if(CPPREGEX) + string(REGEX REPLACE "(${CPPREGEX})" "" CFLAGS_${_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_SUFFIX}}") + string(REGEX REPLACE "(${CPPREGEX})" "" CXXFLAGS_${_SUFFIX} "${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_SUFFIX}}") + else() + set(CFLAGS_${_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_SUFFIX}}") + set(CXXFLAGS_${_SUFFIX} "${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_SUFFIX}}") + endif() + string(REGEX REPLACE " +" " " CPPFLAGS_${_SUFFIX} "${CPPFLAGS_${_SUFFIX}}") + string(REGEX REPLACE " +" " " CFLAGS_${_SUFFIX} "${CFLAGS_${_SUFFIX}}") + string(REGEX REPLACE " +" " " CXXFLAGS_${_SUFFIX} "${CXXFLAGS_${_SUFFIX}}") + # libtool has and -R option so we need to guard against -RTC by using -Xcompiler + # while configuring there might be a lot of unknown compiler option warnings due to that + # just ignore them. + string(REGEX REPLACE "((-|/)RTC[^ ]+)" "-Xcompiler \\1" CFLAGS_${_SUFFIX} "${CFLAGS_${_SUFFIX}}") + string(REGEX REPLACE "((-|/)RTC[^ ]+)" "-Xcompiler \\1" CXXFLAGS_${_SUFFIX} "${CXXFLAGS_${_SUFFIX}}") + string(STRIP "${CPPFLAGS_${_SUFFIX}}" CPPFLAGS_${_SUFFIX}) + string(STRIP "${CFLAGS_${_SUFFIX}}" CFLAGS_${_SUFFIX}) + string(STRIP "${CXXFLAGS_${_SUFFIX}}" CXXFLAGS_${_SUFFIX}) + debug_message("CPPFLAGS_${_SUFFIX}: ${CPPFLAGS_${_SUFFIX}}") + debug_message("CFLAGS_${_SUFFIX}: ${CFLAGS_${_SUFFIX}}") + debug_message("CXXFLAGS_${_SUFFIX}: ${CXXFLAGS_${_SUFFIX}}") +endmacro() + function(vcpkg_configure_make) cmake_parse_arguments(_csc - "AUTOCONFIG;SKIP_CONFIGURE;COPY_SOURCE;DISABLE_VERBOSE_FLAGS;NO_ADDITIONAL_PATHS;ADD_BIN_TO_PATH" + "AUTOCONFIG;SKIP_CONFIGURE;COPY_SOURCE;DISABLE_VERBOSE_FLAGS;NO_ADDITIONAL_PATHS;ADD_BIN_TO_PATH;USE_WRAPPERS;DETERMINE_BUILD_TRIPLET" "SOURCE_PATH;PROJECT_SUBPATH;PRERUN_SHELL;BUILD_TRIPLET" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;CONFIGURE_ENVIRONMENT_VARIABLES;CONFIG_DEPENDENT_ENVIRONMENT" ${ARGN} @@ -169,10 +214,6 @@ function(vcpkg_configure_make) set(CMAKE_VARS_FILE "${CMAKE_VARS_FILE}" PARENT_SCOPE) debug_message("Including cmake vars from: ${CMAKE_VARS_FILE}") include("${CMAKE_VARS_FILE}") - if(VCPKG_TARGET_IS_WINDOWS) - - endif() - if(DEFINED VCPKG_MAKE_BUILD_TRIPLET) set(_csc_BUILD_TRIPLET ${VCPKG_MAKE_BUILD_TRIPLET}) # Triplet overwrite for crosscompiling endif() @@ -201,7 +242,7 @@ function(vcpkg_configure_make) debug_message("REQUIRES_AUTOCONFIG:${REQUIRES_AUTOCONFIG}") # Backup environment variables # CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJCXX R UPC Y - set(FLAGPREFIXES CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJXX R UPC Y) + set(FLAGPREFIXES CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJXX R UPC Y RC) foreach(_prefix IN LISTS FLAGPREFIXES) _vcpkg_backup_env_variable(${prefix}FLAGS) endforeach() @@ -217,15 +258,12 @@ function(vcpkg_configure_make) _vcpkg_backup_env_variables(INCLUDE LIB LIBPATH) if(CURRENT_PACKAGES_DIR MATCHES " " OR CURRENT_INSTALLED_DIR MATCHES " ") - # Don't bother with whitespace. The tools will probably fail and I tried very hard trying to make it work (no success so far)! message(WARNING "Detected whitespace in root directory. Please move the path to one without whitespaces! The required tools do not handle whitespaces correctly and the build will most likely fail") endif() # Pre-processing windows configure requirements if (CMAKE_HOST_WIN32) - _vcpkg_determine_autotools_host_cpu(BUILD_ARCH) # VCPKG_HOST => machine you are building on => --build= - list(APPEND MSYS_REQUIRE_PACKAGES diffutils pkg-config binutils @@ -234,34 +272,36 @@ function(vcpkg_configure_make) gettext-devel ) list(APPEND MSYS_REQUIRE_PACKAGES make) - if (_csc_AUTOCONFIG) + if (_csc_AUTOCONFIG OR _csc_USE_WRAPPERS) list(APPEND MSYS_REQUIRE_PACKAGES autoconf autoconf-archive automake m4 ) + endif() + if(_csc_AUTOCONFIG AND NOT _csc_BUILD_TRIPLET OR _csc_DETERMINE_BUILD_TRIPLET) + _vcpkg_determine_autotools_host_cpu(BUILD_ARCH) # VCPKG_HOST => machine you are building on => --build= + _vcpkg_determine_autotools_target_cpu(TARGET_ARCH) # --build: the machine you are building on # --host: the machine you are building for # --target: the machine that CC will produce binaries for # https://stackoverflow.com/questions/21990021/how-to-determine-host-value-for-configure-when-using-cross-compiler # Only for ports using autotools so we can assume that they follow the common conventions for build/target/host - if(NOT _csc_BUILD_TRIPLET) - set(_csc_BUILD_TRIPLET "--build=${BUILD_ARCH}-pc-mingw32") # This is required since we are running in a msys - # shell which will be otherwise identified as ${BUILD_ARCH}-pc-msys - _vcpkg_determine_autotools_target_cpu(TARGET_ARCH) - if(NOT TARGET_ARCH MATCHES "${BUILD_ARCH}") # we do not need to specify the additional flags if we build nativly. - string(APPEND _csc_BUILD_TRIPLET " --host=${TARGET_ARCH}-pc-mingw32") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target) - endif() - if(VCPKG_TARGET_IS_UWP AND NOT _csc_BUILD_TRIPLET MATCHES "--host") - # Needs to be different from --build to enable cross builds. - string(APPEND _csc_BUILD_TRIPLET " --host=${TARGET_ARCH}-unknown-mingw32") - endif() + set(_csc_BUILD_TRIPLET "--build=${BUILD_ARCH}-pc-mingw32") # This is required since we are running in a msys + # shell which will be otherwise identified as ${BUILD_ARCH}-pc-msys + if(NOT TARGET_ARCH MATCHES "${BUILD_ARCH}") # we do not need to specify the additional flags if we build nativly. + string(APPEND _csc_BUILD_TRIPLET " --host=${TARGET_ARCH}-pc-mingw32") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target) + endif() + if(VCPKG_TARGET_IS_UWP AND NOT _csc_BUILD_TRIPLET MATCHES "--host") + # Needs to be different from --build to enable cross builds. + string(APPEND _csc_BUILD_TRIPLET " --host=${TARGET_ARCH}-unknown-mingw32") endif() - debug_message("Using make triplet: ${_csc_BUILD_TRIPLET}") endif() + debug_message("Using make triplet: ${_csc_BUILD_TRIPLET}") vcpkg_acquire_msys(MSYS_ROOT PACKAGES ${MSYS_REQUIRE_PACKAGES}) vcpkg_add_to_path("${MSYS_ROOT}/usr/bin") + set(BASH "${MSYS_ROOT}/usr/bin/bash.exe") # This is required because PATH contains sort and find from Windows but the MSYS versions are needed @@ -289,10 +329,14 @@ function(vcpkg_configure_make) get_filename_component(${prog} "${${prog}}" NAME) endif() endforeach() - if (_csc_AUTOCONFIG) # without autotools we assume a custom configure script which correctly handles cl and lib. Otherwise the port needs to set CC|CXX|AR and probably CPP + if (_csc_AUTOCONFIG OR _csc_USE_WRAPPERS) # without autotools we assume a custom configure script which correctly handles cl and lib. Otherwise the port needs to set CC|CXX|AR and probably CPP _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "compile ${VCPKG_DETECTED_C_COMPILER} -E") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "compile ${VCPKG_DETECTED_C_COMPILER}") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC_FOR_BUILD "compile ${VCPKG_DETECTED_C_COMPILER}") _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "compile ${VCPKG_DETECTED_CXX_COMPILER}") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV RC "windres-rc ${VCPKG_DETECTED_RC_COMPILER}") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV WINDRES "windres-rc ${VCPKG_DETECTED_RC_COMPILER}") if(VCPKG_DETECTED_AR) _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "${VCPKG_DETECTED_AR}") else() @@ -300,7 +344,9 @@ function(vcpkg_configure_make) endif() else() _vcpkg_append_to_configure_environment(CONFIGURE_ENV CPP "${VCPKG_DETECTED_C_COMPILER} -E") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC "${VCPKG_DETECTED_C_COMPILER}") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV CC_FOR_BUILD "${VCPKG_DETECTED_C_COMPILER}") _vcpkg_append_to_configure_environment(CONFIGURE_ENV CXX "${VCPKG_DETECTED_CXX_COMPILER}") if(VCPKG_DETECTED_AR) _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "${VCPKG_DETECTED_AR}") @@ -335,9 +381,11 @@ function(vcpkg_configure_make) _vcpkg_append_to_configure_environment(CONFIGURE_ENV DLLTOOL "link.exe -verbose -dll") endif() _vcpkg_append_to_configure_environment(CONFIGURE_ENV CCAS ":") # If required set the ENV variable CCAS in the portfile correctly + _vcpkg_append_to_configure_environment(CONFIGURE_ENV AS ":") # If required set the ENV variable CCAS in the portfile correctly foreach(_env IN LISTS _csc_CONFIGURE_ENVIRONMENT_VARIABLES) _vcpkg_append_to_configure_environment(CONFIGURE_ENV ${_env} "${${_env}}") endforeach() + # Other maybe interesting variables to control # COMPILE This is the command used to actually compile a C source file. The file name is appended to form the complete command line. # LINK This is the command used to actually link a C program. @@ -348,10 +396,11 @@ function(vcpkg_configure_make) string(REPLACE " " "\\\ " _VCPKG_PREFIX ${CURRENT_INSTALLED_DIR}) string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_PREFIX "${_VCPKG_PREFIX}") set(_VCPKG_INSTALLED ${CURRENT_INSTALLED_DIR}) - string(REPLACE " " "\ " _VCPKG_INSTALLED_PKGCONF ${CURRENT_INSTALLED_DIR}) - string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_INSTALLED_PKGCONF ${_VCPKG_INSTALLED_PKGCONF}) - string(REPLACE "\\" "/" _VCPKG_INSTALLED_PKGCONF ${_VCPKG_INSTALLED_PKGCONF}) + set(prefix_var "'\${prefix}'") # Windows needs extra quotes or else the variable gets expanded in the makefile! + + list(APPEND _csc_OPTIONS gl_cv_double_slash_root=yes + ac_cv_func_memmove=yes) else() string(REPLACE " " "\ " _VCPKG_PREFIX ${CURRENT_INSTALLED_DIR}) string(REPLACE " " "\ " _VCPKG_INSTALLED ${CURRENT_INSTALLED_DIR}) @@ -418,7 +467,6 @@ function(vcpkg_configure_make) if(VCPKG_TARGET_IS_WINDOWS) _vcpkg_backup_env_variables(_CL_ _LINK_) # TODO: Should be CPP flags instead -> rewrite when vcpkg_determined_cmake_compiler_flags defined - #string(APPEND CPP_FLAGS_GLOBAL " /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN /DWIN32 /D_WINDOWS") if(VCPKG_TARGET_IS_UWP) # Be aware that configure thinks it is crosscompiling due to: # error while loading shared libraries: VCRUNTIME140D_APP.dll: @@ -427,27 +475,26 @@ function(vcpkg_configure_make) # is to use the CL and LINK environment variables !!! # (This is due to libtool and compiler wrapper using the same set of options to pass those variables around) string(REPLACE "\\" "/" VCToolsInstallDir "$ENV{VCToolsInstallDir}") - set(ENV{_CL_} "$ENV{_CL_} /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB_ -FU\"${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\"") - set(ENV{_LINK_} "$ENV{_LINK_} /MANIFEST /DYNAMICBASE /WINMD:NO /APPCONTAINER") + # Can somebody please check if CMake's compiler flags for UWP are correct? + #set(ENV{_CL_} "$ENV{_CL_} /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB_ -FU\"${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\"") + #string(APPEND VCPKG_DETECTED_COMBINED_CXXFLAGS_RELEASE " -ZW:nostdlib") + #string(APPEND VCPKG_DETECTED_COMBINED_CXXFLAGS_DEBUG " -ZW:nostdlib") + #set(ENV{_LINK_} "$ENV{_LINK_} ${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES} /MANIFEST /DYNAMICBASE /WINMD:NO ") + set(ENV{_LINK_} "$ENV{_LINK_} ${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES} /APPCONTAINER") endif() - set(ENV{_LINK_} "${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES}") - else() - set(ENV{LIBS} "$ENV{LIBS} ${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES}") endif() - - if(NOT ENV{PKG_CONFIG}) - find_program(PKGCONFIG pkg-config PATHS "${MSYS_ROOT}/usr/bin" REQUIRED) - debug_message("Using pkg-config from: ${PKGCONFIG}") - if(NOT PKGCONFIG) - message(STATUS "${PORT} requires pkg-config from the system package manager (example: \"sudo apt-get install pkg-config\")") - endif() + + if(DEFINED ENV{LIBS}) + set(ENV{LIBS} "$ENV{LIBS} ${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES}") else() - debug_message("ENV{PKG_CONFIG} found! Using: $ENV{PKG_CONFIG}") - set(PKGCONFIG $ENV{PKG_CONFIG}) + set(ENV{LIBS} "${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES}") endif() + + vcpkg_find_acquire_program(PKGCONFIG) if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" AND NOT PKGCONFIG STREQUAL "--static") set(PKGCONFIG "${PKGCONFIG} --static") endif() + # Run autoconf if necessary set(_GENERATED_CONFIGURE FALSE) if (_csc_AUTOCONFIG OR REQUIRES_AUTOCONFIG) @@ -506,30 +553,6 @@ function(vcpkg_configure_make) ) endif() - macro(extract_cpp_flags_and_set_cflags_and_cxxflags) - string(REGEX MATCHALL "( |^)-[^ ]+" CPPFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") - string(REGEX MATCHALL "( |^)-[^ ]+" CXXPPFLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_VAR_SUFFIX}}") - list(JOIN CXXPPFLAGS_${_VAR_SUFFIX} "|" CXXREGEX) - if(CXXREGEX) - list(FILTER CPPFLAGS_${_VAR_SUFFIX} INCLUDE REGEX "(${CXXREGEX})") - else() - set(CPPFLAGS_${_VAR_SUFFIX}) - endif() - list(JOIN CPPFLAGS_${_VAR_SUFFIX} "|" CPPREGEX) - list(JOIN CPPFLAGS_${_VAR_SUFFIX} " " CPPFLAGS_${_VAR_SUFFIX}) - set(CPPFLAGS_${_VAR_SUFFIX} " ${CPPFLAGS_${_VAR_SUFFIX}}") - if(CPPREGEX) - string(REGEX REPLACE "(${CPPREGEX})" "" CFLAGS_${_VAR_SUFFIX} " ${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") - string(REGEX REPLACE "(${CPPREGEX})" "" CXXFLAGS_${_VAR_SUFFIX} " ${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_VAR_SUFFIX}}") - else() - set(CFLAGS_${_VAR_SUFFIX} " ${VCPKG_DETECTED_COMBINED_CFLAGS_${_VAR_SUFFIX}}") - set(CXXFLAGS_${_VAR_SUFFIX} " ${VCPKG_DETECTED_COMBINED_CXXFLAGS_${_VAR_SUFFIX}}") - endif() - debug_message("CPPFLAGS_${_VAR_SUFFIX}: ${CPPFLAGS_${_VAR_SUFFIX}}") - debug_message("CFLAGS_${_VAR_SUFFIX}: ${CFLAGS_${_VAR_SUFFIX}}") - debug_message("CXXFLAGS_${_VAR_SUFFIX}: ${CXXFLAGS_${_VAR_SUFFIX}}") - endmacro() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" AND NOT _csc_NO_DEBUG) set(_VAR_SUFFIX DEBUG) set(PATH_SUFFIX_${_VAR_SUFFIX} "/debug") @@ -540,12 +563,16 @@ function(vcpkg_configure_make) else() # dynamic set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_SHARED_LINKERFLAGS_${_VAR_SUFFIX}}") endif() - extract_cpp_flags_and_set_cflags_and_cxxflags() + extract_cpp_flags_and_set_cflags_and_cxxflags(${_VAR_SUFFIX}) if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_C_COMPILER MATCHES "cl.exe") - set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/") - set(LINK_ENV_${_VAR_SUFFIX} "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") + if(DEFINED ENV{_LINK_}) + set(LINK_ENV_${_VAR_SUFFIX} "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}") + else() + set(LINK_ENV_${_VAR_SUFFIX} "${LINKER_FLAGS_${_VAR_SUFFIX}}") + endif() else() - set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/ ${LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link ${LINKER_FLAGS_${_VAR_SUFFIX}}") endif() unset(_VAR_SUFFIX) endif() @@ -559,10 +586,14 @@ function(vcpkg_configure_make) else() # dynamic set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_SHARED_LINKERFLAGS_${_VAR_SUFFIX}}") endif() - extract_cpp_flags_and_set_cflags_and_cxxflags() + extract_cpp_flags_and_set_cflags_and_cxxflags(${_VAR_SUFFIX}) if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_C_COMPILER MATCHES "cl.exe") - set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/") - set(LINK_ENV_${_VAR_SUFFIX} "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}") + set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") + if(DEFINED ENV{_LINK_}) + set(LINK_ENV_${_VAR_SUFFIX} "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}") + else() + set(LINK_ENV_${_VAR_SUFFIX} "${LINKER_FLAGS_${_VAR_SUFFIX}}") + endif() else() set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/ -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link/ ${LINKER_FLAGS_${_VAR_SUFFIX}}") endif() @@ -586,23 +617,24 @@ function(vcpkg_configure_make) set(RELATIVE_BUILD_PATH .) endif() - set(PKGCONFIG_INSTALLED_DIR "${_VCPKG_INSTALLED_PKGCONF}${PATH_SUFFIX_${_buildtype}}/lib/pkgconfig") - set(PKGCONFIG_INSTALLED_SHARE_DIR "${_VCPKG_INSTALLED_PKGCONF}/share/pkgconfig") - + # Setup PKG_CONFIG_PATH + set(PKGCONFIG_INSTALLED_DIR "${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_buildtype}}/lib/pkgconfig") + set(PKGCONFIG_INSTALLED_SHARE_DIR "${CURRENT_INSTALLED_DIR}/share/pkgconfig") if(ENV{PKG_CONFIG_PATH}) set(BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype} $ENV{PKG_CONFIG_PATH}) - set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}:${PKGCONFIG_INSTALLED_SHARE_DIR}:$ENV{PKG_CONFIG_PATH}") + set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}${VCPKG_HOST_PATH_SEPARATOR}${PKGCONFIG_INSTALLED_SHARE_DIR}${VCPKG_HOST_PATH_SEPARATOR}$ENV{PKG_CONFIG_PATH}") else() - set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}:${PKGCONFIG_INSTALLED_SHARE_DIR}") + set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_INSTALLED_DIR}${VCPKG_HOST_PATH_SEPARATOR}${PKGCONFIG_INSTALLED_SHARE_DIR}") endif() # Setup environment - set(ENV{CPPFLAGS} ${CPPFLAGS_${_buildtype}}) - set(ENV{CFLAGS} ${CFLAGS_${_buildtype}}) - set(ENV{CXXFLAGS} ${CXXFLAGS_${_buildtype}}) - set(ENV{LDFLAGS} ${LDFLAGS_${_buildtype}}) + set(ENV{CPPFLAGS} "${CPPFLAGS_${_buildtype}}") + set(ENV{CFLAGS} "${CFLAGS_${_buildtype}}") + set(ENV{CXXFLAGS} "${CXXFLAGS_${_buildtype}}") + set(ENV{RCFLAGS} "${VCPKG_DETECTED_COMBINED_RCFLAGS_${_buildtype}}") + set(ENV{LDFLAGS} "${LDFLAGS_${_buildtype}}") if(LINK_ENV_${_VAR_SUFFIX}) - _vcpkg_backup_env_variables(_LINK_) + set(_LINK_CONFIG_BACKUP "$ENV{_LINK_}") set(ENV{_LINK_} "${LINK_ENV_${_VAR_SUFFIX}}") endif() set(ENV{PKG_CONFIG} "${PKGCONFIG} --define-variable=prefix=${_VCPKG_INSTALLED}${PATH_SUFFIX_${_buildtype}}") @@ -622,6 +654,9 @@ function(vcpkg_configure_make) vcpkg_add_to_path("${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_buildtype}}/bin") endif() debug_message("Configure command:'${command}'") + # foreach(_envar IN LISTS printvars) + # message(STATUS "ENV{${_envar}} : '$ENV{${_envar}}'") + # endforeach() if (NOT _csc_SKIP_CONFIGURE) message(STATUS "Configuring ${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}") vcpkg_execute_required_process( @@ -629,11 +664,13 @@ function(vcpkg_configure_make) WORKING_DIRECTORY "${TAR_DIR}" LOGNAME config-${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}} ) - if(EXISTS "${TAR_DIR}/libtool" AND VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - set(_file "${TAR_DIR}/libtool") - file(READ "${_file}" _contents) - string(REPLACE ".dll.lib" ".lib" _contents "${_contents}") - file(WRITE "${_file}" "${_contents}") + if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + file(GLOB_RECURSE LIBTOOL_FILES "${TAR_DIR}*/libtool") + foreach(lt_file IN LISTS LIBTOOL_FILES) + file(READ "${lt_file}" _contents) + string(REPLACE ".dll.lib" ".lib" _contents "${_contents}") + file(WRITE "${lt_file}" "${_contents}") + endforeach() endif() endif() @@ -644,7 +681,10 @@ function(vcpkg_configure_make) endif() unset(BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype}) - _vcpkg_restore_env_variables(_LINK_) + if(_LINK_CONFIG_BACKUP) + set(ENV{_LINK_} "${_LINK_CONFIG_BACKUP}") + unset(_LINK_CONFIG_BACKUP) + endif() if(_csc_ADD_BIN_TO_PATH) set(ENV{PATH} "${PATH_BACKUP}") @@ -661,7 +701,7 @@ function(vcpkg_configure_make) # Restore environment foreach(_prefix IN LISTS FLAGPREFIXES) - _vcpkg_restore_env_variable(${prefix}FLAGS) + _vcpkg_restore_env_variable(${_prefix}FLAGS) endforeach() _vcpkg_restore_env_variables(LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) From b26f1869ce0fc18b8970aa6052db5c3c9dcc25a5 Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Thu, 20 Aug 2020 10:54:26 +0200 Subject: [PATCH 10/34] Apply suggestions from code review Co-authored-by: nicole mazzuca --- scripts/cmake/vcpkg_get_cmake_vars.cmake | 3 +-- scripts/get_cmake_vars/CMakeLists.txt | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/cmake/vcpkg_get_cmake_vars.cmake b/scripts/cmake/vcpkg_get_cmake_vars.cmake index 7b1925a08dcd09..f26c0a8b3dbec2 100644 --- a/scripts/cmake/vcpkg_get_cmake_vars.cmake +++ b/scripts/cmake/vcpkg_get_cmake_vars.cmake @@ -1,7 +1,6 @@ ## # vcpkg_get_cmake_vars ## ## Runs a cmake configure with a dummy project to extract certain cmake variables -## This function is mostliy ## ## ## Usage ## ```cmake @@ -61,4 +60,4 @@ function(vcpkg_get_cmake_vars) endif() file(RENAME "${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}${LOGSUFFIX}-out.log" "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}-out.log") file(RENAME "${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}${LOGSUFFIX}-err.log" "${CURRENT_BUILDTREES_DIR}/get-cmake-vars-${TARGET_TRIPLET}-err.log") -endfunction() \ No newline at end of file +endfunction() diff --git a/scripts/get_cmake_vars/CMakeLists.txt b/scripts/get_cmake_vars/CMakeLists.txt index dab84f4bc081f3..4c53bcdc00a495 100644 --- a/scripts/get_cmake_vars/CMakeLists.txt +++ b/scripts/get_cmake_vars/CMakeLists.txt @@ -94,8 +94,8 @@ file(WRITE "${VCPKG_OUTPUT_FILE}" "${OUTPUT_STRING}") # Programs: # CMAKE_AR # CMAKE__COMPILER_AR (Wrapper) -# CMAKE_RANLIB¶ -# CMAKE__COMPILER_RANLIB¶ +# CMAKE_RANLIB +# CMAKE__COMPILER_RANLIB # CMAKE_STRIP # CMAKE_NM # CMAKE_OBJDUMP @@ -105,7 +105,7 @@ file(WRITE "${VCPKG_OUTPUT_FILE}" "${OUTPUT_STRING}") # CMAKE_C_COMPILER # CMAKE_CXX_COMPILER -# CMAKE_RC_COMPILER <-- +# CMAKE_RC_COMPILER # CMAKE_RC_FLAGS # Flags: @@ -113,6 +113,6 @@ file(WRITE "${VCPKG_OUTPUT_FILE}" "${OUTPUT_STRING}") # CMAKE__FLAGS_ # CMAKE_SHARED_LINKER_FLAGS # CMAKE_STATIC_LINKER_FLAGS -# CMAKE_STATIC_LINKER_FLAGS_. +# CMAKE_STATIC_LINKER_FLAGS_ # CMAKE_EXE_LINKER_FLAGS -# CMAKE_EXE_LINKER_FLAGS_ (CMAKE_C_FLAGS_) +# CMAKE_EXE_LINKER_FLAGS_ From ec357c29f1fc4b37733c8078108d16dc9d149c59 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 20 Aug 2020 10:59:32 +0200 Subject: [PATCH 11/34] cleanup docs --- scripts/cmake/vcpkg_get_cmake_vars.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/cmake/vcpkg_get_cmake_vars.cmake b/scripts/cmake/vcpkg_get_cmake_vars.cmake index f26c0a8b3dbec2..5ea9bc233fb572 100644 --- a/scripts/cmake/vcpkg_get_cmake_vars.cmake +++ b/scripts/cmake/vcpkg_get_cmake_vars.cmake @@ -15,14 +15,14 @@ ## Additional options to pass to the test configure call ## ## ### OUTPUT_FILE -## Variable to hold the +## Variable to return the path to the generated cmake file with the detected `CMAKE_` variables set as `VCKPG_DETECTED_` ## ## ## Notes -## This command will either alter the settings for `VCPKG_LIBRARY_LINKAGE` or fail, depending on what was requested by the user versus what the library supports. +## If possible avoid usage in portfiles. ## ## ## Examples ## -## * [libimobiledevice](https://github.com/Microsoft/vcpkg/blob/master/ports/libimobiledevice/portfile.cmake) +## * [vcpkg_configure_make](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_configure_make.cmake) function(vcpkg_get_cmake_vars) cmake_parse_arguments(PARSE_ARGV 0 _gcv "" "OUTPUT_FILE" "OPTIONS") From 7c440bdd8fbfebd7643299b1a74ddd857851f3e8 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 21 Aug 2020 22:30:07 +0200 Subject: [PATCH 12/34] add conversion from somelib.lib to -lsomelib --- scripts/cmake/vcpkg_configure_make.cmake | 34 +++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index d214c761edd15f..aba2c5685e1c73 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -401,6 +401,9 @@ function(vcpkg_configure_make) list(APPEND _csc_OPTIONS gl_cv_double_slash_root=yes ac_cv_func_memmove=yes) + if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") + list(APPEND _csc_OPTIONS gl_cv_host_cpu_c_abi=no) + endif() else() string(REPLACE " " "\ " _VCPKG_PREFIX ${CURRENT_INSTALLED_DIR}) string(REPLACE " " "\ " _VCPKG_INSTALLED ${CURRENT_INSTALLED_DIR}) @@ -476,18 +479,31 @@ function(vcpkg_configure_make) # (This is due to libtool and compiler wrapper using the same set of options to pass those variables around) string(REPLACE "\\" "/" VCToolsInstallDir "$ENV{VCToolsInstallDir}") # Can somebody please check if CMake's compiler flags for UWP are correct? - #set(ENV{_CL_} "$ENV{_CL_} /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB_ -FU\"${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\"") - #string(APPEND VCPKG_DETECTED_COMBINED_CXXFLAGS_RELEASE " -ZW:nostdlib") - #string(APPEND VCPKG_DETECTED_COMBINED_CXXFLAGS_DEBUG " -ZW:nostdlib") - #set(ENV{_LINK_} "$ENV{_LINK_} ${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES} /MANIFEST /DYNAMICBASE /WINMD:NO ") - set(ENV{_LINK_} "$ENV{_LINK_} ${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES} /APPCONTAINER") + set(ENV{_CL_} "$ENV{_CL_} /D_UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB_ -FU\"${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\"") + string(APPEND VCPKG_DETECTED_COMBINED_CXXFLAGS_RELEASE " -ZW:nostdlib") + string(APPEND VCPKG_DETECTED_COMBINED_CXXFLAGS_DEBUG " -ZW:nostdlib") + set(ENV{_LINK_} "$ENV{_LINK_} ${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES} /MANIFEST /DYNAMICBASE /WINMD:NO /APPCONTAINER") endif() endif() - if(DEFINED ENV{LIBS}) - set(ENV{LIBS} "$ENV{LIBS} ${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES}") - else() - set(ENV{LIBS} "${VCPKG_DETECTED_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CXX_STANDARD_LIBRARIES}") + macro(convert_to_list input output) + string(REGEX MATCHALL "(( +|$ *)[^ ]+)" ${output} "${${input}}") + endmacro() + convert_to_list(VCPKG_DETECTED_C_STANDARD_LIBRARIES C_LIBS_LIST) + convert_to_list(VCPKG_DETECTED_CXX_STANDARD_LIBRARIES CXX_LIBS_LIST) + set(ALL_LIBS_LIST ${C_LIBS_LIST} ${CXX_LIBS_LIST}) + + list(REMOVE_DUPLICATES ALL_LIBS_LIST) + list(TRANSFORM ALL_LIBS_LIST STRIP) + list(TRANSFORM ALL_LIBS_LIST REPLACE "(.lib|.a|.so)$" "") + list(JOIN ALL_LIBS_LIST " -l" ALL_LIBS_STRING) + + if(ALL_LIBS_STRING) + if(DEFINED ENV{LIBS}) + set(ENV{LIBS} "$ENV{LIBS} -l${ALL_LIBS_STRING}") + else() + set(ENV{LIBS} "-l${ALL_LIBS_STRING}") + endif() endif() vcpkg_find_acquire_program(PKGCONFIG) From 8b20a58ad77058fdac9a3877e69313bd3e9a9d49 Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Sat, 22 Aug 2020 18:52:50 +0200 Subject: [PATCH 13/34] add missing ar-lib wrapper --- scripts/cmake/vcpkg_configure_make.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index aba2c5685e1c73..9fb7bd11babf63 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -338,7 +338,7 @@ function(vcpkg_configure_make) _vcpkg_append_to_configure_environment(CONFIGURE_ENV RC "windres-rc ${VCPKG_DETECTED_RC_COMPILER}") _vcpkg_append_to_configure_environment(CONFIGURE_ENV WINDRES "windres-rc ${VCPKG_DETECTED_RC_COMPILER}") if(VCPKG_DETECTED_AR) - _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "${VCPKG_DETECTED_AR}") + _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "ar-lib ${VCPKG_DETECTED_AR}") else() _vcpkg_append_to_configure_environment(CONFIGURE_ENV AR "ar-lib lib.exe -verbose") endif() From 8e276957f3e311d8027ba84a95a6fbce4145761e Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Sat, 22 Aug 2020 19:58:31 +0200 Subject: [PATCH 14/34] small but important regex correction --- scripts/cmake/vcpkg_configure_make.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index 9fb7bd11babf63..d02061e9186059 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -487,7 +487,8 @@ function(vcpkg_configure_make) endif() macro(convert_to_list input output) - string(REGEX MATCHALL "(( +|$ *)[^ ]+)" ${output} "${${input}}") + string(REGEX MATCHALL "(( +|^ *)[^ ]+)" ${output} "${${input}}") + endmacro() convert_to_list(VCPKG_DETECTED_C_STANDARD_LIBRARIES C_LIBS_LIST) convert_to_list(VCPKG_DETECTED_CXX_STANDARD_LIBRARIES CXX_LIBS_LIST) From 7b40bf34584abae84e96f50122468099ca07d6d9 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 24 Aug 2020 09:47:16 +0200 Subject: [PATCH 15/34] add latest changes from update_fontconfig PR --- scripts/cmake/vcpkg_build_make.cmake | 7 +++++-- scripts/cmake/vcpkg_configure_make.cmake | 11 ++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index 29b5191af0d285..b4a30c705b94c6 100644 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -27,6 +27,9 @@ ## ### DISABLE_PARALLEL ## The underlying buildsystem will be instructed to not parallelize ## +## ### WORKING_SUBDIR +## Additional subdir to invoke make in. Useful if only parts of a port should be built. +## ## ## Notes: ## 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 @@ -40,7 +43,7 @@ ## * [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake) function(vcpkg_build_make) include("${CMAKE_VARS_FILE}") - 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;WORKING_SUBDIR" "") if(NOT _bc_LOGFILE_ROOT) set(_bc_LOGFILE_ROOT "build") @@ -108,7 +111,7 @@ function(vcpkg_build_make) set(PATH_SUFFIX "") endif() - set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}") + set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}${_bc_WORKING_SUBDIR}") message(STATUS "Building ${TARGET_TRIPLET}${SHORT_BUILDTYPE}") extract_cpp_flags_and_set_cflags_and_cxxflags(${CMAKE_BUILDTYPE}) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index d02061e9186059..ab05d7f53338a2 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -367,6 +367,7 @@ function(vcpkg_configure_make) _vcpkg_append_to_configure_environment(CONFIGURE_ENV STRIP "${VCPKG_DETECTED_STRIP}") else() _vcpkg_append_to_configure_environment(CONFIGURE_ENV STRIP ":") + list(APPEND _csc_OPTIONS ac_cv_prog_ac_ct_STRIP=:) endif() if(VCPKG_DETECTED_NM) # If required set the ENV variable NM in the portfile correctly _vcpkg_append_to_configure_environment(CONFIGURE_ENV NM "${VCPKG_DETECTED_NM}") @@ -385,7 +386,7 @@ function(vcpkg_configure_make) foreach(_env IN LISTS _csc_CONFIGURE_ENVIRONMENT_VARIABLES) _vcpkg_append_to_configure_environment(CONFIGURE_ENV ${_env} "${${_env}}") endforeach() - + debug_message("CONFIGURE_ENV: '${CONFIGURE_ENV}'") # Other maybe interesting variables to control # COMPILE This is the command used to actually compile a C source file. The file name is appended to form the complete command line. # LINK This is the command used to actually link a C program. @@ -488,7 +489,6 @@ function(vcpkg_configure_make) macro(convert_to_list input output) string(REGEX MATCHALL "(( +|^ *)[^ ]+)" ${output} "${${input}}") - endmacro() convert_to_list(VCPKG_DETECTED_C_STANDARD_LIBRARIES C_LIBS_LIST) convert_to_list(VCPKG_DETECTED_CXX_STANDARD_LIBRARIES CXX_LIBS_LIST) @@ -497,6 +497,9 @@ function(vcpkg_configure_make) list(REMOVE_DUPLICATES ALL_LIBS_LIST) list(TRANSFORM ALL_LIBS_LIST STRIP) list(TRANSFORM ALL_LIBS_LIST REPLACE "(.lib|.a|.so)$" "") + if(VCPKG_TARGET_IS_WINDOWS) + list(REMOVE_ITEM ALL_LIBS_LIST "uuid") + endif() list(JOIN ALL_LIBS_LIST " -l" ALL_LIBS_STRING) if(ALL_LIBS_STRING) @@ -506,7 +509,7 @@ function(vcpkg_configure_make) set(ENV{LIBS} "-l${ALL_LIBS_STRING}") endif() endif() - + debug_message(STATUS "ENV{LIBS}:$ENV{LIBS}") vcpkg_find_acquire_program(PKGCONFIG) if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" AND NOT PKGCONFIG STREQUAL "--static") set(PKGCONFIG "${PKGCONFIG} --static") @@ -689,6 +692,8 @@ function(vcpkg_configure_make) file(WRITE "${lt_file}" "${_contents}") endforeach() endif() + + file(RENAME "${TAR_DIR}/config.log" "${CURRENT_BUILDTREES_DIR}/config.log-${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}.log") endif() if(BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype}) From c249d191b15ab2946391086c53649e14f588c280 Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Fri, 2 Oct 2020 22:21:45 +0200 Subject: [PATCH 16/34] Apply suggestions from code review first set which don't need special attention Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com> --- scripts/cmake/vcpkg_build_make.cmake | 11 ++--------- scripts/cmake/vcpkg_get_cmake_vars.cmake | 1 + 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index cc78bd74de8d91..d69ec271d81846 100644 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -43,7 +43,7 @@ ## * [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake) function(vcpkg_build_make) include("${CMAKE_VARS_FILE}") - cmake_parse_arguments(PARSE_ARGV 0 _bc "ADD_BIN_TO_PATH;ENABLE_INSTALL;DISABLE_PARALLEL" "LOGFILE_ROOT;BUILD_TARGET;WORKING_SUBDIR" "") + 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) set(_bc_LOGFILE_ROOT "build") @@ -128,7 +128,7 @@ function(vcpkg_build_make) 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 + # Setup environment set(ENV{CPPFLAGS} "${CPPFLAGS_${CMAKE_BUILDTYPE}}") set(ENV{CFLAGS} "${CFLAGS_${CMAKE_BUILDTYPE}}") set(ENV{CXXFLAGS} "${CXXFLAGS_${CMAKE_BUILDTYPE}}") @@ -157,10 +157,6 @@ function(vcpkg_build_make) set(NO_PARALLEL_MAKE_CMD_LINE ${MAKE_COMMAND} ${NO_PARALLEL_MAKE_OPTS}) endif() - # foreach(_envar IN LISTS printvars) - # message(STATUS "ENV{${_envar}} : '$ENV{${_envar}}'") - # endforeach() - if (_bc_DISABLE_PARALLEL) vcpkg_execute_build_process( COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE} @@ -183,9 +179,6 @@ function(vcpkg_build_make) else() set(MAKE_CMD_LINE ${MAKE_COMMAND} ${INSTALL_OPTS}) endif() - # foreach(_envar IN LISTS printvars) - # message(STATUS "ENV{${_envar}} : '$ENV{${_envar}}'") - # endforeach() vcpkg_execute_build_process( COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE} WORKING_DIRECTORY "${WORKING_DIRECTORY}" diff --git a/scripts/cmake/vcpkg_get_cmake_vars.cmake b/scripts/cmake/vcpkg_get_cmake_vars.cmake index 5ea9bc233fb572..d93f396532eb3b 100644 --- a/scripts/cmake/vcpkg_get_cmake_vars.cmake +++ b/scripts/cmake/vcpkg_get_cmake_vars.cmake @@ -1,5 +1,6 @@ ## # vcpkg_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 From b457f4a81dfb4b1ec0b42fca86f984107074b32e Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Fri, 2 Oct 2020 22:31:53 +0200 Subject: [PATCH 17/34] Apply suggestions from code review one more simple change Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com> --- scripts/cmake/vcpkg_configure_make.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index 9bcdd7269cfc9a..6e086560a82043 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -653,9 +653,6 @@ function(vcpkg_configure_make) vcpkg_add_to_path("${CURRENT_INSTALLED_DIR}${PATH_SUFFIX_${_buildtype}}/bin") endif() debug_message("Configure command:'${command}'") - # foreach(_envar IN LISTS printvars) - # message(STATUS "ENV{${_envar}} : '$ENV{${_envar}}'") - # endforeach() if (NOT _csc_SKIP_CONFIGURE) message(STATUS "Configuring ${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}") vcpkg_execute_required_process( From 7b281010ef9f9fc282b1ac7c701bc00336e95f57 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 13 Oct 2020 17:03:19 +0200 Subject: [PATCH 18/34] [x264] set env AS --- ports/x264/CONTROL | 2 +- ports/x264/portfile.cmake | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/x264/CONTROL b/ports/x264/CONTROL index ce64f5f7c4f49a..15e35036a06430 100644 --- a/ports/x264/CONTROL +++ b/ports/x264/CONTROL @@ -1,6 +1,6 @@ Source: x264 Version: 157-303c484ec828ed0 -Port-Version: 12 +Port-Version: 13 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 Build-Depends: pthread (linux&osx) diff --git a/ports/x264/portfile.cmake b/ports/x264/portfile.cmake index d2084978cba935..5c716f0d1b4b1a 100644 --- a/ports/x264/portfile.cmake +++ b/ports/x264/portfile.cmake @@ -21,6 +21,7 @@ if(VCPKG_TARGET_IS_WINDOWS) _vcpkg_determine_autotools_target_cpu(HOST_ARCH) list(APPEND OPTIONS --build=${BUILD_ARCH}-pc-mingw32) list(APPEND OPTIONS --host=${HOST_ARCH}-pc-mingw32) + set(ENV{AS} "${NASM}") endif() if(VCPKG_TARGET_IS_UWP) From c04024617ca14247180fa372827bb1c4e4cffb62 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 16 Oct 2020 00:01:39 +0200 Subject: [PATCH 19/34] fix bugs due to refactor --- scripts/cmake/vcpkg_get_cmake_vars.cmake | 1 + scripts/get_cmake_vars/CMakeLists.txt | 44 +++++++++++------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/scripts/cmake/vcpkg_get_cmake_vars.cmake b/scripts/cmake/vcpkg_get_cmake_vars.cmake index 33f405f98e0d5b..62b197eba90b91 100644 --- a/scripts/cmake/vcpkg_get_cmake_vars.cmake +++ b/scripts/cmake/vcpkg_get_cmake_vars.cmake @@ -43,6 +43,7 @@ function(vcpkg_get_cmake_vars) set(DEFAULT_OUT "${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}.cmake.log") # So that the file gets included in CI artifacts. list(APPEND _gcv_OPTIONS "-DVCPKG_OUTPUT_FILE:PATH=${DEFAULT_OUT}") set(${_gcv_OUTPUT_FILE} "${DEFAULT_OUT}" PARENT_SCOPE) + set(${_gcv_OUTPUT_FILE} "${DEFAULT_OUT}") endif() vcpkg_configure_cmake( diff --git a/scripts/get_cmake_vars/CMakeLists.txt b/scripts/get_cmake_vars/CMakeLists.txt index 00e0690ebdaa79..c45cf68205434d 100644 --- a/scripts/get_cmake_vars/CMakeLists.txt +++ b/scripts/get_cmake_vars/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.17) -set(OUTPUT_STRING) +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 @@ -39,13 +40,12 @@ 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}) -endforeach + 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_LANGUAGES "C;CXX" CACHE STRING "Languages to enables for this project") set(VCPKG_VAR_PREFIX "VCPKG_DETECTED" CACHE STRING "Variable prefix to use for detected flags") set(VCPKG_OUTPUT_FILE "${CMAKE_BINARY_DIR}/../detected_flags.cmake.${VCPKG_TARGET_TRIPLET}.log" CACHE STRING "Output CMake files") set(VCPKG_VARS_TO_CHECK "${VCPKG_DEFAULT_VARS_TO_CHECK}" CACHE STRING "Variables to check. If not given there is a list of defaults") @@ -60,24 +60,6 @@ endif() project(get_cmake_vars LANGUAGES ${VCPKG_LANGUAGES}) -set(FLAGS ${VCPKG_LANGUAGES} RC SHARED_LINKER STATIC_LINKER EXE_LINKER) -foreach(flag IN LISTS VCPKG_FLAGS_TO_CHECK) - string(REGEX REPLACE " +" " " ${flag} "${${flag}}") - string(REGEX REPLACE "( |^)/" "\\1-" ${flag} "${${flag}}") - string(STRIP "${${flag}}" ${flag}) - string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag} \" ${${flag}}\")\n") - foreach(config IN LISTS VCPKG_CONFIGS) - string(REGEX REPLACE " +" " " ${flag}_${config} "${${flag}_${config}}") - string(REGEX REPLACE "( |^)/" "\\1-" ${flag}_${config} "${${flag}_${config}}") - string(STRIP "${${flag}_${config}}" ${flag}_${config}) - string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag}_${config} \"${CMAKE_${flag}_FLAGS_${config}}\")\n") - set(COMBINED_${flag}_${config} "${${flag}} ${${flag}_${config}}") - string(REGEX REPLACE " +" " " COMBINED_${flag}_${config} "${COMBINED_${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() - # These seem to be empty. # set(add_props INCLUDE_DIRECTORIES COMPILE_DEFINITIONS COMPILE_OPTIONS LINK_DIRECTORIES LINK_OPTIONS) # foreach(prop IN LISTS add_props) @@ -90,7 +72,7 @@ endforeach() # endforeach() foreach(VAR IN LISTS VCPKG_VARS_TO_CHECK) - string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${VAR} \"${${VAR}}\"\n") + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${VAR} \"${${VAR}}\")\n") endforeach() foreach(_env IN LISTS VCPKG_ENV_VARS_TO_CHECK) @@ -102,6 +84,22 @@ foreach(_env IN LISTS VCPKG_ENV_VARS_TO_CHECK) endif() endforeach() +foreach(flag IN LISTS VCPKG_FLAGS_TO_CHECK) + string(REGEX REPLACE " +" " " ${flag} "${${flag}}") + string(REGEX REPLACE "( |^)/" "\\1-" ${flag} "${${flag}}") + string(STRIP "${${flag}}" ${flag}) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag} \" ${${flag}}\")\n") + foreach(config IN LISTS VCPKG_CONFIGS) + string(REGEX REPLACE " +" " " ${flag}_${config} "${${flag}_${config}}") + string(REGEX REPLACE "( |^)/" "\\1-" ${flag}_${config} "${${flag}_${config}}") + string(STRIP "${${flag}_${config}}" ${flag}_${config}) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag}_${config} \"${CMAKE_${flag}_FLAGS_${config}}\")\n") + set(COMBINED_${flag}_${config} "${${flag}} ${${flag}_${config}}") + string(REGEX REPLACE " +" " " COMBINED_${flag}_${config} "${COMBINED_${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}") From 28a4b38ac6ab00de770c82c770910c6daa628a9c Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 16 Oct 2020 00:03:58 +0200 Subject: [PATCH 20/34] use subpath everywhere --- scripts/cmake/vcpkg_build_make.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index 4b9c46d3e86c17..f67cfd4344f40e 100644 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -27,7 +27,7 @@ ## ### DISABLE_PARALLEL ## The underlying buildsystem will be instructed to not parallelize ## -## ### WORKING_SUBDIR +## ### SUBPATH ## Additional subdir to invoke make in. Useful if only parts of a port should be built. ## ## ## Notes: @@ -112,7 +112,7 @@ function(vcpkg_build_make) set(PATH_SUFFIX "") endif() - set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}${_bc_WORKING_SUBDIR}") + set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}${_bc_SUBPATH}") message(STATUS "Building ${TARGET_TRIPLET}${SHORT_BUILDTYPE}") extract_cpp_flags_and_set_cflags_and_cxxflags(${CMAKE_BUILDTYPE}) From ae93df4e5b6d75833befd5b141693cc952d13c33 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 16 Oct 2020 00:11:53 +0200 Subject: [PATCH 21/34] apply changes from CR --- scripts/get_cmake_vars/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/get_cmake_vars/CMakeLists.txt b/scripts/get_cmake_vars/CMakeLists.txt index c45cf68205434d..e22b356aeb17ba 100644 --- a/scripts/get_cmake_vars/CMakeLists.txt +++ b/scripts/get_cmake_vars/CMakeLists.txt @@ -47,11 +47,14 @@ 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_OUTPUT_FILE "${CMAKE_BINARY_DIR}/../detected_flags.cmake.${VCPKG_TARGET_TRIPLET}.log" CACHE STRING "Output CMake files") 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(CMAKE_BUILD_TYPE) string(TOUPPER "${CMAKE_BUILD_TYPE}" VCPKG_CONFIGS) else() From bb12126844d8c2535542e5e444931238d7115a72 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 17 Oct 2020 00:59:24 +0200 Subject: [PATCH 22/34] remove unnecessary lines 41 & 44 --- scripts/cmake/vcpkg_get_cmake_vars.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/cmake/vcpkg_get_cmake_vars.cmake b/scripts/cmake/vcpkg_get_cmake_vars.cmake index 62b197eba90b91..634f90bc1b52ce 100644 --- a/scripts/cmake/vcpkg_get_cmake_vars.cmake +++ b/scripts/cmake/vcpkg_get_cmake_vars.cmake @@ -38,10 +38,8 @@ function(vcpkg_get_cmake_vars) if(${_gcv_OUTPUT_FILE}) debug_message("OUTPUT_FILE ${${_gcv_OUTPUT_FILE}}") - list(APPEND _gcv_OPTIONS "-DVCPKG_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. - list(APPEND _gcv_OPTIONS "-DVCPKG_OUTPUT_FILE:PATH=${DEFAULT_OUT}") set(${_gcv_OUTPUT_FILE} "${DEFAULT_OUT}" PARENT_SCOPE) set(${_gcv_OUTPUT_FILE} "${DEFAULT_OUT}") endif() From 65e71b182261d0b61dda1fcef23083ec1f5eb4fc Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 18 Oct 2020 22:18:50 +0200 Subject: [PATCH 23/34] remove flag transformation --- scripts/get_cmake_vars/CMakeLists.txt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/scripts/get_cmake_vars/CMakeLists.txt b/scripts/get_cmake_vars/CMakeLists.txt index e22b356aeb17ba..1d173e078254ef 100644 --- a/scripts/get_cmake_vars/CMakeLists.txt +++ b/scripts/get_cmake_vars/CMakeLists.txt @@ -58,7 +58,7 @@ endif() if(CMAKE_BUILD_TYPE) string(TOUPPER "${CMAKE_BUILD_TYPE}" VCPKG_CONFIGS) else() - set(VCPKG_CONFIGS "DEBUG;RELEASE") + set(VCPKG_CONFIGS DEBUG RELEASE) endif() project(get_cmake_vars LANGUAGES ${VCPKG_LANGUAGES}) @@ -88,17 +88,12 @@ foreach(_env IN LISTS VCPKG_ENV_VARS_TO_CHECK) endforeach() foreach(flag IN LISTS VCPKG_FLAGS_TO_CHECK) - string(REGEX REPLACE " +" " " ${flag} "${${flag}}") - string(REGEX REPLACE "( |^)/" "\\1-" ${flag} "${${flag}}") - string(STRIP "${${flag}}" ${flag}) + string(STRIP "${${flag}}" ${flag}) # Strip leading and trailing whitespaces string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag} \" ${${flag}}\")\n") foreach(config IN LISTS VCPKG_CONFIGS) - string(REGEX REPLACE " +" " " ${flag}_${config} "${${flag}_${config}}") - string(REGEX REPLACE "( |^)/" "\\1-" ${flag}_${config} "${${flag}_${config}}") string(STRIP "${${flag}_${config}}" ${flag}_${config}) string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag}_${config} \"${CMAKE_${flag}_FLAGS_${config}}\")\n") set(COMBINED_${flag}_${config} "${${flag}} ${${flag}_${config}}") - string(REGEX REPLACE " +" " " COMBINED_${flag}_${config} "${COMBINED_${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() From 723b9d77dbd3051b8769c251310eda483b71a5d5 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 18 Oct 2020 22:33:48 +0200 Subject: [PATCH 24/34] reintroduce the flag / to - transformation for MSVC --- scripts/get_cmake_vars/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/get_cmake_vars/CMakeLists.txt b/scripts/get_cmake_vars/CMakeLists.txt index 1d173e078254ef..3897598817aa10 100644 --- a/scripts/get_cmake_vars/CMakeLists.txt +++ b/scripts/get_cmake_vars/CMakeLists.txt @@ -89,9 +89,15 @@ 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}) From afb500be88e39f05f4c6ae718c78ef5182a490c1 Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Fri, 23 Oct 2020 13:41:11 +0200 Subject: [PATCH 25/34] Apply suggestions from code review Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com> --- scripts/cmake/vcpkg_configure_make.cmake | 3 +-- scripts/get_cmake_vars/CMakeLists.txt | 18 ++++-------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index c8ab79380eb49a..74f759ea31aee1 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -6,7 +6,7 @@ ## ```cmake ## vcpkg_configure_make( ## SOURCE_PATH <${SOURCE_PATH}> -## [AUTOCONFIG] +## [AUTOCONFIG] ## [USE_WRAPPERS] ## [DETERMINE_BUILD_TRIPLET] ## [BUILD_TRIPLET "--host=x64 --build=i686-unknown-pc"] @@ -86,7 +86,6 @@ ## * [tcl](https://github.com/Microsoft/vcpkg/blob/master/ports/tcl/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) -set(printvars PATH _LINK_ _CL_ CPPFLAGS CFLAGS CXXFLAGS LDFLAGS LIBS INCLUDE LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) macro(_vcpkg_determine_host_mingw out_var) if(DEFINED ENV{PROCESSOR_ARCHITEW6432}) diff --git a/scripts/get_cmake_vars/CMakeLists.txt b/scripts/get_cmake_vars/CMakeLists.txt index 3897598817aa10..283f4ef87d6ec6 100644 --- a/scripts/get_cmake_vars/CMakeLists.txt +++ b/scripts/get_cmake_vars/CMakeLists.txt @@ -55,24 +55,14 @@ if(NOT VCPKG_OUTPUT_FILE) message(FATAL_ERROR "VCPKG_OUTPUT_FILE is required to be defined") endif() -if(CMAKE_BUILD_TYPE) - string(TOUPPER "${CMAKE_BUILD_TYPE}" VCPKG_CONFIGS) +if(NOT CMAKE_BUILD_TYPE) + message(FATAL_ERROR "CMAKE_BUILD_TYPE is required to be defined") else() - set(VCPKG_CONFIGS DEBUG RELEASE) + string(TOUPPER "${CMAKE_BUILD_TYPE}" VCPKG_CONFIGS) endif() -project(get_cmake_vars LANGUAGES ${VCPKG_LANGUAGES}) -# These seem to be empty. -# set(add_props INCLUDE_DIRECTORIES COMPILE_DEFINITIONS COMPILE_OPTIONS LINK_DIRECTORIES LINK_OPTIONS) -# foreach(prop IN LISTS add_props) - # get_directory_property(${prop} ${prop}) - # string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${prop} ${${prop}})\n") - # foreach(config IN LISTS VCPKG_CONFIGS) - # get_directory_property(${prop}_${config} ${prop}_${config}) - # string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${prop}_${config} ${${prop}_${config}})\n") - # endforeach() -# endforeach() +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") From 0c5c9939af0eb375b3f7bfb79d5f642f4bb72f3d Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 23 Oct 2020 13:42:32 +0200 Subject: [PATCH 26/34] rename the function --- scripts/cmake/vcpkg_common_functions.cmake | 2 +- scripts/cmake/vcpkg_configure_make.cmake | 2 +- ...ars.cmake => vcpkg_internal_get_cmake_vars.cmake} | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) rename scripts/cmake/{vcpkg_get_cmake_vars.cmake => vcpkg_internal_get_cmake_vars.cmake} (75%) diff --git a/scripts/cmake/vcpkg_common_functions.cmake b/scripts/cmake/vcpkg_common_functions.cmake index 4dfd709bcbdb5f..bc78b322e55867 100644 --- a/scripts/cmake/vcpkg_common_functions.cmake +++ b/scripts/cmake/vcpkg_common_functions.cmake @@ -33,6 +33,7 @@ include(vcpkg_install_msbuild) include(vcpkg_install_make) include(vcpkg_install_nmake) include(vcpkg_install_qmake) +include(vcpkg_internal_get_cmake_vars) include(vcpkg_configure_cmake) include(vcpkg_configure_gn) include(vcpkg_configure_meson) @@ -42,7 +43,6 @@ include(vcpkg_apply_patches) include(vcpkg_copy_pdbs) include(vcpkg_copy_tool_dependencies) include(vcpkg_copy_tools) -include(vcpkg_get_cmake_vars) include(vcpkg_get_program_files_platform_bitness) include(vcpkg_get_windows_sdk) include(vcpkg_replace_string) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index 74f759ea31aee1..ae66f849bb5ce9 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -209,7 +209,7 @@ function(vcpkg_configure_make) "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;CONFIGURE_ENVIRONMENT_VARIABLES;CONFIG_DEPENDENT_ENVIRONMENT" ${ARGN} ) - vcpkg_get_cmake_vars(OUTPUT_FILE CMAKE_VARS_FILE) + vcpkg_internal_get_cmake_vars(OUTPUT_FILE CMAKE_VARS_FILE) set(CMAKE_VARS_FILE "${CMAKE_VARS_FILE}" PARENT_SCOPE) debug_message("Including cmake vars from: ${CMAKE_VARS_FILE}") include("${CMAKE_VARS_FILE}") diff --git a/scripts/cmake/vcpkg_get_cmake_vars.cmake b/scripts/cmake/vcpkg_internal_get_cmake_vars.cmake similarity index 75% rename from scripts/cmake/vcpkg_get_cmake_vars.cmake rename to scripts/cmake/vcpkg_internal_get_cmake_vars.cmake index 634f90bc1b52ce..7cf9f15d1329b6 100644 --- a/scripts/cmake/vcpkg_get_cmake_vars.cmake +++ b/scripts/cmake/vcpkg_internal_get_cmake_vars.cmake @@ -1,11 +1,11 @@ -## # vcpkg_get_cmake_vars +## # 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_get_cmake_vars( +## vcpkg_internal_get_cmake_vars( ## [OUTPUT_FILE ] ## [OPTIONS <-DUSE_THIS_IN_ALL_BUILDS=1>...] ## ) @@ -25,15 +25,15 @@ ## ## * [vcpkg_configure_make](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_configure_make.cmake) -function(vcpkg_get_cmake_vars) +function(vcpkg_internal_get_cmake_vars) cmake_parse_arguments(PARSE_ARGV 0 _gcv "" "OUTPUT_FILE" "OPTIONS") if(_gcv_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "vcpkg_get_cmake_vars was passed unparsed arguments: '${_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 "vcpkg_get_cmake_vars requires parameter OUTPUT_FILE!") + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} requires parameter OUTPUT_FILE!") endif() if(${_gcv_OUTPUT_FILE}) @@ -53,6 +53,6 @@ function(vcpkg_get_cmake_vars) 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)") + 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() From ade65960cea65b141edec1362dcf545a3e73655f Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 23 Oct 2020 13:44:31 +0200 Subject: [PATCH 27/34] rename function/variables --- scripts/cmake/vcpkg_configure_make.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index ae66f849bb5ce9..ef106aa807d9ec 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -167,7 +167,7 @@ macro(_vcpkg_restore_env_variables) endforeach() endmacro() -macro(extract_cpp_flags_and_set_cflags_and_cxxflags _SUFFIX) +macro(_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags _SUFFIX) string(REGEX MATCHALL "( |^)-D[^ ]+" CPPFLAGS_${_SUFFIX} "${VCPKG_DETECTED_CMAKE_C_FLAGS_${_SUFFIX}}") string(REGEX MATCHALL "( |^)-D[^ ]+" CXXPPFLAGS_${_SUFFIX} "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${_SUFFIX}}") list(JOIN CXXPPFLAGS_${_SUFFIX} "|" CXXREGEX) @@ -209,10 +209,10 @@ function(vcpkg_configure_make) "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;CONFIGURE_ENVIRONMENT_VARIABLES;CONFIG_DEPENDENT_ENVIRONMENT" ${ARGN} ) - vcpkg_internal_get_cmake_vars(OUTPUT_FILE CMAKE_VARS_FILE) - set(CMAKE_VARS_FILE "${CMAKE_VARS_FILE}" PARENT_SCOPE) - debug_message("Including cmake vars from: ${CMAKE_VARS_FILE}") - include("${CMAKE_VARS_FILE}") + vcpkg_internal_get_cmake_vars(OUTPUT_FILE _VCPKG_CMAKE_VARS_FILE) + set(_VCPKG_CMAKE_VARS_FILE "${_VCPKG_CMAKE_VARS_FILE}" PARENT_SCOPE) + debug_message("Including cmake vars from: ${_VCPKG_CMAKE_VARS_FILE}") + include("${_VCPKG_CMAKE_VARS_FILE}") if(DEFINED VCPKG_MAKE_BUILD_TRIPLET) set(_csc_BUILD_TRIPLET ${VCPKG_MAKE_BUILD_TRIPLET}) # Triplet overwrite for crosscompiling endif() @@ -558,7 +558,7 @@ function(vcpkg_configure_make) else() # dynamic set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_CMAKE_SHARED_LINKERFLAGS_${_VAR_SUFFIX}}") endif() - extract_cpp_flags_and_set_cflags_and_cxxflags(${_VAR_SUFFIX}) + _vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags(${_VAR_SUFFIX}) if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe") set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") if(DEFINED ENV{_LINK_}) @@ -581,7 +581,7 @@ function(vcpkg_configure_make) else() # dynamic set(LINKER_FLAGS_${_VAR_SUFFIX} "${VCPKG_DETECTED_CMAKE_SHARED_LINKERFLAGS_${_VAR_SUFFIX}}") endif() - extract_cpp_flags_and_set_cflags_and_cxxflags(${_VAR_SUFFIX}) + _vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags(${_VAR_SUFFIX}) if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe") set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") if(DEFINED ENV{_LINK_}) From d48498092fb73c45595a848a47ab1de290334929 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 23 Oct 2020 13:50:36 +0200 Subject: [PATCH 28/34] transform flags list --- scripts/cmake/vcpkg_configure_make.cmake | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index ef106aa807d9ec..2652ec9519aede 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -241,10 +241,10 @@ function(vcpkg_configure_make) debug_message("REQUIRES_AUTOCONFIG:${REQUIRES_AUTOCONFIG}") # Backup environment variables # CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJCXX R UPC Y - set(FLAGPREFIXES CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJXX R UPC Y RC) - foreach(_prefix IN LISTS FLAGPREFIXES) - _vcpkg_backup_env_variable(${prefix}FLAGS) - endforeach() + set(_cm_FLAGS AS CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJXX R UPC Y RC) + list(TRANSFORM _cm_FLAGS APPEND "FLAGS") + _vcpkg_backup_env_variables(${_cm_FLAGS}) + # FC fotran compiler | FF Fortran 77 compiler # LDFLAGS -> pass -L flags @@ -694,11 +694,7 @@ function(vcpkg_configure_make) endforeach() # Restore environment - foreach(_prefix IN LISTS FLAGPREFIXES) - _vcpkg_restore_env_variable(${_prefix}FLAGS) - endforeach() - - _vcpkg_restore_env_variables(LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) + _vcpkg_restore_env_variables(${_cm_FLAGS} LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) SET(_VCPKG_PROJECT_SOURCE_PATH ${_csc_SOURCE_PATH} PARENT_SCOPE) set(_VCPKG_PROJECT_SUBPATH ${_csc_PROJECT_SUBPATH} PARENT_SCOPE) From c5e9724722846c23a750dd6b41063e52395bc8cd Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Fri, 23 Oct 2020 14:10:53 +0200 Subject: [PATCH 29/34] Apply suggestions from code review --- scripts/cmake/vcpkg_configure_make.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index 2652ec9519aede..f375447c918857 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -86,7 +86,6 @@ ## * [tcl](https://github.com/Microsoft/vcpkg/blob/master/ports/tcl/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) - macro(_vcpkg_determine_host_mingw out_var) if(DEFINED ENV{PROCESSOR_ARCHITEW6432}) set(HOST_ARCH $ENV{PROCESSOR_ARCHITEW6432}) @@ -366,7 +365,8 @@ function(vcpkg_configure_make) _vcpkg_append_to_configure_environment(CONFIGURE_ENV DLLTOOL "link.exe -verbose -dll") endif() _vcpkg_append_to_configure_environment(CONFIGURE_ENV CCAS ":") # If required set the ENV variable CCAS in the portfile correctly - _vcpkg_append_to_configure_environment(CONFIGURE_ENV AS ":") # If required set the ENV variable CCAS in the portfile correctly + _vcpkg_append_to_configure_environment(CONFIGURE_ENV AS ":") # If required set the ENV variable AS in the portfile correctly + foreach(_env IN LISTS _csc_CONFIGURE_ENVIRONMENT_VARIABLES) _vcpkg_append_to_configure_environment(CONFIGURE_ENV ${_env} "${${_env}}") endforeach() From 2ac0ca238ee2d11fc738444d97843b03b42ad99e Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 23 Oct 2020 15:00:09 +0200 Subject: [PATCH 30/34] fix vcpkg_build_make due to the variable name change --- scripts/cmake/vcpkg_build_make.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index f67cfd4344f40e..aef53ba405e5b4 100644 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -42,7 +42,7 @@ ## * [freexl](https://github.com/Microsoft/vcpkg/blob/master/ports/freexl/portfile.cmake) ## * [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake) function(vcpkg_build_make) - include("${CMAKE_VARS_FILE}") + include("${_VCPKG_CMAKE_VARS_FILE}") 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) From a40e9a44a1716559fdf6feddd37bc64e01948412 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 23 Oct 2020 16:50:54 +0200 Subject: [PATCH 31/34] fix another case of function renaming regressions --- scripts/cmake/vcpkg_build_make.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index aef53ba405e5b4..3caf9bb2625f71 100644 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -115,7 +115,7 @@ function(vcpkg_build_make) set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}${_bc_SUBPATH}") message(STATUS "Building ${TARGET_TRIPLET}${SHORT_BUILDTYPE}") - extract_cpp_flags_and_set_cflags_and_cxxflags(${CMAKE_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 From d857367b471551342a28d6677c6c56c3e2b88fc5 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 23 Oct 2020 23:16:35 +0200 Subject: [PATCH 32/34] only rename config.log if it exists --- scripts/cmake/vcpkg_configure_make.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index f375447c918857..12432ac48ace16 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -665,7 +665,9 @@ function(vcpkg_configure_make) endforeach() endif() - file(RENAME "${TAR_DIR}/config.log" "${CURRENT_BUILDTREES_DIR}/config.log-${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}.log") + if(EXISTS "${TAR_DIR}/config.log") + file(RENAME "${TAR_DIR}/config.log" "${CURRENT_BUILDTREES_DIR}/config.log-${TARGET_TRIPLET}-${SHORT_NAME_${_buildtype}}.log") + endif() endif() if(BACKUP_ENV_PKG_CONFIG_PATH_${_buildtype}) From 7e247076ba9894921abd55e4bf79594d18d7cd5f Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 2 Nov 2020 22:27:22 +0100 Subject: [PATCH 33/34] actually add the script after vcpkg_common_functions was deleted. --- scripts/ports.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ports.cmake b/scripts/ports.cmake index c05323ec90cbac..9381b3d1aeb6bc 100644 --- a/scripts/ports.cmake +++ b/scripts/ports.cmake @@ -129,6 +129,7 @@ if(CMD MATCHES "^BUILD$") include(vcpkg_install_msbuild) include(vcpkg_install_nmake) include(vcpkg_install_qmake) + include(vcpkg_internal_get_cmake_vars) include(vcpkg_prettify_command) include(vcpkg_replace_string) include(vcpkg_test_cmake) From 21d09b99f786d9c76d985444638e6c35da217970 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 9 Nov 2020 11:59:36 +0100 Subject: [PATCH 34/34] remove setting of ldflags if path contains spaces --- scripts/cmake/vcpkg_configure_make.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index 4a988df8987350..d3cba3bf2d43d6 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -255,9 +255,11 @@ function(vcpkg_configure_make) #Used by cl _vcpkg_backup_env_variables(INCLUDE LIB LIBPATH) + set(_vcm_paths_with_spaces FALSE) if(CURRENT_PACKAGES_DIR MATCHES " " OR CURRENT_INSTALLED_DIR MATCHES " ") # Don't bother with whitespace. The tools will probably fail and I tried very hard trying to make it work (no success so far)! message(WARNING "Detected whitespace in root directory. Please move the path to one without whitespaces! The required tools do not handle whitespaces correctly and the build will most likely fail") + set(_vcm_paths_with_spaces TRUE) endif() # Pre-processing windows configure requirements @@ -560,7 +562,9 @@ function(vcpkg_configure_make) endif() _vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags(${_VAR_SUFFIX}) if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe") - set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") + if(NOT _vcm_paths_with_spaces) + set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") + endif() if(DEFINED ENV{_LINK_}) set(LINK_ENV_${_VAR_SUFFIX} "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}") else() @@ -583,7 +587,9 @@ function(vcpkg_configure_make) endif() _vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags(${_VAR_SUFFIX}) if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe") - set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") + if(NOT _vcm_paths_with_spaces) + set(LDFLAGS_${_VAR_SUFFIX} "-L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib -L${_VCPKG_INSTALLED}${PATH_SUFFIX_${_VAR_SUFFIX}}/lib/manual-link") + endif() if(DEFINED ENV{_LINK_}) set(LINK_ENV_${_VAR_SUFFIX} "$ENV{_LINK_} ${LINKER_FLAGS_${_VAR_SUFFIX}}") else()