Skip to content

Commit

Permalink
Development/cmake enhancements (#308)
Browse files Browse the repository at this point in the history
* cmake: set minimum required cmake to 3.15

* cmake: remove empty lines

* cmake: Introduce cmake components

* DisplayInfo: remove hardcoded linking
  • Loading branch information
bramoosterhuis authored Jul 7, 2024
1 parent 727bd49 commit 651218b
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 87 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)
project(NanoServicesRDK)

find_package(Thunder)
Expand Down
4 changes: 2 additions & 2 deletions DeviceIdentification/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(DeviceIdentification)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -130,6 +130,6 @@ target_include_directories(${MODULE_NAME}
${CMAKE_CURRENT_LIST_DIR})

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()
4 changes: 2 additions & 2 deletions DeviceInfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(DeviceInfo)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -55,6 +55,6 @@ target_link_libraries(${MODULE_NAME}
${NAMESPACE}Definitions::${NAMESPACE}Definitions)

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()
10 changes: 3 additions & 7 deletions DisplayInfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(DisplayInfo)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -49,10 +49,6 @@ find_package(BCM_HOST QUIET)
find_package(NEXUS QUIET)
find_package(NXCLIENT QUIET)
find_package(LibDRM QUIET)
find_path (STAGING_INCDIR glib-2.0)
include_directories(include)
include_directories(${STAGING_INCDIR})
include_directories(${STAGING_INCDIR}/${CMAKE_INSTALL_LIBDIR}drm)

add_library(${MODULE_NAME} SHARED
DisplayInfo.cpp
Expand Down Expand Up @@ -141,12 +137,12 @@ elseif (LIBDRM_FOUND)

target_link_libraries(${MODULE_NAME}
PRIVATE
drm)
libdrm::libdrm)
else ()
message(FATAL_ERROR "There is no graphic backend for display info plugin")
endif ()

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()
43 changes: 14 additions & 29 deletions DisplayInfo/cmake/FindLibDRM.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# If not stated otherwise in this file or this component's license file the
# following copyright and licenses apply:
#
# Copyright 2020 RDK Management
# Copyright 2020 Metrological B.V.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,49 +15,34 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.7)

# Be compatible even if a newer CMake version is available
cmake_policy(VERSION 3.7...3.12)

if(LibDRM_FIND_QUIETLY)
set(_LIBDRM_MODE QUIET)
set(_LibDRM_MODE QUIET)
elseif(LibDRM_FIND_REQUIRED)
set(_LIBDRM_MODE REQUIRED)
set(_LibDRM_MODE REQUIRED)
endif()

find_package(PkgConfig)

# Just check if the libdrm.pc exist, and create the PkgConfig::libdrm target
# No version requirement (yet)
pkg_check_modules(LIBDRM ${_LIBDRM_MODE} IMPORTED_TARGET libdrm)

find_library(LIBDRM_ACTUAL_LIBRARY NAMES drm
HINTS ${LIBDRM_LIBRARY_DIRS} )
pkg_check_modules(LibDRM ${_LibDRM_MODE} IMPORTED_TARGET libdrm)

include(FindPackageHandleStandardArgs)

# Sets the FOUND variable to TRUE if all required variables are present and set
find_package_handle_standard_args(
LibDRM
REQUIRED_VARS
LIBDRM_INCLUDE_DIRS
LIBDRM_CFLAGS
LIBDRM_LDFLAGS
LIBDRM_LIBRARIES
LIBDRM_ACTUAL_LIBRARY
LibDRM_INCLUDE_DIRS
LibDRM_CFLAGS
LibDRM_LDFLAGS
LibDRM_LIBRARIES
LibDRM_ACTUAL_LIBRARY
VERSION_VAR
LIBDRM_VERSION
LibDRM_VERSION
)
mark_as_advanced(LIBDRM_INCLUDE_DIRS LIBDRM_LIBRARIES)
set(LIBDRM_FOUND ${LibDRM_FOUND})
mark_as_advanced(LibDRM_INCLUDE_DIRS LibDRM_LIBRARIES)

