diff options
author | fuzzard <fuzzard@users.noreply.github.com> | 2024-06-25 11:09:02 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-25 11:09:02 +1000 |
commit | c6682ed7ebf29f97a1a6bc82857ecf04521e2c56 (patch) | |
tree | 0a4222e57e11f43fee5fee145f3b73eafdabbd4d /cmake/scripts | |
parent | 563d33acc2e94ff92681005f75548a630e001700 (diff) | |
parent | a3046c6dd0385e92f083009b2fd3116bdcfeebea (diff) |
Merge pull request #25228 from fuzzard/cmake_cleanup3
[cmake] Complete target usage for dependency libs, and remove some old globals and other cmake cleanups
Diffstat (limited to 'cmake/scripts')
-rw-r--r-- | cmake/scripts/android/Install.cmake | 4 | ||||
-rw-r--r-- | cmake/scripts/common/ArchSetup.cmake | 1 | ||||
-rw-r--r-- | cmake/scripts/common/Macros.cmake | 78 | ||||
-rw-r--r-- | cmake/scripts/darwin_embedded/Macros.cmake | 8 | ||||
-rw-r--r-- | cmake/scripts/freebsd/Macros.cmake | 8 | ||||
-rw-r--r-- | cmake/scripts/linux/ExtraTargets.cmake | 14 | ||||
-rw-r--r-- | cmake/scripts/linux/Install.cmake | 8 | ||||
-rw-r--r-- | cmake/scripts/linux/Macros.cmake | 8 | ||||
-rw-r--r-- | cmake/scripts/osx/Macros.cmake | 8 | ||||
-rw-r--r-- | cmake/scripts/webos/ExtraTargets.cmake | 8 | ||||
-rw-r--r-- | cmake/scripts/windows/ArchSetup.cmake | 2 |
11 files changed, 66 insertions, 81 deletions
diff --git a/cmake/scripts/android/Install.cmake b/cmake/scripts/android/Install.cmake index b912141007..8e2b90e7b4 100644 --- a/cmake/scripts/android/Install.cmake +++ b/cmake/scripts/android/Install.cmake @@ -141,8 +141,8 @@ foreach(library IN LISTS LIBRARY_FILES) add_bundle_file(${library} ${libdir}/${APP_NAME_LC} ${CMAKE_BINARY_DIR}) endforeach() -if(TARGET Shairplay::Shairplay) - add_bundle_file(Shairplay::Shairplay ${libdir} "") +if(TARGET ${APP_NAME_LC}::Shairplay) + add_bundle_file(${APP_NAME_LC}::Shairplay ${libdir} "") endif() # Main targets from Makefile.in diff --git a/cmake/scripts/common/ArchSetup.cmake b/cmake/scripts/common/ArchSetup.cmake index a83d2ae198..0461496bf5 100644 --- a/cmake/scripts/common/ArchSetup.cmake +++ b/cmake/scripts/common/ArchSetup.cmake @@ -8,7 +8,6 @@ # ARCH - the system architecture # ARCH_DEFINES - list of compiler definitions for this architecture # SYSTEM_DEFINES - list of compiler definitions for this system -# DEP_DEFINES - compiler definitions for system dependencies (e.g. LIRC) # + the results of compiler tests etc. # workaround a bug in older cmake, where binutils wouldn't be set after deleting CMakeCache.txt diff --git a/cmake/scripts/common/Macros.cmake b/cmake/scripts/common/Macros.cmake index 65d6406ec7..fcb9659de9 100644 --- a/cmake/scripts/common/Macros.cmake +++ b/cmake/scripts/common/Macros.cmake @@ -72,12 +72,9 @@ function(core_add_library name) add_library(${name} STATIC ${SOURCES} ${HEADERS} ${OTHERS}) set_target_properties(${name} PROPERTIES PREFIX "") set(core_DEPENDS ${name} ${core_DEPENDS} CACHE STRING "" FORCE) - add_dependencies(${name} ${GLOBAL_TARGET_DEPS}) # Adds global target to library. This propagates dep lib info (eg include_dir locations) core_target_link_libraries(${name}) - # ToDo: remove the next line when the GLOBAL_TARGET_DEPS is removed completely - target_link_libraries(${name} PRIVATE ${GLOBAL_TARGET_DEPS}) set(CORE_LIBRARY ${name} PARENT_SCOPE) @@ -106,7 +103,7 @@ function(core_add_test_library name) set_target_properties(${name} PROPERTIES PREFIX "" EXCLUDE_FROM_ALL 1 FOLDER "Build Utilities/tests") - add_dependencies(${name} ${GLOBAL_TARGET_DEPS}) + set(test_archives ${test_archives} ${name} CACHE STRING "" FORCE) if(NOT MSVC) @@ -345,15 +342,6 @@ function(copy_files_from_filelist_to_buildtree pattern) set(install_data ${install_data} PARENT_SCOPE) endfunction() -# helper macro to set modified variables in parent scope -macro(export_dep) - set(SYSTEM_INCLUDES ${SYSTEM_INCLUDES} PARENT_SCOPE) - set(DEPLIBS ${DEPLIBS} PARENT_SCOPE) - set(DEP_DEFINES ${DEP_DEFINES} PARENT_SCOPE) - set(${depup}_FOUND ${${depup}_FOUND} PARENT_SCOPE) - mark_as_advanced(${depup}_LIBRARIES) -endmacro() - # split dependency specification to name and version # Arguments: # depspec dependency specification that can optionally include a required @@ -396,17 +384,20 @@ endmacro() # Arguments: # dep_list One or many dependency specifications (see split_dependency_specification) # for syntax). The dependency name is used uppercased as variable prefix. -# On return: -# dependencies added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} function(core_require_dep) foreach(depspec ${ARGN}) split_dependency_specification(${depspec} dep version) find_package_with_ver(${dep} ${version} REQUIRED) string(TOUPPER ${dep} depup) - list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) - list(APPEND DEPLIBS ${${depup}_LIBRARIES}) - list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) - export_dep() + + # We dont want to add a build tool + if (NOT ${depspec} IN_LIST optional_buildtools AND NOT ${depspec} IN_LIST required_buildtools) + # If dependency is found and is not in the list (eg shairplay) add to list + if (NOT ${depspec} IN_LIST required_deps) + set(required_deps ${required_deps} ${depspec} PARENT_SCOPE) + endif() + endif() + endforeach() endfunction() @@ -426,8 +417,6 @@ endmacro() # Arguments: # dep_list One or many dependency specifications (see split_dependency_specification) # for syntax). The dependency name is used uppercased as variable prefix. -# On return: -# dependency optionally added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} function(core_optional_dep) foreach(depspec ${ARGN}) set(_required False) @@ -440,12 +429,17 @@ function(core_optional_dep) set(_required True) endif() - if(${depup}_FOUND) - list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) - list(APPEND DEPLIBS ${${depup}_LIBRARIES}) - list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) + if(TARGET kodi::${dep}) set(final_message ${final_message} "${depup} enabled: Yes") - export_dep() + + # We dont want to add a build tool + if (NOT ${depspec} IN_LIST optional_buildtools AND NOT ${depspec} IN_LIST required_buildtools) + # If dependency is found and is not in the list (eg mariadb/mysql) add to list + if (NOT ${depspec} IN_LIST optional_deps) + set(optional_deps ${optional_deps} ${depspec} PARENT_SCOPE) + endif() + endif() + elseif(_required) message(FATAL_ERROR "${depup} enabled but not found") else() @@ -548,38 +542,6 @@ macro(core_add_optional_subdirs_from_filelist pattern) endforeach() endmacro() -# Generates an RFC2822 timestamp -# -# The following variable is set: -# RFC2822_TIMESTAMP -function(rfc2822stamp) - execute_process(COMMAND date -R - OUTPUT_VARIABLE RESULT) - set(RFC2822_TIMESTAMP ${RESULT} PARENT_SCOPE) -endfunction() - -# Generates an user stamp from git config info -# -# The following variable is set: -# PACKAGE_MAINTAINER - user stamp in the form of "username <username@example.com>" -# if no git tree is found, value is set to "nobody <nobody@example.com>" -function(userstamp) - find_package(Git) - if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git) - execute_process(COMMAND ${GIT_EXECUTABLE} config user.name - OUTPUT_VARIABLE username - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${GIT_EXECUTABLE} config user.email - OUTPUT_VARIABLE useremail - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_STRIP_TRAILING_WHITESPACE) - set(PACKAGE_MAINTAINER "${username} <${useremail}>" PARENT_SCOPE) - else() - set(PACKAGE_MAINTAINER "nobody <nobody@example.com>" PARENT_SCOPE) - endif() -endfunction() - # Parses git info and sets variables used to identify the build # Arguments: # stamp variable name to return diff --git a/cmake/scripts/darwin_embedded/Macros.cmake b/cmake/scripts/darwin_embedded/Macros.cmake index 5084bc1a54..f101044b11 100644 --- a/cmake/scripts/darwin_embedded/Macros.cmake +++ b/cmake/scripts/darwin_embedded/Macros.cmake @@ -37,7 +37,13 @@ function(core_link_library lib wraplib) list(APPEND export ${arg}) endforeach() elseif(check_arg STREQUAL archives) - set(extra_libs ${data_arg}) + foreach(_data_arg ${data_arg}) + if(TARGET ${_data_arg}) + list(APPEND extra_libs $<TARGET_FILE:_data_arg>) + else() + list(APPEND extra_libs ${_data_arg}) + endif() + endforeach() endif() get_filename_component(dir ${wraplib} DIRECTORY) diff --git a/cmake/scripts/freebsd/Macros.cmake b/cmake/scripts/freebsd/Macros.cmake index ef5aed38d1..f1877cf1e4 100644 --- a/cmake/scripts/freebsd/Macros.cmake +++ b/cmake/scripts/freebsd/Macros.cmake @@ -28,7 +28,13 @@ function(core_link_library lib wraplib) list(APPEND export ${arg}) endforeach() elseif(check_arg STREQUAL archives) - set(extra_libs ${data_arg}) + foreach(_data_arg ${data_arg}) + if(TARGET ${_data_arg}) + list(APPEND extra_libs $<TARGET_FILE:_data_arg>) + else() + list(APPEND extra_libs ${_data_arg}) + endif() + endforeach() endif() string(REGEX REPLACE "[ ]+" ";" _flags "${CMAKE_SHARED_LINKER_FLAGS}") diff --git a/cmake/scripts/linux/ExtraTargets.cmake b/cmake/scripts/linux/ExtraTargets.cmake index d3b3f1807c..36757cef41 100644 --- a/cmake/scripts/linux/ExtraTargets.cmake +++ b/cmake/scripts/linux/ExtraTargets.cmake @@ -1,16 +1,16 @@ # xrandr -if(TARGET X::X AND TARGET XRandR::XRandR) +if(TARGET ${APP_NAME_LC}::X AND TARGET ${APP_NAME_LC}::XRandR) find_package(X QUIET) find_package(XRandR QUIET) add_executable(${APP_NAME_LC}-xrandr ${CMAKE_SOURCE_DIR}/xbmc-xrandr.c) - target_link_libraries(${APP_NAME_LC}-xrandr ${SYSTEM_LDFLAGS} X::X m XRandR::XRandR) + target_link_libraries(${APP_NAME_LC}-xrandr ${SYSTEM_LDFLAGS} ${APP_NAME_LC}::X m ${APP_NAME_LC}::XRandR) endif() # WiiRemote if(ENABLE_EVENTCLIENTS AND TARGET ${APP_NAME_LC}::Bluetooth) find_package(CWiid QUIET) find_package(GLU QUIET) - if(CWIID_FOUND AND GLU_FOUND) + if(TARGET ${APP_NAME_LC}::CWiid AND TARGET ${APP_NAME_LC}::GLU) add_subdirectory(${CMAKE_SOURCE_DIR}/tools/EventClients/Clients/WiiRemote build/WiiRemote) endif() endif() @@ -24,8 +24,9 @@ if("wayland" IN_LIST CORE_PLATFORM_NAME_LC) "${WAYLAND_PROTOCOLS_DIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml") add_custom_command(OUTPUT "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.cpp" - COMMAND "${WAYLANDPP_SCANNER}" ${PROTOCOL_XMLS} "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.cpp" - DEPENDS "${WAYLANDPP_SCANNER}" ${PROTOCOL_XMLS} + COMMAND wayland::waylandppscanner + ARGS ${PROTOCOL_XMLS} "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-extra-protocols.cpp" + DEPENDS wayland::waylandppscanner ${PROTOCOL_XMLS} COMMENT "Generating wayland-protocols C++ wrappers") if("webos" IN_LIST CORE_PLATFORM_NAME_LC) @@ -34,7 +35,6 @@ if("wayland" IN_LIST CORE_PLATFORM_NAME_LC) # Dummy target for dependencies add_custom_target(generate-wayland-extra-protocols DEPENDS wayland-extra-protocols.hpp) - # ToDo: turn this into a TARGET OBJECT. For now, a custum target doesnt play nice with - # our PLATFORM_GLOBAL_TARGET_DEPS usage in macros + add_dependencies(lib${APP_NAME_LC} generate-wayland-extra-protocols) endif() diff --git a/cmake/scripts/linux/Install.cmake b/cmake/scripts/linux/Install.cmake index 47dc8faeef..5b4216badb 100644 --- a/cmake/scripts/linux/Install.cmake +++ b/cmake/scripts/linux/Install.cmake @@ -1,4 +1,4 @@ -if(X_FOUND) +if(TARGET ${APP_NAME_LC}::X) set(USE_X11 1) else() set(USE_X11 0) @@ -13,7 +13,7 @@ set(APP_INCLUDE_DIR ${includedir}/${APP_NAME_LC}) # Set XBMC_STANDALONE_SH_PULSE so we can insert PulseAudio block into kodi-standalone if(EXISTS ${CMAKE_SOURCE_DIR}/tools/Linux/kodi-standalone.sh.pulse) - if(ENABLE_PULSEAUDIO AND TARGET PulseAudio::PulseAudio) + if(ENABLE_PULSEAUDIO AND TARGET ${APP_NAME_LC}::PulseAudio) file(READ "${CMAKE_SOURCE_DIR}/tools/Linux/kodi-standalone.sh.pulse" pulse_content) set(XBMC_STANDALONE_SH_PULSE ${pulse_content}) endif() @@ -49,7 +49,7 @@ configure_file(${CMAKE_SOURCE_DIR}/tools/Linux/kodi.metainfo.xml.in install(TARGETS ${APP_NAME_LC} DESTINATION ${libdir}/${APP_NAME_LC} COMPONENT kodi-bin) -if(TARGET X::X AND TARGET XRandR::XRandR) +if(TARGET ${APP_NAME_LC}::X AND TARGET ${APP_NAME_LC}::XRandR) install(TARGETS ${APP_NAME_LC}-xrandr DESTINATION ${libdir}/${APP_NAME_LC} COMPONENT kodi-bin) @@ -275,7 +275,7 @@ if(ENABLE_EVENTCLIENTS) DESTINATION ${bindir} COMPONENT kodi-eventclients-ps3) - if(TARGET ${APP_NAME_LC}::Bluetooth AND CWIID_FOUND AND GLU_FOUND) + if(TARGET ${APP_NAME_LC}::Bluetooth AND ${APP_NAME_LC}::CWiid AND GLU_FOUND) # Install kodi-eventclients-wiiremote install(PROGRAMS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/WiiRemote/${APP_NAME_LC}-wiiremote DESTINATION ${bindir} diff --git a/cmake/scripts/linux/Macros.cmake b/cmake/scripts/linux/Macros.cmake index 37243a77cd..5ffb8171eb 100644 --- a/cmake/scripts/linux/Macros.cmake +++ b/cmake/scripts/linux/Macros.cmake @@ -28,7 +28,13 @@ function(core_link_library lib wraplib) list(APPEND export ${arg}) endforeach() elseif(check_arg STREQUAL archives) - set(extra_libs ${data_arg}) + foreach(_data_arg ${data_arg}) + if(TARGET ${_data_arg}) + list(APPEND extra_libs $<TARGET_FILE:_data_arg>) + else() + list(APPEND extra_libs ${_data_arg}) + endif() + endforeach() endif() string(REGEX REPLACE "[ ]+" ";" _flags "${CMAKE_SHARED_LINKER_FLAGS}") diff --git a/cmake/scripts/osx/Macros.cmake b/cmake/scripts/osx/Macros.cmake index f32a7358b5..6d41981db4 100644 --- a/cmake/scripts/osx/Macros.cmake +++ b/cmake/scripts/osx/Macros.cmake @@ -24,7 +24,13 @@ function(core_link_library lib wraplib) list(APPEND export ${arg}) endforeach() elseif(check_arg STREQUAL archives) - set(extra_libs ${data_arg}) + foreach(_data_arg ${data_arg}) + if(TARGET ${_data_arg}) + list(APPEND extra_libs $<TARGET_FILE:_data_arg>) + else() + list(APPEND extra_libs ${_data_arg}) + endif() + endforeach() endif() get_filename_component(dir ${wraplib} DIRECTORY) diff --git a/cmake/scripts/webos/ExtraTargets.cmake b/cmake/scripts/webos/ExtraTargets.cmake index 3380c6a3be..92ef6b62fa 100644 --- a/cmake/scripts/webos/ExtraTargets.cmake +++ b/cmake/scripts/webos/ExtraTargets.cmake @@ -3,10 +3,10 @@ set(WEBOS_PROTOCOL_XMLS "${WAYLANDPROTOCOLSWEBOS_PROTOCOLSDIR}/webos-shell.xml" "${WAYLANDPROTOCOLSWEBOS_PROTOCOLSDIR}/webos-foreign.xml" ) add_custom_command(OUTPUT "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-webos-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-webos-protocols.cpp" - COMMAND "${WAYLANDPP_SCANNER}" ${WEBOS_PROTOCOL_XMLS} "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-webos-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-webos-protocols.cpp" - DEPENDS "${WAYLANDPP_SCANNER}" ${WEBOS_PROTOCOL_XMLS} + COMMAND wayland::waylandppscanner + ARGS ${WEBOS_PROTOCOL_XMLS} "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-webos-protocols.hpp" "${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}/wayland-webos-protocols.cpp" + DEPENDS wayland::waylandppscanner ${WEBOS_PROTOCOL_XMLS} COMMENT "Generating wayland-webos C++ wrappers") add_custom_target(generate-wayland-webos-protocols DEPENDS wayland-webos-protocols.hpp) -# ToDo: turn this into a TARGET OBJECT. For now, a custum target doesnt play nice with -# our PLATFORM_GLOBAL_TARGET_DEPS usage in macros + add_dependencies(lib${APP_NAME_LC} generate-wayland-webos-protocols) diff --git a/cmake/scripts/windows/ArchSetup.cmake b/cmake/scripts/windows/ArchSetup.cmake index 7116196207..8be83e6a78 100644 --- a/cmake/scripts/windows/ArchSetup.cmake +++ b/cmake/scripts/windows/ArchSetup.cmake @@ -65,7 +65,7 @@ set(SYSTEM_DEFINES -DWIN32_LEAN_AND_MEAN -DNOMINMAX -DHAS_DX -D__STDC_CONSTANT_M $<$<CONFIG:Debug>:-DD3D_DEBUG_INFO>) # Additional SYSTEM_DEFINES -list(APPEND SYSTEM_DEFINES -DHAS_WIN32_NETWORK -DHAS_FILESYSTEM_SMB) +list(APPEND SYSTEM_DEFINES -DHAS_WIN32_NETWORK) # The /MP option enables /FS by default. if(CMAKE_GENERATOR MATCHES "Visual Studio") |