Skip to content

CMake build system #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Sep 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
40c4260
CMake: build AvTranscoder
Sep 2, 2014
dcdccef
CMake: build cpp apps
Sep 2, 2014
f5b51aa
CMake: fix install of libraries
Sep 3, 2014
7373f56
CMake: fix java binding
Sep 3, 2014
cb22c08
CMake: fix build with dependency to libav
Sep 3, 2014
c1aa8e4
Gitignore: ignore CMake generated files
Sep 4, 2014
f6c6d42
Travis build: use CMake
Sep 8, 2014
5595b56
Travis build: remove install of python-git module
Sep 8, 2014
cdbc802
CMake: add cmake directory to have custom utilities
Sep 9, 2014
a5c72f9
CMake: get swresample or avresample
Sep 9, 2014
bab28bb
FindFFmpeg.cmake: manages REQUIRED statement
Sep 9, 2014
098fc87
FindFFmpeg.cmake: set FFMPEG_FOUND if FFmpeg is found on the system
Sep 9, 2014
2053bee
CMake: clean find java package
Sep 9, 2014
4b06105
Travis: add install libxmu-dev
Sep 9, 2014
9f03569
Merge branch 'master' of https://github.com/avTranscoder/avTranscoder…
Sep 9, 2014
94e1e69
CMake: define preprocessor macro AVTRANSCODER_VERSION_... through cmake
Sep 9, 2014
0d545aa
CMake: clean javac and jar command
Sep 9, 2014
a127ede
Travis: fix build
Sep 9, 2014
3a14d71
FindFFmpeg.cmake: add comments
Sep 9, 2014
03a828d
CMake: no compiler chosen
Sep 9, 2014
f5a7047
CMake: set verbose mode off
Sep 9, 2014
798c780
CMake: update permissions of executable apps
Sep 9, 2014
57e5775
CMake: update name of man apps
Sep 9, 2014
a084402
CMake: refactoring variable to check RESAMPLE_LIBRARY
Sep 9, 2014
1db0ec1
CMake: update jar name
Sep 9, 2014
1da0ec2
CMake: fix versioning of dynamic avtranscoder library
Sep 10, 2014
85b9ee7
CMake: add version to avtranscoder-py dynamic library
Sep 10, 2014
bd52b12
CMake: add version to avtranscoder-java dynamic library
Sep 10, 2014
da41972
CMake: python file and its directory in lower case
Sep 10, 2014
287c5f1
CMake: add version to cpp apps
Sep 10, 2014
3c07530
CMake: generate bindings only if possible
Sep 10, 2014
c464d6e
CMake: check python version when install corresponding binding
Sep 10, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ config.log
scons.cfg
build
dist

# CMake
CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
install_manifest.txt
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ before_script:
- sudo apt-add-repository "deb http://security.ubuntu.com/ubuntu trusty-security main restricted universe multiverse"
- sudo apt-get update -qq
- sudo apt-get install -qq gcc g++ scons swig swig2.0
- sudo apt-get install -qq libavdevice-dev libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libavresample-dev python-dev freeglut3-dev doxygen python-git
- sudo apt-get install -qq libavdevice-dev libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libavresample-dev python-dev freeglut3-dev libxmu-dev doxygen

script:
- scons
- mkdir build && cd build && cmake ../ && make

after_failure:
- cat config.log
Expand Down
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 2.8)

project(AvTranscoder)

# Set AvTranscoder versions
set(AVTRANSCODER_VERSION_MAJOR "0")
set(AVTRANSCODER_VERSION_MINOR "2")
set(AVTRANSCODER_VERSION_MICRO "1")
set(AVTRANSCODER_VERSION ${AVTRANSCODER_VERSION_MAJOR}.${AVTRANSCODER_VERSION_MINOR}.${AVTRANSCODER_VERSION_MICRO})

# Define AvTranscoder versions
add_definitions(-DAVTRANSCODER_VERSION_MAJOR=${AVTRANSCODER_VERSION_MAJOR})
add_definitions(-DAVTRANSCODER_VERSION_MINOR=${AVTRANSCODER_VERSION_MINOR})
add_definitions(-DAVTRANSCODER_VERSION_MICRO=${AVTRANSCODER_VERSION_MICRO})

# Diplay commands being ran by CMake
set(CMAKE_VERBOSE_MAKEFILE OFF)

# CPP flags on debug / release mode
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fPIC -pg -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIC -O3")

add_subdirectory(src)
add_subdirectory(app)
7 changes: 7 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
add_subdirectory(cpp/avInfo)
add_subdirectory(cpp/avMeta)
add_subdirectory(cpp/avplay)
add_subdirectory(cpp/avTranscoder)
add_subdirectory(cpp/genericProcessor)
add_subdirectory(cpp/optionChecker)
add_subdirectory(cpp/presetChecker)
23 changes: 23 additions & 0 deletions app/cpp/avInfo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### cpp/avInfo

# Load custom cmake utilities
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(AvTranscoderMacros)

