Skip to content

Commit

Permalink
Merge pull request xbmc#23612 from fuzzard/cmake_target_fixes
Browse files Browse the repository at this point in the history
[Cmake] Several fixes for TARGET usage
  • Loading branch information
fuzzard authored Sep 1, 2023
2 parents 5180a2d + cecee18 commit efe703a
Show file tree
Hide file tree
Showing 27 changed files with 1,014 additions and 835 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ core_add_subdirs_from_filelist(${CMAKE_SOURCE_DIR}/cmake/treedata/common/*.txt
core_add_optional_subdirs_from_filelist(${CMAKE_SOURCE_DIR}/cmake/treedata/optional/common/*.txt
${CMAKE_SOURCE_DIR}/cmake/treedata/optional/${CORE_SYSTEM_NAME}/*.txt)

target_link_libraries(lib${APP_NAME_LC} PUBLIC ${core_DEPENDS} ${SYSTEM_LDFLAGS} ${DEPLIBS} ${CMAKE_DL_LIBS})
target_link_libraries(lib${APP_NAME_LC} PUBLIC ${core_DEPENDS} ${SYSTEM_LDFLAGS} ${DEPLIBS} ${CMAKE_DL_LIBS} ${GLOBAL_TARGET_DEPS})
set_target_properties(lib${APP_NAME_LC} PROPERTIES PROJECT_LABEL "xbmc")
source_group_by_folder(lib${APP_NAME_LC} RELATIVE ${CMAKE_SOURCE_DIR}/xbmc)
if(WIN32)
Expand Down
129 changes: 58 additions & 71 deletions cmake/modules/FindCrossGUID.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,110 +2,97 @@
# -------
# Finds the CrossGUID library
#
# This will define the following variables::
#
# CROSSGUID_FOUND_FOUND - system has CrossGUID
# CROSSGUID_INCLUDE_DIRS - the CrossGUID include directory
# CROSSGUID_LIBRARIES - the CrossGUID libraries
# CROSSGUID_DEFINITIONS - cmake definitions required
#
# and the following imported targets::
# This will define the following target:
#
# CrossGUID::CrossGUID - The CrossGUID library

if(ENABLE_INTERNAL_CROSSGUID)
include(cmake/scripts/common/ModuleHelpers.cmake)
if(NOT TARGET CrossGUID::CrossGUID)
if(ENABLE_INTERNAL_CROSSGUID)
include(cmake/scripts/common/ModuleHelpers.cmake)

set(MODULE_LC crossguid)
set(MODULE_LC crossguid)

SETUP_BUILD_VARS()
SETUP_BUILD_VARS()

set(CROSSGUID_VERSION ${${MODULE}_VER})
set(CROSSGUID_DEFINITIONS -DHAVE_NEW_CROSSGUID)
set(CROSSGUID_DEBUG_POSTFIX "-dgb")
set(CROSSGUID_VERSION ${${MODULE}_VER})
set(CROSSGUID_DEBUG_POSTFIX "-dgb")

if(ANDROID)
list(APPEND CROSSGUID_DEFINITIONS -DGUID_ANDROID)
endif()
set(_crossguid_definitions HAVE_NEW_CROSSGUID)

set(patches "${CMAKE_SOURCE_DIR}/tools/depends/target/crossguid/001-fix-unused-function.patch"
"${CMAKE_SOURCE_DIR}/tools/depends/target/crossguid/002-disable-Wall-error.patch"
"${CMAKE_SOURCE_DIR}/tools/depends/target/crossguid/003-add-cstdint-include.patch")
if(ANDROID)
list(APPEND _crossguid_definitions GUID_ANDROID)
endif()

generate_patchcommand("${patches}")
set(patches "${CMAKE_SOURCE_DIR}/tools/depends/target/crossguid/001-fix-unused-function.patch"
"${CMAKE_SOURCE_DIR}/tools/depends/target/crossguid/002-disable-Wall-error.patch"
"${CMAKE_SOURCE_DIR}/tools/depends/target/crossguid/003-add-cstdint-include.patch")

set(CMAKE_ARGS -DCROSSGUID_TESTS=OFF
-DDISABLE_WALL=ON)
generate_patchcommand("${patches}")

BUILD_DEP_TARGET()
set(CMAKE_ARGS -DCROSSGUID_TESTS=OFF
-DDISABLE_WALL=ON)

else()
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_CROSSGUID crossguid QUIET)
set(CROSSGUID_VERSION ${PC_CROSSGUID_VERSION})
endif()
BUILD_DEP_TARGET()

if(CROSSGUID_FOUND)
find_path(CROSSGUID_INCLUDE_DIR NAMES crossguid/guid.hpp guid.h
PATHS ${PC_CROSSGUID_INCLUDEDIR})
else()
if(PKG_CONFIG_FOUND)
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
PATHS ${PC_CROSSGUID_INCLUDEDIR})
find_library(CROSSGUID_LIBRARY_RELEASE NAMES crossguid
PATHS ${PC_CROSSGUID_LIBDIR})
HINTS ${PC_CROSSGUID_LIBDIR})
find_library(CROSSGUID_LIBRARY_DEBUG NAMES crossguidd crossguid-dgb
PATHS ${PC_CROSSGUID_LIBDIR})
else()
find_path(CROSSGUID_INCLUDE_DIR NAMES crossguid/guid.hpp guid.h)
find_library(CROSSGUID_LIBRARY_RELEASE NAMES crossguid)
find_library(CROSSGUID_LIBRARY_DEBUG NAMES crossguidd)
endif()
endif()
HINTS ${PC_CROSSGUID_LIBDIR})

# Select relevant lib build type (ie CROSSGUID_LIBRARY_RELEASE or CROSSGUID_LIBRARY_DEBUG)
include(SelectLibraryConfigurations)
select_library_configurations(CROSSGUID)
# NEW_CROSSGUID >= 0.2.0 release
if(EXISTS "${CROSSGUID_INCLUDE_DIR}/crossguid/guid.hpp")
list(APPEND _crossguid_definitions HAVE_NEW_CROSSGUID)
endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CrossGUID
REQUIRED_VARS CROSSGUID_LIBRARY CROSSGUID_INCLUDE_DIR
VERSION_VAR CROSSGUID_VERSION)
# Select relevant lib build type (ie CROSSGUID_LIBRARY_RELEASE or CROSSGUID_LIBRARY_DEBUG)
include(SelectLibraryConfigurations)
select_library_configurations(CROSSGUID)

if(CROSSGUID_FOUND)
set(CROSSGUID_LIBRARIES ${CROSSGUID_LIBRARY})
set(CROSSGUID_INCLUDE_DIRS ${CROSSGUID_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CrossGUID
REQUIRED_VARS CROSSGUID_LIBRARY CROSSGUID_INCLUDE_DIR
VERSION_VAR CROSSGUID_VERSION)

# NEW_CROSSGUID >= 0.2.0 release
if(EXISTS "${CROSSGUID_INCLUDE_DIR}/crossguid/guid.hpp")
list(APPEND CROSSGUID_DEFINITIONS -DHAVE_NEW_CROSSGUID)
add_library(CrossGUID::CrossGUID UNKNOWN IMPORTED)
if(CROSSGUID_LIBRARY_RELEASE)
set_target_properties(CrossGUID::CrossGUID PROPERTIES
IMPORTED_CONFIGURATIONS RELEASE
IMPORTED_LOCATION_RELEASE "${CROSSGUID_LIBRARY_RELEASE}")
endif()
if(CROSSGUID_LIBRARY_DEBUG)
set_target_properties(CrossGUID::CrossGUID PROPERTIES
IMPORTED_CONFIGURATIONS DEBUG
IMPORTED_LOCATION_DEBUG "${CROSSGUID_LIBRARY_DEBUG}")
endif()
set_target_properties(CrossGUID::CrossGUID PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CROSSGUID_INCLUDE_DIRS}"
INTERFACE_COMPILE_DEFINITIONS "${_crossguid_definitions}")

if(UNIX AND NOT (APPLE OR ANDROID))
# Suppress mismatch warning, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html
set(FPHSA_NAME_MISMATCHED 1)
find_package(UUID REQUIRED)
unset(FPHSA_NAME_MISMATCHED)
list(APPEND CROSSGUID_INCLUDE_DIRS ${UUID_INCLUDE_DIRS})
list(APPEND CROSSGUID_LIBRARIES ${UUID_LIBRARIES})
endif()

if(NOT TARGET CrossGUID::CrossGUID)
add_library(CrossGUID::CrossGUID UNKNOWN IMPORTED)
if(CROSSGUID_LIBRARY_RELEASE)
set_target_properties(CrossGUID::CrossGUID PROPERTIES
IMPORTED_CONFIGURATIONS RELEASE
IMPORTED_LOCATION "${CROSSGUID_LIBRARY_RELEASE}")
if(TARGET UUID::UUID)
add_dependencies(CrossGUID::CrossGUID UUID::UUID)
target_link_libraries(CrossGUID::CrossGUID INTERFACE UUID::UUID)
endif()
if(CROSSGUID_LIBRARY_DEBUG)
set_target_properties(CrossGUID::CrossGUID PROPERTIES
IMPORTED_CONFIGURATIONS DEBUG
IMPORTED_LOCATION "${CROSSGUID_LIBRARY_DEBUG}")
endif()
set_target_properties(CrossGUID::CrossGUID PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CROSSGUID_INCLUDE_DIRS}")
endif()

if(TARGET crossguid)
add_dependencies(CrossGUID::CrossGUID crossguid)
endif()
set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP CrossGUID::CrossGUID)

set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP CrossGUID::CrossGUID)
endif()
mark_as_advanced(CROSSGUID_INCLUDE_DIR CROSSGUID_LIBRARY)
Loading

0 comments on commit efe703a

Please sign in to comment.