Skip to content

Commit 2ad9fbd

Browse files
Merge pull request #79 from cchampet/build_CMake
CMake build system
2 parents 9e8f54d + c464d6e commit 2ad9fbd

File tree

14 files changed

+457
-2
lines changed

14 files changed

+457
-2
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ config.log
1818
scons.cfg
1919
build
2020
dist
21+
22+
# CMake
23+
CMakeCache.txt
24+
CMakeFiles
25+
Makefile
26+
cmake_install.cmake
27+
install_manifest.txt

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ before_script:
1717
- sudo apt-add-repository "deb http://security.ubuntu.com/ubuntu trusty-security main restricted universe multiverse"
1818
- sudo apt-get update -qq
1919
- sudo apt-get install -qq gcc g++ scons swig swig2.0
20-
- sudo apt-get install -qq libavdevice-dev libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libavresample-dev python-dev freeglut3-dev doxygen python-git
20+
- sudo apt-get install -qq libavdevice-dev libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libavresample-dev python-dev freeglut3-dev libxmu-dev doxygen
2121

2222
script:
23-
- scons
23+
- mkdir build && cd build && cmake ../ && make
2424

2525
after_failure:
2626
- cat config.log

CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cmake_minimum_required(VERSION 2.8)
2+
3+
project(AvTranscoder)
4+
5+
# Set AvTranscoder versions
6+
set(AVTRANSCODER_VERSION_MAJOR "0")
7+
set(AVTRANSCODER_VERSION_MINOR "2")
8+
set(AVTRANSCODER_VERSION_MICRO "1")
9+
set(AVTRANSCODER_VERSION ${AVTRANSCODER_VERSION_MAJOR}.${AVTRANSCODER_VERSION_MINOR}.${AVTRANSCODER_VERSION_MICRO})
10+
11+
# Define AvTranscoder versions
12+
add_definitions(-DAVTRANSCODER_VERSION_MAJOR=${AVTRANSCODER_VERSION_MAJOR})
13+
add_definitions(-DAVTRANSCODER_VERSION_MINOR=${AVTRANSCODER_VERSION_MINOR})
14+
add_definitions(-DAVTRANSCODER_VERSION_MICRO=${AVTRANSCODER_VERSION_MICRO})
15+
16+
# Diplay commands being ran by CMake
17+
set(CMAKE_VERBOSE_MAKEFILE OFF)
18+
19+
# CPP flags on debug / release mode
20+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fPIC -pg -g")
21+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIC -O3")
22+
23+
add_subdirectory(src)
24+
add_subdirectory(app)

app/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
add_subdirectory(cpp/avInfo)
2+
add_subdirectory(cpp/avMeta)
3+
add_subdirectory(cpp/avplay)
4+
add_subdirectory(cpp/avTranscoder)
5+
add_subdirectory(cpp/genericProcessor)
6+
add_subdirectory(cpp/optionChecker)
7+
add_subdirectory(cpp/presetChecker)

app/cpp/avInfo/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
### cpp/avInfo
2+
3+
# Load custom cmake utilities
4+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
5+
include(AvTranscoderMacros)
6+
7+
# Build app
8+
include_directories(${AVTRANSCODER_SRC_PATH})
9+
add_executable(avinfo avInfo.cpp)
10+
set_target_properties(avinfo PROPERTIES VERSION ${AVTRANSCODER_VERSION})
11+
target_link_libraries(avinfo avtranscoder-shared)
12+
13+
# Install app
14+
install(
15+
FILES "${CMAKE_CURRENT_BINARY_DIR}/avinfo" "${CMAKE_CURRENT_BINARY_DIR}/avinfo-${AVTRANSCODER_VERSION}"
16+
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
17+
DESTINATION "bin/"
18+
)
19+
install(
20+
FILES ${CMAKE_CURRENT_SOURCE_DIR}/avinfo.man
21+
RENAME "avinfo.1"
22+
DESTINATION "share/man/man1/"
23+
)

