Skip to content
Permalink
Browse files

Cumulative update for build system

 - Add `pkg-config` for `libmfx.a`. It fixes #1.
 - Support for Cmake v3.0+ (removed redefinition of `CMAKE_SOURCE_DIR`)
 - Update install procedure to copy `libmfx.a` (with `pkg-config`) and header
   files
 - Take into account lightweight tags for `git annotate`
  • Loading branch information
Maslennikov, Andrey committed May 2, 2017
1 parent cb25e4c commit 92b6ee70f5ea45d08527f81cb93105f9ee71d84e
@@ -125,3 +125,19 @@ list(APPEND sources.plus
set( defs "-DMFX_DISPATCHER_LOG -DDXVA2DEVICE_LOG ${WARNING_FLAGS}" )
make_static_library( dispatch_trace )

get_mfx_version(MFX_VERSION_MAJOR MFX_VERSION_MINOR)
set( PKG_CONFIG_FNAME "${CMAKE_LIB_DIR}/${CMAKE_BUILD_TYPE}/${PROJECT_NAME}.pc")

set( INSTALL_LIB_PATH "lib/lin_x86" )
if(__ARCH MATCHES intel64)
set( INSTALL_LIB_PATH "lib/lin_x64" )
endif( )

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pkg-config.pc.cmake" ${PKG_CONFIG_FNAME} @ONLY)

install( TARGETS mfx ARCHIVE DESTINATION ${INSTALL_LIB_PATH} )
install( TARGETS dispatch_shared ARCHIVE DESTINATION ${INSTALL_LIB_PATH} )
install( TARGETS dispatch_trace ARCHIVE DESTINATION ${INSTALL_LIB_PATH} )
install( FILES ${PKG_CONFIG_FNAME} DESTINATION "${INSTALL_LIB_PATH}/pkgconfig" )

install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../include/ DESTINATION include FILES_MATCHING PATTERN *.h )
@@ -0,0 +1,9 @@
Name: @PROJECT_NAME@
Description: Intel(R) Media SDK Dispatcher
Version: @MFX_VERSION_MAJOR@.@MFX_VERSION_MINOR@

prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_PREFIX@/@INSTALL_LIB_PATH@
includedir=@CMAKE_INSTALL_PREFIX@/include
Libs: -L${libdir} -lmfx
Cflags: -I${includedir}
@@ -102,12 +102,18 @@ function( get_folder folder )
set (${ARGV0} ${folder} PARENT_SCOPE)
endfunction()

function( get_mfx_version mfx_version_major mfx_version_minor )
file(STRINGS $ENV{MFX_HOME}/api/include/mfxvideo.h major REGEX "#define MFX_VERSION_MAJOR")
file(STRINGS $ENV{MFX_HOME}/api/include/mfxvideo.h minor REGEX "#define MFX_VERSION_MINOR")
string(REPLACE "#define MFX_VERSION_MAJOR " "" major ${major})
string(REPLACE "#define MFX_VERSION_MINOR " "" minor ${minor})
set(${mfx_version_major} ${major} PARENT_SCOPE)
set(${mfx_version_minor} ${minor} PARENT_SCOPE)
endfunction()

function( gen_plugins_cfg plugin_id guid plugin_name type codecID )
file(STRINGS $ENV{MFX_HOME}/api/include/mfxvideo.h MFX_VERSION_MAJOR REGEX "#define MFX_VERSION_MAJOR")
file(STRINGS $ENV{MFX_HOME}/api/include/mfxvideo.h MFX_VERSION_MINOR REGEX "#define MFX_VERSION_MINOR")
string(REPLACE "#define MFX_VERSION_MAJOR " "" MFX_VERSION_MAJOR ${MFX_VERSION_MAJOR})
string(REPLACE "#define MFX_VERSION_MINOR " "" MFX_VERSION_MINOR ${MFX_VERSION_MINOR})
math(EXPR api_version "${MFX_VERSION_MAJOR}*256 + ${MFX_VERSION_MINOR}")
get_mfx_version(mfx_version_major mfx_version_minor)
math(EXPR api_version "${mfx_version_major}*256 + ${mfx_version_minor}")

if((NOT DEFINED ARGV5) OR (ARGV5 STREQUAL "eval"))
get_property( PLUGINS_EVAL_CFG GLOBAL PROPERTY PROP_PLUGINS_EVAL_CFG )
@@ -346,7 +352,7 @@ endfunction()