if(LibDRM_FOUND AND NOT TARGET LibDRM::LibDRM)
add_library(LibDRM::LibDRM UNKNOWN IMPORTED)
set_target_properties(LibDRM::LibDRM PROPERTIES
IMPORTED_LOCATION "${LIBDRM_ACTUAL_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${LIBDRM_LIBRARIES}"
INTERFACE_COMPILE_OPTIONS "${LIBDRM_CFLAGS}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBDRM_INCLUDE_DIRS}"
)
endif()
if(LibDRM_FOUND)
add_library(libdrm::libdrm ALIAS PkgConfig::LibDRM)
endif()
4 changes: 2 additions & 2 deletions LocationSync/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(LocationSync)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -59,6 +59,6 @@ target_link_libraries(${MODULE_NAME}
${NAMESPACE}Definitions::${NAMESPACE}Definitions)

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()
4 changes: 2 additions & 2 deletions MessageControl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(MessageControl)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -60,6 +60,6 @@ target_link_libraries(${MODULE_NAME}
${NAMESPACE}Messaging::${NAMESPACE}Messaging)

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()
5 changes: 2 additions & 3 deletions Messenger/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(Messenger)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -62,7 +62,6 @@ target_link_libraries(${MODULE_NAME}
${NAMESPACE}Definitions::${NAMESPACE}Definitions)

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()

4 changes: 2 additions & 2 deletions Monitor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(Monitor)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -97,6 +97,6 @@ target_link_libraries(${MODULE_NAME}
${NAMESPACE}Plugins::${NAMESPACE}Plugins)

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()
9 changes: 2 additions & 7 deletions OpenCDMi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(OCDM)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -65,11 +65,6 @@ target_link_libraries(${MODULE_NAME}
${NAMESPACE}Plugins::${NAMESPACE}Plugins )
# Library definition section
install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)


# Library installation section
string(TOLOWER ${NAMESPACE} STORAGENAME)
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGENAME}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()
4 changes: 2 additions & 2 deletions Packager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(Packager)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -67,7 +67,7 @@ endif (libprovision_FOUND)

string(TOLOWER ${NAMESPACE} STORAGENAME)
install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGENAME}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGENAME}/plugins COMPONENT ${NAMESPACE}_Runtime)

configure_file(
"${CMAKE_CURRENT_LIST_DIR}/opkg.conf.in"
Expand Down
6 changes: 2 additions & 4 deletions PerformanceMetrics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(PerformanceMetrics)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -73,7 +73,7 @@ target_link_libraries(${MODULE_NAME}
${NAMESPACE}Plugins::${NAMESPACE}Plugins)

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

if(PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER OR PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER_CLASSNAME)
write_config( PLUGINS PerfMetricsWebKitBrowser )
Expand All @@ -94,5 +94,3 @@ endif()
if(PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER_YOUTUBE)
write_config( PLUGINS PerfMetricsYouTube )
endif()


4 changes: 2 additions & 2 deletions PlayerInfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(PlayerInfo)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -105,6 +105,6 @@ if (DOLBY_SUPPORT)
endif()

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()
2 changes: 0 additions & 2 deletions PlayerInfo/Dolby/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,3 @@ if(${DOLBY_IMPLEMENTATION} STREQUAL "AMLogic")
else()
message(SEND_ERROR "No DOLBY_IMPLEMENTATION picked. Turn off dolby support or pick one.")
endif()


2 changes: 1 addition & 1 deletion RustBridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ target_link_libraries(${MODULE_NAME}
${NAMESPACE}Plugins::${NAMESPACE}Plugins)

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()
4 changes: 2 additions & 2 deletions SecurityAgent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(SecurityAgent)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -71,6 +71,6 @@ if (SECAPI)
endif()

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()
4 changes: 2 additions & 2 deletions WebBridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

project(WebBridge)

cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.15)

find_package(Thunder)

Expand Down Expand Up @@ -49,6 +49,6 @@ target_link_libraries(${MODULE_NAME}
${NAMESPACE}Plugins::${NAMESPACE}Plugins)

install(TARGETS ${MODULE_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime)

write_config()
Loading

0 comments on commit 651218b

Please sign in to comment.