Skip to content

Commit

Permalink
[vcpkg_build_make] Only set the lib path if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Jan 28, 2022
1 parent 3cf63c4 commit 78f9ffb
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions scripts/cmake/vcpkg_build_make.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_}")
Expand Down

0 comments on commit 78f9ffb

Please sign in to comment.