app/cpp/avMeta/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
### cpp/avMeta
2+
3+
# Load custom cmake utilities
4+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
5+
include(AvTranscoderMacros)
6+
7+
# Build app
8+
include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
9+
add_executable(avmeta avMeta.cpp)
10+
set_target_properties(avmeta PROPERTIES VERSION ${AVTRANSCODER_VERSION})
11+
target_link_libraries(avmeta avtranscoder-shared)
12+
13+
# Install app
14+
install(
15+
FILES "${CMAKE_CURRENT_BINARY_DIR}/avmeta" "${CMAKE_CURRENT_BINARY_DIR}/avmeta-${AVTRANSCODER_VERSION}"
16+
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
17+
DESTINATION "bin/"
18+
)
19+
install(
20+
FILES ${CMAKE_CURRENT_SOURCE_DIR}/avmeta.man
21+
RENAME "avmeta.1"
22+
DESTINATION "share/man/man1/"
23+
)

app/cpp/avTranscoder/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
### cpp/avTranscoder
2+
3+
# Load custom cmake utilities
4+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
5+
include(AvTranscoderMacros)
6+
7+
# Build app
8+
include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
9+
add_executable(avtranscoder avTranscoder.cpp)
10+
set_target_properties(avtranscoder PROPERTIES VERSION ${AVTRANSCODER_VERSION})
11+
target_link_libraries(avtranscoder avtranscoder-shared)
12+
13+
# Install app
14+
install(
15+
FILES "${CMAKE_CURRENT_BINARY_DIR}/avtranscoder" "${CMAKE_CURRENT_BINARY_DIR}/avtranscoder-${AVTRANSCODER_VERSION}"
16+
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
17+
DESTINATION "bin/"
18+
)
19+
install(
20+
FILES ${CMAKE_CURRENT_SOURCE_DIR}/av++.man
21+
RENAME av++.1
22+
DESTINATION "share/man/man1/"
23+
)