# Build app
include_directories(${AVTRANSCODER_SRC_PATH})
add_executable(avinfo avInfo.cpp)
set_target_properties(avinfo PROPERTIES VERSION ${AVTRANSCODER_VERSION})
target_link_libraries(avinfo avtranscoder-shared)

# Install app
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/avinfo" "${CMAKE_CURRENT_BINARY_DIR}/avinfo-${AVTRANSCODER_VERSION}"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
DESTINATION "bin/"
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/avinfo.man
RENAME "avinfo.1"
DESTINATION "share/man/man1/"
)
23 changes: 23 additions & 0 deletions app/cpp/avMeta/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### cpp/avMeta

# Load custom cmake utilities
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(AvTranscoderMacros)

# Build app
include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
add_executable(avmeta avMeta.cpp)
set_target_properties(avmeta PROPERTIES VERSION ${AVTRANSCODER_VERSION})
target_link_libraries(avmeta avtranscoder-shared)

# Install app
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/avmeta" "${CMAKE_CURRENT_BINARY_DIR}/avmeta-${AVTRANSCODER_VERSION}"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
DESTINATION "bin/"
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/avmeta.man
RENAME "avmeta.1"
DESTINATION "share/man/man1/"
)
23 changes: 23 additions & 0 deletions app/cpp/avTranscoder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### cpp/avTranscoder

# Load custom cmake utilities
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(AvTranscoderMacros)

# Build app
include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
add_executable(avtranscoder avTranscoder.cpp)
set_target_properties(avtranscoder PROPERTIES VERSION ${AVTRANSCODER_VERSION})
target_link_libraries(avtranscoder avtranscoder-shared)

# Install app
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/avtranscoder" "${CMAKE_CURRENT_BINARY_DIR}/avtranscoder-${AVTRANSCODER_VERSION}"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
DESTINATION "bin/"
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/av++.man
RENAME av++.1
DESTINATION "share/man/man1/"
)
29 changes: 29 additions & 0 deletions app/cpp/avplay/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### cpp/avplay

# Load custom cmake utilities
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(AvTranscoderMacros)

# Build app
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)

include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} )

file(GLOB AVPLAY_SRC_FILES "*.cpp" "*.hpp")
add_executable(avplay ${AVPLAY_SRC_FILES})
set_target_properties(avplay PROPERTIES VERSION ${AVTRANSCODER_VERSION})
target_link_libraries(avplay avtranscoder-shared ${OPENGL_LIBRARIES} ${GLUT_LIBRARY})

# Install app
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/avplay" "${CMAKE_CURRENT_BINARY_DIR}/avplay-${AVTRANSCODER_VERSION}"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
DESTINATION "bin/"
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/avplayer.man
RENAME avplayer.1
DESTINATION "share/man/man1/"
)
23 changes: 23 additions & 0 deletions app/cpp/genericProcessor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### cpp/avProcessor

# Load custom cmake utilities
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(AvTranscoderMacros)

# Build app
include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
add_executable(avprocessor genericProcessor.cpp)
set_target_properties(avprocessor PROPERTIES VERSION ${AVTRANSCODER_VERSION})
target_link_libraries(avprocessor avtranscoder-shared)

# Install app
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/avprocessor" "${CMAKE_CURRENT_BINARY_DIR}/avprocessor-${AVTRANSCODER_VERSION}"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
DESTINATION "bin/"
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/avprocessor.man
RENAME avprocessor.1
DESTINATION "share/man/man1/"
)
20 changes: 20 additions & 0 deletions app/cpp/optionChecker/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### cpp/avOptionChecker

# Load custom cmake utilities
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(AvTranscoderMacros)

# Build app
include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
# Add C++11 flag
set(CMAKE_CXX_FLAGS "-std=c++0x")
add_executable(avoptionchecker optionChecker.cpp)
set_target_properties(avoptionchecker PROPERTIES VERSION ${AVTRANSCODER_VERSION})
target_link_libraries(avoptionchecker avtranscoder-shared)

# Install app
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/avoptionchecker" "${CMAKE_CURRENT_BINARY_DIR}/avoptionchecker-${AVTRANSCODER_VERSION}"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
DESTINATION "bin/"
)
25 changes: 25 additions & 0 deletions app/cpp/presetChecker/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
### cpp/avPresetChecker

# Load custom cmake utilities
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(AvTranscoderMacros)

# Build app
include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
# Add C++11 flag
set(CMAKE_CXX_FLAGS "-std=c++0x")
add_executable(avpresetchecker presetChecker.cpp)
set_target_properties(avpresetchecker PROPERTIES VERSION ${AVTRANSCODER_VERSION})
target_link_libraries(avpresetchecker avtranscoder-shared)