function( git_describe git_commit )
execute_process(
COMMAND git describe --dirty
COMMAND git describe --all --dirty
OUTPUT_VARIABLE git_commit
OUTPUT_STRIP_TRAILING_WHITESPACE
)
@@ -23,14 +23,15 @@ if( Linux )
elseif( Darwin )
set( os_arch "darwin" )
endif()

if( __ARCH MATCHES ia32)
set( os_arch "${os_arch}_ia32" )
else()
set( os_arch "${os_arch}_x64" )
endif()

if( Linux OR Darwin )
if(CMAKE_MFX_HOME)
if( CMAKE_MFX_HOME )
set( MFX_API_HOME ${CMAKE_MFX_HOME} )
else()
set( MFX_API_HOME $ENV{MFX_HOME} )
@@ -39,33 +40,36 @@ if( Linux OR Darwin )
find_path( MFX_INCLUDE mfxdefs.h PATHS ${MFX_API_HOME}/include )
find_library( MFX_LIBRARY libmfx.a PATHS ${MFX_API_HOME}/lib PATH_SUFFIXES ${os_arch} )

include_directories( ${MFX_INCLUDE} )
get_filename_component( MFX_LIBRARY_PATH ${MFX_LIBRARY} PATH )
link_directories( ${MFX_LIBRARY_PATH} )
if( NOT MFX_INCLUDE MATCHES NOTFOUND )
include_directories( ${MFX_API_HOME}/mediasdk_structures )
include_directories( ${MFX_INCLUDE} )
endif()

if( NOT MFX_LIBRARY MATCHES NOTFOUND )
get_filename_component( MFX_LIBRARY_PATH ${MFX_LIBRARY} PATH )
link_directories( ${MFX_LIBRARY_PATH} )
endif()
else()
set( MFX_INCLUDE NOTFOUND )
set( MFX_LIBRARY NOTFOUND )

endif()

if(NOT MFX_INCLUDE MATCHES NOTFOUND)
if( NOT MFX_INCLUDE MATCHES NOTFOUND )
set( MFX_FOUND TRUE )
include_directories( ${MFX_INCLUDE} )
endif()

if(NOT DEFINED MFX_FOUND)
if( NOT DEFINED MFX_FOUND )
message( FATAL_ERROR "Intel(R) Media SDK was not found (required)! Set/check MFX_HOME environment variable!")
else ()
else()
message( STATUS "Intel(R) Media SDK was found here $ENV{MFX_HOME}")
endif()

if(NOT MFX_LIBRARY MATCHES NOTFOUND)
if( NOT MFX_LIBRARY MATCHES NOTFOUND )
get_filename_component(MFX_LIBRARY_PATH ${MFX_LIBRARY} PATH )
link_directories( ${MFX_LIBRARY_PATH} )
endif()

if( Linux )
set(MFX_LDFLAGS "-Wl,--default-symver" )
set( MFX_LDFLAGS "-Wl,--default-symver" )
endif()

@@ -1,6 +1,6 @@
include_directories (
${CMAKE_SOURCE_DIR}/sample_common/include
${CMAKE_SOURCE_DIR}/sample_misc/wayland/include
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/../sample_misc/wayland/include
)

set( defs "${WARNING_FLAGS}" )
@@ -1,7 +1,7 @@
include_directories (
${CMAKE_SOURCE_DIR}/sample_common/include
${CMAKE_SOURCE_DIR}/sample_misc/wayland/include
${CMAKE_SOURCE_DIR}/sample_decode/include
${CMAKE_CURRENT_SOURCE_DIR}/../sample_common/include
${CMAKE_CURRENT_SOURCE_DIR}/../sample_misc/wayland/include
${CMAKE_CURRENT_SOURCE_DIR}/include
)

