From 528769c0918bccf0141d2b2be1c5f96ba06495ce Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Tue, 25 Jul 2017 12:16:59 +0200 Subject: [PATCH] allow QtAV to be used as a cmake external project --- CMakeLists.txt | 3 +++ examples/CMakeLists.txt | 4 ++-- qml/CMakeLists.txt | 2 +- src/CMakeLists.txt | 12 ++++++------ widgets/CMakeLists.txt | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef7ade074..5ce1729e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,7 @@ cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR) + +project(QTAV) + set(QTAV_MAJOR 1) set(QTAV_MINOR 11) set(QTAV_PATCH 0) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 32b3201cd..2f7ad26a2 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -101,7 +101,7 @@ if(Qt5Quick_FOUND) set(MODULE QMLPlayer) if(WIN32) set(RC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}.rc) - configure_file(${CMAKE_SOURCE_DIR}/cmake/QtAV.rc.in ${RC_FILE}) + configure_file(${QTAV_SOURCE_DIR}/cmake/QtAV.rc.in ${RC_FILE}) endif() add_executable(QMLPlayer ${EXE_TYPE} QMLPlayer/main.cpp @@ -120,7 +120,7 @@ if(Qt5Widgets_FOUND) set(MODULE Player) if(WIN32) set(RC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}.rc) - configure_file(${CMAKE_SOURCE_DIR}/cmake/QtAV.rc.in ${RC_FILE}) + configure_file(${QTAV_SOURCE_DIR}/cmake/QtAV.rc.in ${RC_FILE}) endif() add_executable(Player ${EXE_TYPE} ${PLAYER_SRC} ${PLAYER_HEADERS} ${PLAYER_RES} ${RC_FILE}) target_link_libraries(Player QtAVWidgets common) diff --git a/qml/CMakeLists.txt b/qml/CMakeLists.txt index ec2815e82..8a976888a 100644 --- a/qml/CMakeLists.txt +++ b/qml/CMakeLists.txt @@ -32,7 +32,7 @@ endif() # add HEADERS for moc if(WIN32) set(RC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}.rc) - configure_file(${CMAKE_SOURCE_DIR}/cmake/QtAV.rc.in ${RC_FILE}) + configure_file(${QTAV_SOURCE_DIR}/cmake/QtAV.rc.in ${RC_FILE}) endif() add_library(${MODULE} SHARED ${SOURCES} ${RESOURCES_SOURCES} ${HEADERS} ${RC_FILE}) target_link_libraries(${MODULE} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea97ad5a9..db84dbf89 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,8 +12,8 @@ INCLUDE(CheckTypeSize) include_directories(${QTDIR}/include) #TODO: remove. use external/include get_filename_component(QTDIR "${QTDIR}" ABSOLUTE) -list(APPEND EXTRA_INCLUDE ${CMAKE_SOURCE_DIR}/external/include) -list(APPEND EXTRA_LIBS ${CMAKE_LIBRARY_PATH_FLAG}${CMAKE_SOURCE_DIR}/external/lib) +list(APPEND EXTRA_INCLUDE ${QTAV_SOURCE_DIR}/external/include) +list(APPEND EXTRA_LIBS ${CMAKE_LIBRARY_PATH_FLAG}${QTAV_SOURCE_DIR}/external/lib) if(APPLE) if(IOS) #set_xcode_property(myioslib IPHONEOS_DEPLOYMENT_TARGET "8.0") @@ -22,9 +22,9 @@ if(APPLE) list(APPEND EXTRA_LIBS -L/usr/local/lib) endif() endif() -if(EXISTS ${CMAKE_SOURCE_DIR}/contrib/capi/capi.h) +if(EXISTS ${QTAV_SOURCE_DIR}/contrib/capi/capi.h) set(HAVE_CAPI 1) - list(APPEND EXTRA_INCLUDE ${CMAKE_SOURCE_DIR}/contrib/capi) # TODO: only files use capi.h + list(APPEND EXTRA_INCLUDE ${QTAV_SOURCE_DIR}/contrib/capi) # TODO: only files use capi.h list(APPEND EXTRA_DEFS -DQTAV_HAVE_CAPI=1) endif() @@ -324,7 +324,7 @@ endif() if(WIN32 OR WindowsStore OR WindowsPhone) check_include_files(XAudio2.h HAVE_XAUDIO2_H) if(NOT HAVE_XAUDIO2_H) - list(APPEND EXTRA_INCLUDE ${CMAKE_SOURCE_DIR}/contrib/dxsdk) + list(APPEND EXTRA_INCLUDE ${QTAV_SOURCE_DIR}/contrib/dxsdk) endif() message("Qt5Gui_EGL_INCLUDE_DIRS: ${Qt5Gui_EGL_INCLUDE_DIRS}") list(APPEND HEADERS @@ -473,7 +473,7 @@ QT5_ADD_RESOURCES(RESOURCES_SOURCES ${RESOURCES}) set_source_files_properties(${RESOURCES_SOURCES} PROPERTIES GENERATED ON) if(WIN32) set(RC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}.rc) - configure_file(${CMAKE_SOURCE_DIR}/cmake/QtAV.rc.in ${RC_FILE}) + configure_file(${QTAV_SOURCE_DIR}/cmake/QtAV.rc.in ${RC_FILE}) endif() # add HEADERS for moc add_library(${MODULE} SHARED ${SOURCES} ${RESOURCES_SOURCES} ${HEADERS} ${RC_FILE}) diff --git a/widgets/CMakeLists.txt b/widgets/CMakeLists.txt index 0084f8e76..2cbe0518c 100644 --- a/widgets/CMakeLists.txt +++ b/widgets/CMakeLists.txt @@ -43,7 +43,7 @@ endif() set(HEADERS ${SDK_HEADERS}) if(WIN32) set(RC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}.rc) - configure_file(${CMAKE_SOURCE_DIR}/cmake/QtAV.rc.in ${RC_FILE}) + configure_file(${QTAV_SOURCE_DIR}/cmake/QtAV.rc.in ${RC_FILE}) endif() # add HEADERS for moc add_library(${MODULE} SHARED ${SOURCES} ${RESOURCES_SOURCES} ${HEADERS} ${RC_FILE})