# Install app
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/avpresetchecker" "${CMAKE_CURRENT_BINARY_DIR}/avpresetchecker-${AVTRANSCODER_VERSION}"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
DESTINATION "bin/"
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/avprofiles.man
RENAME avprofiles.1
DESTINATION "share/man/man1/"
)
4 changes: 4 additions & 0 deletions cmake/AvTranscoderMacros.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Get useful variables
set(AVTRANSCODER_APP_PATH "${PROJECT_SOURCE_DIR}/app")
set(AVTRANSCODER_SRC_PATH "${PROJECT_SOURCE_DIR}/src")
file(GLOB_RECURSE AVTRANSCODER_SRC_FILES "AvTranscoder/*.cpp" "AvTranscoder/*.hpp")
119 changes: 119 additions & 0 deletions cmake/FindFFmpeg.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# - Find FFmpeg library
# Find the native FFmpeg includes and library.
#
# This module defines:
# FFMPEG_FOUND
# FFMPEG_INCLUDE_DIR - The FFmpeg include directory.
# FFMPEG_LIBRARIES - The FFmpeg libraries.
# FFMPEG_DEFINITIONS - The FFmpeg compile flags.
#
# For each component:
# ${COMPONENT}_FOUND
# ${COMPONENT}_INCLUDE_DIR
# ${COMPONENT}_LIBRARIES
# ${COMPONENT}_DEFINITIONS
# ${COMPONENT}_VERSION
#
# If any component is specified, default components are avcodec avformat avutil.
#

### Macro: check_ffmpeg_version
#
# Check FFmpeg version.
# @todo: clean how to get current FFmpeg version.
#
macro(check_ffmpeg_version)
exec_program("ffmpeg -version 2>&1 | grep 'ffmpeg version' | sed -e 's/ffmpeg\ version\ //'"
OUTPUT_VARIABLE FFmpeg_CURRENT_VERSION)
if(${FFmpeg_CURRENT_VERSION} LESS ${FFmpeg_FIND_VERSION})
message(SEND_ERROR "Your FFmpeg version is too old (${FFmpeg_CURRENT_VERSION} < ${FFmpeg_FIND_VERSION}).")
endif()
endmacro()


### Macro: find_component
#
# Check the given component by invoking pkgconfig and
# then looking up the libraries and include directories.
# @todo: WIN and MAC OSX.
#
macro(find_component COMPONENT PKGCONFIG LIBRARY HEADER)
if(NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_${COMPONENT} ${PKGCONFIG})
endif()
endif()

find_path(${COMPONENT}_INCLUDE_DIR
${HEADER}
PATH ${PC_LIB${COMPONENT}_INCLUDEDIR} ${PC_LIB${COMPONENT}_INCLUDE_DIR}
PATH_SUFFIXES ffmpeg libav
)

find_library(${COMPONENT}_LIBRARIES
NAMES ${LIBRARY}
PATH ${PC_LIB${COMPONENT}_LIBDIR} ${PC_LIB${COMPONENT}_LIBRARY_DIRS}
)

set(${COMPONENT}_DEFINITIONS ${PC_${COMPONENT}_CFLAGS_OTHER} CACHE STRING "The ${COMPONENT} CFLAGS.")
set(${COMPONENT}_VERSION ${PC_${COMPONENT}_VERSION} CACHE STRING "The ${COMPONENT} version number.")

# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIR is present.
if(${COMPONENT}_LIBRARIES AND ${COMPONENT}_INCLUDE_DIR)
set(${COMPONENT}_FOUND TRUE)
else()
set(${COMPONENT}_FOUND FALSE)
endif()

mark_as_advanced(
${COMPONENT}_INCLUDE_DIR
${COMPONENT}_LIBRARIES
${COMPONENT}_DEFINITIONS
${COMPONENT}_VERSION
)
endmacro()

# Get FFmpeg from custom install
if(FFMPEG_LIBRARY_DIR AND FFMPEG_INCLUDE_DIR)
set(FFMPEG_FOUND TRUE)
file(GLOB FFMPEG_LIBRARIES "${FFMPEG_LIBRARY_DIR}/*.so")
# Get FFmpeg from system install
else()
# Check FFmpeg version
if(DEFINED FFmpeg_FIND_VERSION)
check_ffmpeg_version()
endif()

if(NOT FFmpeg_FIND_COMPONENTS)
set(FFmpeg_FIND_COMPONENTS avcodec avformat avutil)
endif()

# Check components and add their stuff to the FFMPEG_* vars.
foreach(COMPONENT ${FFmpeg_FIND_COMPONENTS})
# Get component name is lower cases.
string(TOLOWER ${COMPONENT} LOWERCOMPONENT)
find_component(${COMPONENT} lib${LOWERCOMPONENT} ${LOWERCOMPONENT} lib${LOWERCOMPONENT}/${LOWERCOMPONENT}.h)
# If the component is found.
if(${COMPONENT}_FOUND)
message(STATUS "Component ${COMPONENT} present.")
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${COMPONENT}_LIBRARIES})
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${COMPONENT}_DEFINITIONS})
list(APPEND FFMPEG_INCLUDE_DIR ${${COMPONENT}_INCLUDE_DIR})
else()
if(FFmpeg_FIND_REQUIRED)
message(SEND_ERROR "Error: required component ${COMPONENT} missing.")
else()
message(STATUS "Warning: component ${COMPONENT} missing.")
endif()
endif()
endforeach()

# Build the include path with duplicates removed.
if(FFMPEG_INCLUDE_DIR)
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIR)
set(FFMPEG_FOUND TRUE)
endif()
endif()
Loading