Skip to content

Commit

Permalink
Merge pull request xbmc#23809 from fuzzard/cmake_assorted1
Browse files Browse the repository at this point in the history
[Cmake] assorted updates to search paths and fixes to *_LIBRARIES usage
  • Loading branch information
fuzzard authored Sep 26, 2023
2 parents 6763a69 + 070bda8 commit 7e58d70
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 36 deletions.
4 changes: 2 additions & 2 deletions cmake/modules/FindAlsa.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ if(NOT TARGET ALSA::ALSA)
endif()

find_path(ALSA_INCLUDE_DIR NAMES alsa/asoundlib.h
PATHS ${PC_ALSA_INCLUDEDIR}
HINTS ${PC_ALSA_INCLUDEDIR}
NO_CACHE)
find_library(ALSA_LIBRARY NAMES asound
PATHS ${PC_ALSA_LIBDIR}
HINTS ${PC_ALSA_LIBDIR}
NO_CACHE)

set(ALSA_VERSION ${PC_ALSA_VERSION})
Expand Down
12 changes: 8 additions & 4 deletions cmake/modules/FindAvahi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ if(NOT TARGET Avahi::Avahi)
endif()

find_path(AVAHI_CLIENT_INCLUDE_DIR NAMES avahi-client/client.h
PATHS ${PC_AVAHI_INCLUDEDIR}
HINTS ${DEPENDS_PATH}/include ${PC_AVAHI_INCLUDEDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)
find_path(AVAHI_COMMON_INCLUDE_DIR NAMES avahi-common/defs.h
PATHS ${PC_AVAHI_INCLUDEDIR}
HINTS ${DEPENDS_PATH}/include ${PC_AVAHI_INCLUDEDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)
find_library(AVAHI_CLIENT_LIBRARY NAMES avahi-client
PATHS ${PC_AVAHI_LIBDIR}
HINTS ${DEPENDS_PATH}/lib ${PC_AVAHI_LIBDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)
find_library(AVAHI_COMMON_LIBRARY NAMES avahi-common
PATHS ${PC_AVAHI_LIBDIR}
HINTS ${DEPENDS_PATH}/lib ${PC_AVAHI_LIBDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)

set(AVAHI_VERSION ${PC_AVAHI_VERSION})
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/FindBluetooth.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ if(NOT TARGET Bluetooth::Bluetooth)
endif()

find_path(BLUETOOTH_INCLUDE_DIR NAMES bluetooth/bluetooth.h
PATHS ${PC_BLUETOOTH_INCLUDEDIR}
HINTS ${PC_BLUETOOTH_INCLUDEDIR}
NO_CACHE)
find_library(BLUETOOTH_LIBRARY NAMES bluetooth libbluetooth
PATHS ${PC_BLUETOOTH_LIBDIR}
HINTS ${PC_BLUETOOTH_LIBDIR}
NO_CACHE)

set(BLUETOOTH_VERSION ${PC_BLUETOOTH_VERSION})
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/FindCAP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ if(NOT TARGET CAP::CAP)
endif()

find_path(CAP_INCLUDE_DIR NAMES sys/capability.h
PATHS ${PC_CAP_INCLUDEDIR}
HINTS ${PC_CAP_INCLUDEDIR}
NO_CACHE)
find_library(CAP_LIBRARY NAMES cap libcap
PATHS ${PC_CAP_LIBDIR}
HINTS ${PC_CAP_LIBDIR}
NO_CACHE)

set(CAP_VERSION ${PC_CAP_VERSION})
Expand Down
17 changes: 13 additions & 4 deletions cmake/modules/FindCrossGUID.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,25 @@ if(NOT TARGET CrossGUID::CrossGUID)
if(ENABLE_INTERNAL_CROSSGUID)
buildCrossGUID()
else()
if(PKG_CONFIG_FOUND)
find_package(PkgConfig)
# Do not use pkgconfig on windows
if(PKG_CONFIG_FOUND AND NOT WIN32)
pkg_check_modules(PC_CROSSGUID crossguid QUIET)
set(CROSSGUID_VERSION ${PC_CROSSGUID_VERSION})
endif()

find_path(CROSSGUID_INCLUDE_DIR NAMES crossguid/guid.hpp guid.h
HINTS ${DEPENDS_PATH}/include ${PC_CROSSGUID_INCLUDEDIR})
HINTS ${DEPENDS_PATH}/include ${PC_CROSSGUID_INCLUDEDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)
find_library(CROSSGUID_LIBRARY_RELEASE NAMES crossguid
HINTS ${DEPENDS_PATH}/lib ${PC_CROSSGUID_LIBDIR})
HINTS ${DEPENDS_PATH}/lib ${PC_CROSSGUID_LIBDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)
find_library(CROSSGUID_LIBRARY_DEBUG NAMES crossguidd crossguid-dgb
HINTS ${DEPENDS_PATH}/lib ${PC_CROSSGUID_LIBDIR})
HINTS ${DEPENDS_PATH}/lib ${PC_CROSSGUID_LIBDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)

# NEW_CROSSGUID >= 0.2.0 release
if(EXISTS "${CROSSGUID_INCLUDE_DIR}/crossguid/guid.hpp")
Expand All @@ -59,6 +67,7 @@ if(NOT TARGET CrossGUID::CrossGUID)
# Select relevant lib build type (ie CROSSGUID_LIBRARY_RELEASE or CROSSGUID_LIBRARY_DEBUG)
include(SelectLibraryConfigurations)
select_library_configurations(CROSSGUID)
unset(CROSSGUID_LIBRARIES)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CrossGUID
Expand Down
9 changes: 4 additions & 5 deletions cmake/modules/FindDBus.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ if(NOT TARGET DBus::DBus)

find_path(DBUS_INCLUDE_DIR NAMES dbus/dbus.h
PATH_SUFFIXES dbus-1.0
PATHS ${PC_DBUS_INCLUDE_DIR})
HINTS ${PC_DBUS_INCLUDE_DIR})
find_path(DBUS_ARCH_INCLUDE_DIR NAMES dbus/dbus-arch-deps.h
PATH_SUFFIXES dbus-1.0/include
PATHS ${PC_DBUS_LIBDIR}
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})
HINTS ${PC_DBUS_LIBDIR}
PATHS /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})
find_library(DBUS_LIBRARY NAMES dbus-1
PATHS ${PC_DBUS_LIBDIR})
HINTS ${PC_DBUS_LIBDIR})