list( APPEND LIBS_VARIANT sample_common )
@@ -1,6 +1,6 @@
@echo off
::/******************************************************************************\
:: Copyright (c) 2005-2016, Intel Corporation
:: Copyright (c) 2005-2017, Intel Corporation
:: All rights reserved.
::
:: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -1,7 +1,7 @@
include_directories (
${CMAKE_SOURCE_DIR}/sample_common/include
${CMAKE_SOURCE_DIR}/sample_encode/include
${CMAKE_SOURCE_DIR}/sample_plugins/rotate_cpu/include
${CMAKE_CURRENT_SOURCE_DIR}/../sample_common/include
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/../sample_plugins/rotate_cpu/include
)

list( APPEND LIBS_VARIANT sample_common )
@@ -5,8 +5,8 @@ if(FEI_INCLUDE MATCHES NOTFOUND)
endif()

include_directories (
${CMAKE_SOURCE_DIR}/sample_common/include
${CMAKE_SOURCE_DIR}/sample_fei/include
${CMAKE_CURRENT_SOURCE_DIR}/../sample_common/include
${CMAKE_CURRENT_SOURCE_DIR}/include
)

list( APPEND LIBS_VARIANT sample_common )
@@ -2,8 +2,8 @@ if (NOT ENABLE_WAYLAND)
return()
endif()
include_directories (
${CMAKE_SOURCE_DIR}/sample_common/include
${CMAKE_SOURCE_DIR}/sample_misc/wayland/include
${CMAKE_CURRENT_SOURCE_DIR}/../../sample_common/include
${CMAKE_CURRENT_SOURCE_DIR}/include
)

list(APPEND LIBS sample_common)
@@ -1,9 +1,9 @@
include_directories (
${CMAKE_SOURCE_DIR}/sample_common/include
${CMAKE_SOURCE_DIR}/sample_misc/wayland/include
${CMAKE_SOURCE_DIR}/sample_multi_transcode/include
${CMAKE_SOURCE_DIR}/sample_plugins/vpp_plugin/include
${CMAKE_SOURCE_DIR}/sample_plugins/rotate_cpu/include
${CMAKE_CURRENT_SOURCE_DIR}/../sample_common/include
${CMAKE_CURRENT_SOURCE_DIR}/../sample_misc/wayland/include
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/../sample_plugins/vpp_plugin/include
${CMAKE_CURRENT_SOURCE_DIR}/../sample_plugins/rotate_cpu/include
)

list( APPEND LIBS_VARIANT sample_common )
@@ -1,8 +1,8 @@
set( PLUGINS_COMMON_PATH ${CMAKE_SOURCE_DIR}/sample_plugins/plugins_common_files )
set( PLUGINS_COMMON_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../plugins_common_files )

include_directories (
${CMAKE_SOURCE_DIR}/sample_common/include
${CMAKE_SOURCE_DIR}/sample_plugins/rotate_cpu/include
${CMAKE_CURRENT_SOURCE_DIR}/../../sample_common/include
${CMAKE_CURRENT_SOURCE_DIR}/include
)

set(LDFLAGS "${LDFLAGS} -Wl,--version-script=${PLUGINS_COMMON_PATH}/mfx_plugin.map" )
@@ -1,11 +1,11 @@
include( ${BUILDER_ROOT}/FindOpenCL.cmake )

set( PLUGINS_COMMON_PATH ${CMAKE_SOURCE_DIR}/sample_plugins/plugins_common_files )
set( PLUGINS_COMMON_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../plugins_common_files )


include_directories (
${CMAKE_SOURCE_DIR}/sample_common/include
${CMAKE_SOURCE_DIR}/sample_plugins/rotate_opencl/include
${CMAKE_CURRENT_SOURCE_DIR}/../../sample_common/include
${CMAKE_CURRENT_SOURCE_DIR}/include
)

set( LDFLAGS "${LDFLAGS} -Wl,--version-script=${PLUGINS_COMMON_PATH}/mfx_plugin.map" )
@@ -24,7 +24,7 @@ install( TARGETS ${target} LIBRARY DESTINATION ${MFX_SAMPLES_INSTALL_LIB_DIR} )
if ( DEFINED OPENCL_FOUND )
# copy .cl file into build directory
execute_process( COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_SOURCE_DIR}/sample_plugins/rotate_opencl/src/ocl_rotate.cl"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ocl_rotate.cl"
"${CMAKE_BIN_DIR}/${CMAKE_BUILD_TYPE}/ocl_rotate.cl" )

install( FILES src/ocl_rotate.cl DESTINATION ${MFX_SAMPLES_INSTALL_LIB_DIR} )
@@ -1,6 +1,6 @@
include_directories (
${CMAKE_SOURCE_DIR}/sample_common/include
${CMAKE_SOURCE_DIR}/sample_plugins/vpp_plugin/include
${CMAKE_CURRENT_SOURCE_DIR}/../../sample_common/include
${CMAKE_CURRENT_SOURCE_DIR}/include
)

make_library( shortname none static "nosafestring" )
@@ -1,6 +1,6 @@
include_directories (
${CMAKE_SOURCE_DIR}/sample_common/include
${CMAKE_SOURCE_DIR}/sample_vpp/include
${CMAKE_CURRENT_SOURCE_DIR}/../sample_common/include
${CMAKE_CURRENT_SOURCE_DIR}/include
)

list( APPEND LIBS_VARIANT sample_common )

0 comments on commit 92b6ee7

Please sign in to comment.