Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
[CP] Fix compilation issues for ClearLinux integration(CL#806263)
Browse files Browse the repository at this point in the history
Fix compilation issues for ClearLinux integration
1. Auto detect libdrm
2. Auto detect systemd
3. Standard installation path
4. Explictly compile common module as static library
5. Add pkg-config file
6. Add shared library version

Change-Id: Id9bb8d597cb260304f1aad7f8560ae729846cf7a
  • Loading branch information
shiqiangyu committed Oct 10, 2018
1 parent 0972f98 commit 0b1e72f
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 36 deletions.
72 changes: 57 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@

cmake_minimum_required(VERSION 2.8.12)

add_definitions(-DLINUX)

# Forbid in-tree building
if(${CMAKE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR})
message(STATUS "Please do out-of-tree build")
message(FATAL_ERROR "In-tree-build detected!")
endif()

# Set compile flags
set(HDCP_COMMON_COMPILE_FLAGS
-O2
-D_FORTIFY_SOURCE=2
Expand All @@ -36,9 +45,8 @@ set(HDCP_C_FLAGS ${HDCP_COMMON_COMPILE_FLAGS})
set(HDCP_CXX_FLAGS ${HDCP_COMMON_COMPILE_FLAGS} -std=c++11)
set(HDCP_LD_FLAGS "-z noexecstack -z relro -z now -pie")

add_definitions(-DLINUX)

if (DEFINED CMAKE_BUILD_TYPE AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
# Set build type
if(DEFINED CMAKE_BUILD_TYPE AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
message(STATUS "cmake build type is DEBUG")

set(HDCP_CXX_FLAGS ${HDCP_CXX_FLAGS} -g)
Expand All @@ -47,20 +55,28 @@ if (DEFINED CMAKE_BUILD_TYPE AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
add_definitions(-DHDCP_USE_VERBOSE_LOGGING)
add_definitions(-DHDCP_USE_FUNCTION_LOGGING)
add_definitions(-DHDCP_USE_LINK_FUNCTION_LOGGING)
endif ()
endif()

if (DEFINED CMAKE_BUILD_TYPE AND "${CMAKE_BUILD_TYPE}" STREQUAL "ReleaseInternal")
if(DEFINED CMAKE_BUILD_TYPE AND "${CMAKE_BUILD_TYPE}" STREQUAL "ReleaseInternal")
message(STATUS "cmake build type is \"${CMAKE_BUILD_TYPE}\"")

add_definitions(-DLOG_CONSOLE)
add_definitions(-DHDCP_USE_VERBOSE_LOGGING)
add_definitions(-DHDCP_USE_FUNCTION_LOGGING)
endif ()
endif()

if (DEFINED CMAKE_BUILD_TYPE AND "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
if(DEFINED CMAKE_BUILD_TYPE AND "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
message(STATUS "cmake build type is \"${CMAKE_BUILD_TYPE}\"")
endif ()
endif()

# Set version
set(HDCP_VERSION_MAJOR 0)
set(HDCP_VERSION_MINOR 1)
set(HDCP_VERSION_PATCH 1)
set(HDCP_VERSION
${HDCP_VERSION_MAJOR}.${HDCP_VERSION_MINOR}.${HDCP_VERSION_PATCH})

# Include sub project sdk daemon
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
Expand All @@ -69,17 +85,43 @@ add_subdirectory(common ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/common)
add_subdirectory(sdk ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/sdk)
add_subdirectory(daemon ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/daemon)

set(CMAKE_INSTALL_BINDIR /usr/bin)
set(CMAKE_INSTALL_LIBDIR /usr/lib/x86_64-linux-gnu)
set(CMAKE_SYSTEMD_INSTALL_DIR /etc/systemd/system)
install (PROGRAMS ${CMAKE_BINARY_DIR}/hdcpd DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT cp)
install (FILES ${CMAKE_BINARY_DIR}/libhdcpsdk.so DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT cp)
install (FILES ${CMAKE_SOURCE_DIR}/config/hdcpd.service DESTINATION ${CMAKE_SYSTEMD_INSTALL_DIR} COMPONENT cp)
configure_file(${CMAKE_SOURCE_DIR}/config/libhdcpsdk.pc.in
${CMAKE_BINARY_DIR}/libhdcpsdk.pc
@ONLY)

# Set install path
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr/local")
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

set(CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include)
set(CMAKE_INSTALL_BINDIR ${CMAKE_INSTALL_PREFIX}/bin)
set(CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib)

install(PROGRAMS ${CMAKE_BINARY_DIR}/hdcpd
DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT cp)
install(FILES ${CMAKE_SOURCE_DIR}/sdk/hdcpapi.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT cp)
install(FILES ${CMAKE_BINARY_DIR}/libhdcpsdk.so
DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT cp)
install(FILES ${CMAKE_BINARY_DIR}/libhdcpsdk.so.${HDCP_VERSION_MAJOR}
DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT cp)
install(FILES ${CMAKE_BINARY_DIR}/libhdcpsdk.so.${HDCP_VERSION}
DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT cp)
install(FILES ${CMAKE_BINARY_DIR}/libhdcpsdk.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT cp)

include(${CMAKE_SOURCE_DIR}/config/systemdservice.cmake)

message(STATUS "hdcpd install dir : ${CMAKE_INSTALL_BINDIR}")
message(STATUS "libhdcpsdk.so install dir : ${CMAKE_INSTALL_LIBDIR}")

# Set package information
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "intel-uapi-hdcp")
set(CPACK_PACKAGE_VERSION ${HDCP_VERSION})
set(CPACK_PACKAGE_VENDOR "Intel")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "intel-uapi-hdcp deb package for internal usage only")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "intel unified hdcp deb package")
SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_SOURCE_DIR}/config/postinst)

set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel")
Expand Down
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ The Intel(R) unified HDCP is dependent on kernel space HDCP implementation to pr
1. Obtain Linux kernel from https://github.com/freedesktop/drm-tip
2. Follow below steps to build and upgrade kernel:
```
$ make ARCH=x86_64 defconfig  
$ make ARCH=x86_64 defconfig
$ make ARCH=x86_64 menuconfig
# include device driver->Network device driver->USB Network Adapters->the corresponding adapter if you use usb adapter for network hub.  
# include drivers->misc drivers->Intel Management Engine Interface & ME Enabled Intel Chipsets & Intel Trusted Execution Enviroment with ME Interface to enable MEI_HDCP for HDCP 2.2 
$ make -j 
$ make modules  
$ sudo make modules_install  
# include device driver->Network device driver->USB Network Adapters->the corresponding adapter if you use usb adapter for network hub.
# include drivers->misc drivers->Intel Management Engine Interface & ME Enabled Intel Chipsets & Intel Trusted Execution Enviroment with ME Interface to enable MEI_HDCP for HDCP 2.2
$ make -j
$ make modules
$ sudo make modules_install
$ sudo make install
```

Expand All @@ -49,12 +49,13 @@ $ sudo make install
|- sdk
|- common
|- CMakeLists.txt
...
```
3.
3. Create build folder, and generate targets in the directory
```
$ cd <workspace>
$ cmake CMakeLists.txt \
-DLIBDRM_INCLUDE_DIRS=/usr/local/include/libdrm
$ mkdir build; cd build
$ cmake ../
```
4. Then run
```
Expand All @@ -68,8 +69,12 @@ $ sudo make install
```
This will install the following files (e.g. on Ubuntu):
```
-- Installing: /usr/lib/x86_64-linux-gnu/libhdcpsdk.so
-- Installing: /usr/bin/hdcpd
-- Installing: /usr/local/bin/hdcpd
-- Installing: /usr/local/include/hdcpapi.h
-- Installing: /usr/local/lib/libhdcpsdk.so
-- Installing: /usr/local/lib/pkgconfig/libhdcpsdk.pc
-- Installing: /lib/systemd/system/hdcpd.service
-- ...
```


Expand Down Expand Up @@ -123,4 +128,4 @@ You may follow below basic steps for HDCP enabling:

7. App finishes playing protected content.

8. App is finished and calls HDCPDestroy. HDCP SDK cleans up and destroys its session with the daemon. The daemon will remove the App from a list of active applications using the port.
8. App is finished and calls HDCPDestroy. HDCP SDK cleans up and destroys its session with the daemon. The daemon will remove the App from a list of active applications using the port.
1 change: 1 addition & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ get_filename_component(HDCP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.." REALPATH)
include_directories(${HDCP_DIR}/sdk)

add_library(${PROJECT_NAME}
STATIC
clientsock.cpp
gensock.cpp
servsock.cpp
Expand Down
3 changes: 1 addition & 2 deletions config/hdcpd.service → config/hdcpd.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Description=hdcp daemon

[Service]
Type=simple
ExecStart=/usr/bin/hdcpd
User=root
ExecStart=@CMAKE_INSTALL_BINDIR@/hdcpd

[Install]
WantedBy=multi-user.target
10 changes: 10 additions & 0 deletions config/libhdcpsdk.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: @CMAKE_PROJECT_NAME@
Description: Intel Unified HDCP SDK
Version: @HDCP_VERSION@
Libs: -L${libdir} -lhdcpsdk
Cflags: -I${includedir}
4 changes: 3 additions & 1 deletion config/postinst
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash

systemctl disable hdcpd.service
systemctl enable hdcpd.service
systemctl start hdcpd.service
systemctl stop hdcpd.service
systemctl start hdcpd.service
47 changes: 47 additions & 0 deletions config/systemdservice.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright (c) 2018, Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

include(FindPkgConfig)

pkg_check_modules(SYSTEMD "systemd")

if (SYSTEMD_FOUND AND "${SYSTEMD_SERVICES_INSTALL_DIR}" STREQUAL "")
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
--variable=systemdsystemunitdir systemd
OUTPUT_VARIABLE SYSTEMD_SERVICES_INSTALL_DIR)
string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SERVICES_INSTALL_DIR
"${SYSTEMD_SERVICES_INSTALL_DIR}")
configure_file(${CMAKE_SOURCE_DIR}/config/hdcpd.service.in
${CMAKE_BINARY_DIR}/hdcpd.service
@ONLY)
install(FILES ${CMAKE_BINARY_DIR}/hdcpd.service DESTINATION
${SYSTEMD_SERVICES_INSTALL_DIR} COMPONENT cp)

elseif (NOT SYSTEMD_FOUND AND SYSTEMD_SERVICES_INSTALL_DIR)
message (FATAL_ERROR "Variable SYSTEMD_SERVICES_INSTALL_DIR is\
defined, but we can't find systemd using pkg-config")
endif()

if (SYSTEMD_FOUND)
set(WITH_SYSTEMD "ON")
message(STATUS "systemd services install dir: ${SYSTEMD_SERVICES_INSTALL_DIR}")
else()
set(WITH_SYSTEMD "OFF")
endif (SYSTEMD_FOUND)
7 changes: 1 addition & 6 deletions daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,14 @@ cmake_minimum_required(VERSION 2.8.12)

project(hdcpd CXX)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/")

find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)
if ("${LIBDRM_INCLUDE_DIRS}" STREQUAL "")
Message(FATAL_ERROR "libdrm include directory is not specified")
endif ()
pkg_check_modules(LIBDRM REQUIRED libdrm)

get_filename_component(HDCP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.." REALPATH)

include_directories(${OPENSSL_INCLUDE_DIRS})
include_directories(${LIBDRM_INCLUDE_DIRS})
include_directories(${LIBDRM_MODE_INCLUDE_DIRS})
include_directories(${HDCP_DIR}/common)
include_directories(${HDCP_DIR}/sdk)
include_directories(${HDCP_DIR}/daemon)
Expand Down
2 changes: 2 additions & 0 deletions sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ add_library(${PROJECT_NAME}

target_compile_options(${PROJECT_NAME} PRIVATE ${HDCP_CXX_FLAGS})
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS ${HDCP_LD_FLAGS})
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${HDCP_VERSION} SOVERSION ${HDCP_VERSION_MAJOR})

target_link_libraries(${PROJECT_NAME}
${CMAKE_THREAD_LIBS_INIT}
Expand Down

0 comments on commit 0b1e72f

Please sign in to comment.