set(DBUS_VERSION ${PC_DBUS_VERSION})

Expand All @@ -31,7 +31,6 @@ if(NOT TARGET DBus::DBus)
VERSION_VAR DBUS_VERSION)

if(DBUS_FOUND)

add_library(DBus::DBus UNKNOWN IMPORTED)
set_target_properties(DBus::DBus PROPERTIES
IMPORTED_LOCATION "${DBUS_LIBRARY}"
Expand Down
6 changes: 5 additions & 1 deletion cmake/modules/FindDav1d.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,20 @@ if(NOT TARGET dav1d::dav1d)

BUILD_DEP_TARGET()
else()
if(PKG_CONFIG_FOUND)
find_package(PkgConfig)
# Do not use pkgconfig on windows
if(PKG_CONFIG_FOUND AND NOT WIN32)
pkg_check_modules(PC_DAV1D dav1d QUIET)
endif()

find_library(DAV1D_LIBRARY NAMES dav1d libdav1d
HINTS ${DEPENDS_PATH}/lib ${PC_DAV1D_LIBDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)

find_path(DAV1D_INCLUDE_DIR NAMES dav1d/dav1d.h
HINTS ${DEPENDS_PATH}/include ${PC_DAV1D_INCLUDEDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)

set(DAV1D_VERSION ${PC_DAV1D_VERSION})
Expand Down
2 changes: 2 additions & 0 deletions cmake/modules/FindDetours.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ if(NOT TARGET windows::Detours)
NO_CACHE)

find_library(DETOURS_LIBRARY_RELEASE NAMES detours
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)
find_library(DETOURS_LIBRARY_DEBUG NAMES detoursd
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)

include(SelectLibraryConfigurations)
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/FindEGL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ if(NOT TARGET EGL::EGL)
endif()

find_path(EGL_INCLUDE_DIR EGL/egl.h
PATHS ${PC_EGL_INCLUDEDIR}
HINTS ${PC_EGL_INCLUDEDIR}
NO_CACHE)

find_library(EGL_LIBRARY NAMES EGL egl
PATHS ${PC_EGL_LIBDIR}
HINTS ${PC_EGL_LIBDIR}
NO_CACHE)

set(EGL_VERSION ${PC_EGL_VERSION})
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/FindFmt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ if(NOT TARGET fmt::fmt OR Fmt_FIND_REQUIRED)

include(SelectLibraryConfigurations)
select_library_configurations(FMT)
unset(FMT_LIBRARIES)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Fmt
Expand Down
10 changes: 7 additions & 3 deletions cmake/modules/FindFreeType.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@

if(NOT TARGET FreeType::FreeType)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
# Do not use pkgconfig on windows
if(PKG_CONFIG_FOUND AND NOT WIN32)
pkg_check_modules(PC_FREETYPE freetype2 QUIET)
endif()

find_path(FREETYPE_INCLUDE_DIR NAMES freetype/freetype.h freetype.h
PATHS ${PC_FREETYPE_INCLUDEDIR}
HINTS ${DEPENDS_PATH}/include
${PC_FREETYPE_INCLUDEDIR}
${PC_FREETYPE_INCLUDE_DIRS}
PATH_SUFFIXES freetype2
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)
find_library(FREETYPE_LIBRARY NAMES freetype freetype246MT
PATHS ${PC_FREETYPE_LIBDIR}
HINTS ${DEPENDS_PATH}/lib ${PC_FREETYPE_LIBDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)

set(FREETYPE_VERSION ${PC_FREETYPE_VERSION})
Expand Down
11 changes: 7 additions & 4 deletions cmake/modules/FindFstrcmp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,20 @@ if(NOT TARGET fstrcmp::fstrcmp)

BUILD_DEP_TARGET()
else()
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_FSTRCMP fstrcmp QUIET)
endif()

find_path(FSTRCMP_INCLUDE_DIR NAMES fstrcmp.h
PATHS ${PC_FSTRCMP_INCLUDEDIR})
HINTS ${DEPENDS_PATH}/include ${PC_FSTRCMP_INCLUDEDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)

find_library(FSTRCMP_LIBRARY NAMES fstrcmp
PATHS ${PC_FSTRCMP_LIBDIR})
HINTS ${DEPENDS_PATH}/lib ${PC_FSTRCMP_LIBDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)

set(FSTRCMP_VER ${PC_FSTRCMP_VERSION})
endif()
Expand All @@ -56,5 +61,3 @@ if(NOT TARGET fstrcmp::fstrcmp)

set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP fstrcmp::fstrcmp)
endif()

mark_as_advanced(FSTRCMP_INCLUDE_DIR FSTRCMP_LIBRARY)
4 changes: 2 additions & 2 deletions cmake/modules/FindGBM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ if(NOT TARGET GBM::GBM)
endif()

find_path(GBM_INCLUDE_DIR NAMES gbm.h
PATHS ${PC_GBM_INCLUDEDIR}
HINTS ${PC_GBM_INCLUDEDIR}
NO_CACHE)
find_library(GBM_LIBRARY NAMES gbm
PATHS ${PC_GBM_LIBDIR}
HINTS ${PC_GBM_LIBDIR}
NO_CACHE)

set(GBM_VERSION ${PC_GBM_VERSION})
Expand Down
8 changes: 5 additions & 3 deletions cmake/modules/FindHarfBuzz.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ if(NOT TARGET HarfBuzz::HarfBuzz)
endif()

find_path(HARFBUZZ_INCLUDE_DIR NAMES harfbuzz/hb-ft.h hb-ft.h
HINTS ${PC_HARFBUZZ_INCLUDEDIR}
HINTS ${DEPENDS_PATH}/include
${PC_HARFBUZZ_INCLUDEDIR}
${PC_HARFBUZZ_INCLUDE_DIRS}
PATH_SUFFIXES harfbuzz
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)
find_library(HARFBUZZ_LIBRARY NAMES harfbuzz
HINTS ${PC_HARFBUZZ_LIBDIR}
HINTS ${DEPENDS_PATH}/lib ${PC_HARFBUZZ_LIBDIR}
${${CORE_PLATFORM_LC}_SEARCH_CONFIG}
NO_CACHE)

set(HARFBUZZ_VERSION ${PC_HARFBUZZ_VERSION})
Expand Down
2 changes: 2 additions & 0 deletions cmake/modules/FindPCRE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ if(NOT PCRE::pcre)
include(SelectLibraryConfigurations)
select_library_configurations(PCRECPP)
select_library_configurations(PCRE)
unset(PCRECPP_LIBRARIES)
unset(PCRE_LIBRARIES)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PCRE
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/FindSpdlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ if(NOT TARGET spdlog::spdlog)

include(SelectLibraryConfigurations)
select_library_configurations(SPDLOG)
unset(SPDLOG_LIBRARIES)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Spdlog
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/FindTagLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ if(NOT TARGET TagLib::TagLib)

include(SelectLibraryConfigurations)
select_library_configurations(TAGLIB)
unset(TAGLIB_LIBRARIES)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(TagLib
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/FindTinyXML2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ if(NOT TARGET tinyxml2::tinyxml2)

include(SelectLibraryConfigurations)
select_library_configurations(TINYXML2)
unset(TINYXML2_LIBRARIES)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(TinyXML2
Expand Down
4 changes: 2 additions & 2 deletions tools/EventClients/Clients/WiiRemote/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ set(HEADERS CWIID_WiiRemote.h)
add_executable(${APP_NAME_LC}-wiiremote ${SOURCES} ${HEADERS})

target_include_directories(${APP_NAME_LC}-wiiremote
PRIVATE ${BLUETOOTH_INCLUDE_DIRS}
PRIVATE $<TARGET_PROPERTY:Bluetooth::Bluetooth,INTERFACE_INCLUDE_DIRECTORIES>
${CWIID_INCLUDE_DIRS})

target_link_libraries(${APP_NAME_LC}-wiiremote
PRIVATE ${SYSTEM_LDFLAGS}
${BLUETOOTH_LIBRARIES}
Bluetooth::Bluetooth
${CWIID_LIBRARIES})

target_compile_options(${APP_NAME_LC}-wiiremote PRIVATE ${ARCH_DEFINES})
Expand Down

0 comments on commit 7e58d70

Please sign in to comment.