Skip to content

Commit

Permalink
vcpkg_fixup_pkgconfig: Move definition of SYSTEM_LIBRARIES to vcpkg_c…
Browse files Browse the repository at this point in the history
…ommon_definitions

To correctly validate installed pkg-config files, vcpkg_fixup_pkgconfig needs to know
for each platform which libraries are not managed by vcpkg. This commits improve this
definitions for all the triplet supported by vcpkg, and move this definition to vcpkg_common_definitions
in a way that permit custom triplets to overload its value.
  • Loading branch information
traversaro committed Jun 6, 2020
1 parent 58fd9f4 commit 83f3459
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions scripts/cmake/vcpkg_common_definitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
## VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX import library suffix for target (same as CMAKE_IMPORT_LIBRARY_SUFFIX)
## VCPKG_FIND_LIBRARY_PREFIXES target dependent prefixes used for find_library calls in portfiles
## VCPKG_FIND_LIBRARY_SUFFIXES target dependent suffixes used for find_library calls in portfiles
## VCPKG_SYSTEM_LIBRARIES list of libraries are provide by the toolchain and are not managed by vcpkg
## ```
##
## CMAKE_STATIC_LIBRARY_(PREFIX|SUFFIX), CMAKE_SHARED_LIBRARY_(PREFIX|SUFFIX) and CMAKE_IMPORT_LIBRARY_(PREFIX|SUFFIX) are defined for the target
Expand Down Expand Up @@ -111,3 +112,22 @@ set(CMAKE_IMPORT_LIBRARY_PREFIX "${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX}")

set(CMAKE_FIND_LIBRARY_SUFFIXES "${VCPKG_FIND_LIBRARY_SUFFIXES}" CACHE INTERNAL "") # Required by find_library
set(CMAKE_FIND_LIBRARY_PREFIXES "${VCPKG_FIND_LIBRARY_PREFIXES}" CACHE INTERNAL "") # Required by find_library

# Append platform libraries to VCPKG_SYSTEM_LIBRARIES
# The variable are just appended to permit to custom triplets define the variable

# Platforms with libdl
if(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_ANDROID OR VCPKG_TARGET_IS_OSX)
list(APPEND VCPKG_SYSTEM_LIBRARIES dl)
endif()

# Platforms with libm
if(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_ANDROID OR VCPKG_TARGET_IS_FREEBSD)
list(APPEND VCPKG_SYSTEM_LIBRARIES m)
endif()

# Windows system libs
if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND VCPKG_SYSTEM_LIBRARIES wsock32)
list(APPEND VCPKG_SYSTEM_LIBRARIES ws2_32)
endif()
4 changes: 2 additions & 2 deletions scripts/cmake/vcpkg_fixup_pkgconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ endfunction()
function(vcpkg_fixup_pkgconfig)
cmake_parse_arguments(_vfpkg "" "" "RELEASE_FILES;DEBUG_FILES;SYSTEM_LIBRARIES;SYSTEM_PACKAGES;IGNORE_FLAGS" ${ARGN})

if(VCPKG_TARGET_IS_LINUX)
list(APPEND _vfpkg_SYSTEM_LIBRARIES -ldl -lm)
if(VCPKG_SYSTEM_LIBRARIES)
list(APPEND _vfpkg_SYSTEM_LIBRARIES ${VCPKG_SYSTEM_LIBRARIES})
endif()
message(STATUS "Fixing pkgconfig")
if(_vfpkg_UNPARSED_ARGUMENTS)
Expand Down

0 comments on commit 83f3459

Please sign in to comment.