diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index 7622f682192904..ceefcc5be9d1cf 100755 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -146,19 +146,18 @@ function(vcpkg_build_make) else() # dynamic set(LINKER_FLAGS_${cmake_buildtype} "${VCPKG_DETECTED_SHARED_LINKER_FLAGS_${cmake_buildtype}}") endif() - if (CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe") - if(EXISTS "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link") - set(LDFLAGS_${cmake_buildtype} "-L${Z_VCPKG_INSTALLED}${path_suffix}/lib -L${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link") - else() - set(LDFLAGS_${cmake_buildtype} "-L${Z_VCPKG_INSTALLED}${path_suffix}/lib") - endif() - set(LINK_ENV_${cmake_buildtype} "$ENV{_LINK_} ${LINKER_FLAGS_${cmake_buildtype}}") - else() - if(EXISTS "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link") - set(LDFLAGS_${cmake_buildtype} "-L${Z_VCPKG_INSTALLED}${path_suffix}/lib -L${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link ${LINKER_FLAGS_${cmake_buildtype}}") - else() - set(LDFLAGS_${cmake_buildtype} "-L${Z_VCPKG_INSTALLED}${path_suffix}/lib ${LINKER_FLAGS_${cmake_buildtype}}") - endif() + set(LDFLAGS_${cmake_buildtype} "") + if(EXISTS "${Z_VCPKG_INSTALLED}${path_suffix}/lib") + set(LDFLAGS_${cmake_buildtype} "${LDFLAGS_${cmake_buildtype}} -L${Z_VCPKG_INSTALLED}${path_suffix}/lib") + endif() + if(EXISTS "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link") + set(LDFLAGS_${cmake_buildtype} "${LDFLAGS_${cmake_buildtype}} -L${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link") + endif() + if(EXISTS "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link") + vcpkg_host_path_list(PREPEND ENV{${lib_env_var}} "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link") + endif() + if(EXISTS "${Z_VCPKG_INSTALLED}${path_suffix}/lib") + vcpkg_host_path_list(PREPEND ENV{${lib_env_var}} "${Z_VCPKG_INSTALLED}${path_suffix}/lib") endif() # Setup environment @@ -167,17 +166,16 @@ function(vcpkg_build_make) set(ENV{CXXFLAGS} "${CXXFLAGS_${cmake_buildtype}}") set(ENV{RCFLAGS} "${VCPKG_DETECTED_CMAKE_RC_FLAGS_${cmake_buildtype}}") set(ENV{LDFLAGS} "${LDFLAGS_${cmake_buildtype}}") - if(EXISTS "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link") - vcpkg_host_path_list(PREPEND ENV{LIB} "${Z_VCPKG_INSTALLED}${path_suffix}/lib/" "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link/") - vcpkg_host_path_list(PREPEND ENV{LIBPATH} "${Z_VCPKG_INSTALLED}${path_suffix}/lib/" "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link/") - vcpkg_host_path_list(PREPEND ENV{LIBRARY_PATH} "${Z_VCPKG_INSTALLED}${path_suffix_${buildtype}}/lib/" "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link/") - #vcpkg_host_path_list(PREPEND ENV{LD_LIBRARY_PATH} "${Z_VCPKG_INSTALLED}${path_suffix}/lib/" "${Z_VCPKG_INSTALLED}${path_suffix_${buildtype}}/lib/manual-link/") - else() - vcpkg_host_path_list(PREPEND ENV{LIB} "${Z_VCPKG_INSTALLED}${path_suffix}/lib/") - vcpkg_host_path_list(PREPEND ENV{LIBPATH} "${Z_VCPKG_INSTALLED}${path_suffix}/lib/") - vcpkg_host_path_list(PREPEND ENV{LIBRARY_PATH} "${Z_VCPKG_INSTALLED}${path_suffix_${buildtype}}/lib/") - #vcpkg_host_path_list(PREPEND ENV{LD_LIBRARY_PATH} "${Z_VCPKG_INSTALLED}${path_suffix}/lib/") - endif() + vcpkg_list(APPEND lib_env_vars LIB LIBPATH LIBRARY_PATH) # LD_LIBRARY_PATH) + foreach(lib_env_var IN LISTS lib_env_vars) + if(EXISTS "${Z_VCPKG_INSTALLED}${path_suffix}/lib") + vcpkg_host_path_list(PREPEND ENV{${lib_env_var}} "${Z_VCPKG_INSTALLED}${path_suffix}/lib") + endif() + if(EXISTS "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link") + vcpkg_host_path_list(PREPEND ENV{${lib_env_var}} "${Z_VCPKG_INSTALLED}${path_suffix}/lib/manual-link") + endif() + endforeach() + unset(lib_env_vars) if(LINK_ENV_${_VAR_SUFFIX}) set(config_link_backup "$ENV{_LINK_}")