app/cpp/avplay/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### cpp/avplay
2+
3+
# Load custom cmake utilities
4+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
5+
include(AvTranscoderMacros)
6+
7+
# Build app
8+
find_package(OpenGL REQUIRED)
9+
find_package(GLUT REQUIRED)
10+
11+
include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
12+
include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} )
13+
14+
file(GLOB AVPLAY_SRC_FILES "*.cpp" "*.hpp")
15+
add_executable(avplay ${AVPLAY_SRC_FILES})
16+
set_target_properties(avplay PROPERTIES VERSION ${AVTRANSCODER_VERSION})
17+
target_link_libraries(avplay avtranscoder-shared ${OPENGL_LIBRARIES} ${GLUT_LIBRARY})
18+
19+
# Install app
20+
install(
21+
FILES "${CMAKE_CURRENT_BINARY_DIR}/avplay" "${CMAKE_CURRENT_BINARY_DIR}/avplay-${AVTRANSCODER_VERSION}"
22+
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
23+
DESTINATION "bin/"
24+
)
25+
install(
26+
FILES ${CMAKE_CURRENT_SOURCE_DIR}/avplayer.man
27+
RENAME avplayer.1
28+
DESTINATION "share/man/man1/"
29+
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
### cpp/avProcessor
2+
3+
# Load custom cmake utilities
4+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
5+
include(AvTranscoderMacros)
6+
7+
# Build app
8+
include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
9+
add_executable(avprocessor genericProcessor.cpp)
10+
set_target_properties(avprocessor PROPERTIES VERSION ${AVTRANSCODER_VERSION})
11+
target_link_libraries(avprocessor avtranscoder-shared)
12+
13+
# Install app
14+
install(
15+
FILES "${CMAKE_CURRENT_BINARY_DIR}/avprocessor" "${CMAKE_CURRENT_BINARY_DIR}/avprocessor-${AVTRANSCODER_VERSION}"
16+
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
17+
DESTINATION "bin/"
18+
)
19+
install(
20+
FILES ${CMAKE_CURRENT_SOURCE_DIR}/avprocessor.man
21+
RENAME avprocessor.1
22+
DESTINATION "share/man/man1/"
23+
)

app/cpp/optionChecker/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
### cpp/avOptionChecker
2+
3+
# Load custom cmake utilities
4+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
5+
include(AvTranscoderMacros)
6+
7+
# Build app
8+
include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
9+
# Add C++11 flag
10+
set(CMAKE_CXX_FLAGS "-std=c++0x")
11+
add_executable(avoptionchecker optionChecker.cpp)
12+
set_target_properties(avoptionchecker PROPERTIES VERSION ${AVTRANSCODER_VERSION})
13+
target_link_libraries(avoptionchecker avtranscoder-shared)
14+
15+
# Install app
16+
install(
17+
FILES "${CMAKE_CURRENT_BINARY_DIR}/avoptionchecker" "${CMAKE_CURRENT_BINARY_DIR}/avoptionchecker-${AVTRANSCODER_VERSION}"
18+
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
19+
DESTINATION "bin/"
20+
)

app/cpp/presetChecker/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### cpp/avPresetChecker
2+
3+
# Load custom cmake utilities
4+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
5+
include(AvTranscoderMacros)
6+
7+
# Build app
8+
include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
9+
# Add C++11 flag
10+
set(CMAKE_CXX_FLAGS "-std=c++0x")
11+
add_executable(avpresetchecker presetChecker.cpp)
12+
set_target_properties(avpresetchecker PROPERTIES VERSION ${AVTRANSCODER_VERSION})
13+
target_link_libraries(avpresetchecker avtranscoder-shared)
14+
15+
# Install app
16+
install(
17+
FILES "${CMAKE_CURRENT_BINARY_DIR}/avpresetchecker" "${CMAKE_CURRENT_BINARY_DIR}/avpresetchecker-${AVTRANSCODER_VERSION}"
18+
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
19+
DESTINATION "bin/"
20+
)
21+
install(
22+
FILES ${CMAKE_CURRENT_SOURCE_DIR}/avprofiles.man
23+
RENAME avprofiles.1
24+
DESTINATION "share/man/man1/"
25+
)

cmake/AvTranscoderMacros.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Get useful variables
2+
set(AVTRANSCODER_APP_PATH "${PROJECT_SOURCE_DIR}/app")
3+
set(AVTRANSCODER_SRC_PATH "${PROJECT_SOURCE_DIR}/src")
4+
file(GLOB_RECURSE AVTRANSCODER_SRC_FILES "AvTranscoder/*.cpp" "AvTranscoder/*.hpp")

cmake/FindFFmpeg.cmake

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# - Find FFmpeg library
2+
# Find the native FFmpeg includes and library.
3+
#
4+
# This module defines:
5+
# FFMPEG_FOUND
6+
# FFMPEG_INCLUDE_DIR - The FFmpeg include directory.
7+
# FFMPEG_LIBRARIES - The FFmpeg libraries.
8+
# FFMPEG_DEFINITIONS - The FFmpeg compile flags.
9+
#
10+
# For each component:
11+
# ${COMPONENT}_FOUND
12+
# ${COMPONENT}_INCLUDE_DIR
13+
# ${COMPONENT}_LIBRARIES
14+
# ${COMPONENT}_DEFINITIONS
15+
# ${COMPONENT}_VERSION
16+
#
17+
# If any component is specified, default components are avcodec avformat avutil.
18+
#
19+
20+
### Macro: check_ffmpeg_version
21+
#
22+
# Check FFmpeg version.
23+
# @todo: clean how to get current FFmpeg version.
24+
#
25+
macro(check_ffmpeg_version)
26+
exec_program("ffmpeg -version 2>&1 | grep 'ffmpeg version' | sed -e 's/ffmpeg\ version\ //'"
27+
OUTPUT_VARIABLE FFmpeg_CURRENT_VERSION)
28+
if(${FFmpeg_CURRENT_VERSION} LESS ${FFmpeg_FIND_VERSION})
29+
message(SEND_ERROR "Your FFmpeg version is too old (${FFmpeg_CURRENT_VERSION} < ${FFmpeg_FIND_VERSION}).")
30+
endif()
31+
endmacro()
32+
33+
34+
### Macro: find_component
35+
#
36+
# Check the given component by invoking pkgconfig and
37+
# then looking up the libraries and include directories.
38+
# @todo: WIN and MAC OSX.
39+
#
40+
macro(find_component COMPONENT PKGCONFIG LIBRARY HEADER)
41+
if(NOT WIN32)
42+
# use pkg-config to get the directories and then use these values
43+
# in the FIND_PATH() and FIND_LIBRARY() calls
44+
find_package(PkgConfig)
45+
if(PKG_CONFIG_FOUND)
46+
pkg_check_modules(PC_${COMPONENT} ${PKGCONFIG})
47+
endif()
48+
endif()
49+
50+
find_path(${COMPONENT}_INCLUDE_DIR
51+
${HEADER}
52+
PATH ${PC_LIB${COMPONENT}_INCLUDEDIR} ${PC_LIB${COMPONENT}_INCLUDE_DIR}
53+
PATH_SUFFIXES ffmpeg libav
54+
)
55+
56+
find_library(${COMPONENT}_LIBRARIES
57+
NAMES ${LIBRARY}
58+
PATH ${PC_LIB${COMPONENT}_LIBDIR} ${PC_LIB${COMPONENT}_LIBRARY_DIRS}
59+
)
60+
61+
set(${COMPONENT}_DEFINITIONS ${PC_${COMPONENT}_CFLAGS_OTHER} CACHE STRING "The ${COMPONENT} CFLAGS.")
62+
set(${COMPONENT}_VERSION ${PC_${COMPONENT}_VERSION} CACHE STRING "The ${COMPONENT} version number.")
63+
64+
# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIR is present.
65+
if(${COMPONENT}_LIBRARIES AND ${COMPONENT}_INCLUDE_DIR)
66+
set(${COMPONENT}_FOUND TRUE)
67+
else()
68+
set(${COMPONENT}_FOUND FALSE)
69+
endif()
70+
71+
mark_as_advanced(
72+
${COMPONENT}_INCLUDE_DIR
73+
${COMPONENT}_LIBRARIES
74+
${COMPONENT}_DEFINITIONS
75+
${COMPONENT}_VERSION
76+
)
77+
endmacro()
78+
79+
# Get FFmpeg from custom install
80+
if(FFMPEG_LIBRARY_DIR AND FFMPEG_INCLUDE_DIR)
81+
set(FFMPEG_FOUND TRUE)
82+
file(GLOB FFMPEG_LIBRARIES "${FFMPEG_LIBRARY_DIR}/*.so")
83+
# Get FFmpeg from system install
84+
else()
85+
# Check FFmpeg version
86+
if(DEFINED FFmpeg_FIND_VERSION)
87+
check_ffmpeg_version()
88+
endif()
89+
90+
if(NOT FFmpeg_FIND_COMPONENTS)
91+
set(FFmpeg_FIND_COMPONENTS avcodec avformat avutil)
92+
endif()
93+
94+
# Check components and add their stuff to the FFMPEG_* vars.
95+
foreach(COMPONENT ${FFmpeg_FIND_COMPONENTS})
96+
# Get component name is lower cases.
97+
string(TOLOWER ${COMPONENT} LOWERCOMPONENT)
98+
find_component(${COMPONENT} lib${LOWERCOMPONENT} ${LOWERCOMPONENT} lib${LOWERCOMPONENT}/${LOWERCOMPONENT}.h)
99+
# If the component is found.
100+
if(${COMPONENT}_FOUND)
101+
message(STATUS "Component ${COMPONENT} present.")
102+
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${COMPONENT}_LIBRARIES})
103+
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${COMPONENT}_DEFINITIONS})
104+
list(APPEND FFMPEG_INCLUDE_DIR ${${COMPONENT}_INCLUDE_DIR})
105+
else()
106+
if(FFmpeg_FIND_REQUIRED)
107+
message(SEND_ERROR "Error: required component ${COMPONENT} missing.")
108+
else()
109+
message(STATUS "Warning: component ${COMPONENT} missing.")
110+
endif()
111+
endif()
112+
endforeach()
113+
114+
# Build the include path with duplicates removed.
115+
if(FFMPEG_INCLUDE_DIR)
116+
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIR)
117+
set(FFMPEG_FOUND TRUE)
118+
endif()
119+
endif()

0 commit comments

Comments
 (0)