2015-02-13 20:23:40 +01:00
|
|
|
## Copyright (c) 2015 The WebM project authors. All Rights Reserved.
|
|
|
|
##
|
|
|
|
## Use of this source code is governed by a BSD-style license
|
|
|
|
## that can be found in the LICENSE file in the root of the source
|
|
|
|
## tree. An additional intellectual property rights grant can be found
|
|
|
|
## in the file PATENTS. All contributing project authors may
|
|
|
|
## be found in the AUTHORS file in the root of the source tree.
|
2016-02-24 19:03:37 +01:00
|
|
|
cmake_minimum_required(VERSION 3.2)
|
|
|
|
project(LIBWEBM CXX)
|
2015-02-13 20:23:40 +01:00
|
|
|
include("${CMAKE_CURRENT_SOURCE_DIR}/build/msvc_runtime.cmake")
|
|
|
|
|
2016-02-24 19:03:37 +01:00
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
include(CheckCXXSourceCompiles)
|
2016-01-25 21:13:34 +01:00
|
|
|
|
2016-02-24 19:03:37 +01:00
|
|
|
set(LIBWEBM_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
2016-01-22 20:24:55 +01:00
|
|
|
|
2016-02-24 19:03:37 +01:00
|
|
|
# Build/test configuration flags. Defined here for visibility.
|
|
|
|
option(ENABLE_WEBMTS "Enables WebM PES/TS support." ON)
|
2016-01-12 03:46:55 +01:00
|
|
|
option(ENABLE_TESTS "Enables tests." OFF)
|
|
|
|
set(GTEST_SRC_DIR "${LIBWEBM_SRC_DIR}/../googletest" CACHE PATH
|
|
|
|
"Path to Googletest git repository.")
|
|
|
|
|
|
|
|
# This directory is where libwebm will build googletest dependencies.
|
|
|
|
set(GTEST_BUILD_DIR "${CMAKE_BINARY_DIR}/googletest_build")
|
|
|
|
|
2016-02-24 19:03:37 +01:00
|
|
|
if (ENABLE_TESTS OR ENABLE_WEBMTS)
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR
|
|
|
|
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
|
|
|
|
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-std=c++11" HAVE_CXX11)
|
|
|
|
if (HAVE_CXX11)
|
|
|
|
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}" CACHE STRING "" FORCE)
|
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
|
2016-03-02 22:40:32 +01:00
|
|
|
# C++11 compile tests.
|
|
|
|
# TODO(tomfinegan): Move the C++11 tests into a cmake include.
|
2016-02-24 19:03:37 +01:00
|
|
|
if (MSVC OR HAVE_CXX11)
|
2016-03-02 22:40:32 +01:00
|
|
|
# std::unique_ptr
|
2016-02-24 19:03:37 +01:00
|
|
|
check_cxx_source_compiles("
|
|
|
|
#include <memory>
|
|
|
|
int main(int argc, const char* argv[]) {
|
|
|
|
std::unique_ptr<int> ptr;
|
|
|
|
(void)ptr;
|
|
|
|
return 0;
|
|
|
|
}"
|
|
|
|
HAVE_UNIQUE_PTR)
|
2016-03-02 22:40:32 +01:00
|
|
|
|
|
|
|
# default member values
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
struct Foo {
|
|
|
|
int a = 0;
|
|
|
|
};
|
|
|
|
int main(int argc, const char* argv[]) {
|
|
|
|
Foo bar;
|
|
|
|
(void)bar;
|
|
|
|
return 0;
|
|
|
|
}"
|
|
|
|
HAVE_DEFAULT_MEMBER_VALUES)
|
|
|
|
|
|
|
|
# defaulted methods
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
struct Foo {
|
|
|
|
Foo() = default;
|
|
|
|
~Foo() = default;
|
|
|
|
};
|
|
|
|
int main(int argc, const char* argv[]) {
|
|
|
|
Foo bar;
|
|
|
|
(void)bar;
|
|
|
|
return 0;
|
|
|
|
}"
|
|
|
|
HAVE_DEFAULTED_MEMBER_FUNCTIONS)
|
|
|
|
|
|
|
|
# deleted methods
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
struct Foo {
|
|
|
|
Foo() {}
|
|
|
|
Foo(const Foo&) = delete;
|
|
|
|
};
|
|
|
|
int main(int argc, const char* argv[]) {
|
|
|
|
Foo bar;
|
|
|
|
(void)bar;
|
|
|
|
return 0;
|
|
|
|
}"
|
|
|
|
HAVE_DELETED_MEMBER_FUNCTIONS)
|
2016-02-24 19:03:37 +01:00
|
|
|
endif ()
|
|
|
|
|
2016-03-02 22:40:32 +01:00
|
|
|
if (NOT HAVE_UNIQUE_PTR
|
|
|
|
OR NOT HAVE_DEFAULT_MEMBER_VALUES
|
|
|
|
OR NOT HAVE_DEFAULTED_MEMBER_FUNCTIONS
|
|
|
|
OR NOT HAVE_DELETED_MEMBER_FUNCTIONS)
|
2016-02-24 19:03:37 +01:00
|
|
|
set(ENABLE_TESTS OFF)
|
|
|
|
set(ENABLE_WEBMTS OFF)
|
2016-03-02 22:40:32 +01:00
|
|
|
message(WARNING "C++11 feature(s) not supported, tests and webmts disabled.")
|
2016-02-24 19:03:37 +01:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
# Turn up the warning levels.
|
|
|
|
if (MSVC)
|
|
|
|
set(CMAKE_CXX_FLAGS "/W4 ${CMAKE_CXX_FLAGS}" CACHE STRING "" FORCE)
|
|
|
|
else ()
|
|
|
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}" CACHE STRING "" FORCE)
|
2016-02-25 18:37:11 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "-Wno-deprecated ${CMAKE_CXX_FLAGS}" CACHE
|
|
|
|
STRING "" FORCE)
|
2016-02-24 19:03:37 +01:00
|
|
|
endif ()
|
|
|
|
|
2015-02-13 20:23:40 +01:00
|
|
|
# Libwebm section.
|
2015-03-02 21:43:56 +01:00
|
|
|
add_library(webm STATIC
|
2016-03-07 20:08:14 +01:00
|
|
|
"${LIBWEBM_SRC_DIR}/common/file_util.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/common/file_util.h"
|
2016-03-07 20:09:44 +01:00
|
|
|
"${LIBWEBM_SRC_DIR}/common/hdr_util.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/common/hdr_util.h"
|
2015-02-13 20:23:40 +01:00
|
|
|
"${LIBWEBM_SRC_DIR}/mkvmuxer.cpp"
|
|
|
|
"${LIBWEBM_SRC_DIR}/mkvmuxer.hpp"
|
|
|
|
"${LIBWEBM_SRC_DIR}/mkvmuxertypes.hpp"
|
|
|
|
"${LIBWEBM_SRC_DIR}/mkvmuxerutil.cpp"
|
|
|
|
"${LIBWEBM_SRC_DIR}/mkvmuxerutil.hpp"
|
|
|
|
"${LIBWEBM_SRC_DIR}/mkvparser.cpp"
|
|
|
|
"${LIBWEBM_SRC_DIR}/mkvparser.hpp"
|
|
|
|
"${LIBWEBM_SRC_DIR}/mkvreader.cpp"
|
|
|
|
"${LIBWEBM_SRC_DIR}/mkvreader.hpp"
|
|
|
|
"${LIBWEBM_SRC_DIR}/mkvwriter.cpp"
|
|
|
|
"${LIBWEBM_SRC_DIR}/mkvwriter.hpp"
|
|
|
|
"${LIBWEBM_SRC_DIR}/webmids.hpp")
|
2016-02-24 19:03:37 +01:00
|
|
|
if (WIN32)
|
2015-03-02 21:43:56 +01:00
|
|
|
# Use libwebm and libwebm.lib for project and library name on Windows (instead
|
|
|
|
# webm and webm.lib).
|
|
|
|
set_target_properties(webm PROPERTIES PROJECT_LABEL libwebm)
|
|
|
|
set_target_properties(webm PROPERTIES PREFIX lib)
|
2016-02-24 19:03:37 +01:00
|
|
|
endif ()
|
2015-02-13 20:23:40 +01:00
|
|
|
|
|
|
|
include_directories("${LIBWEBM_SRC_DIR}")
|
|
|
|
|
2016-02-17 20:16:38 +01:00
|
|
|
# Sample (mkvparser) section.
|
2015-02-13 20:23:40 +01:00
|
|
|
add_executable(sample
|
|
|
|
"${LIBWEBM_SRC_DIR}/sample.cpp")
|
2015-03-02 21:43:56 +01:00
|
|
|
target_link_libraries(sample LINK_PUBLIC webm)
|
2015-02-13 20:23:40 +01:00
|
|
|
|
|
|
|
# Sample muxer section.
|
|
|
|
add_executable(sample_muxer
|
|
|
|
"${LIBWEBM_SRC_DIR}/sample_muxer.cpp"
|
|
|
|
"${LIBWEBM_SRC_DIR}/sample_muxer_metadata.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/sample_muxer_metadata.h"
|
|
|
|
"${LIBWEBM_SRC_DIR}/vttreader.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/vttreader.h"
|
|
|
|
"${LIBWEBM_SRC_DIR}/webvttparser.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/webvttparser.h")
|
2015-03-02 21:43:56 +01:00
|
|
|
target_link_libraries(sample_muxer LINK_PUBLIC webm)
|
2015-02-13 20:23:40 +01:00
|
|
|
|
|
|
|
# Vttdemux section.
|
|
|
|
add_executable(vttdemux
|
|
|
|
"${LIBWEBM_SRC_DIR}/vttdemux.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/webvttparser.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/webvttparser.h")
|
2015-03-02 21:43:56 +01:00
|
|
|
target_link_libraries(vttdemux LINK_PUBLIC webm)
|
2015-11-30 20:23:10 +01:00
|
|
|
|
2016-02-24 19:03:37 +01:00
|
|
|
if (ENABLE_WEBMTS)
|
|
|
|
# webmts (PES/TS support) library section.
|
|
|
|
add_library(webmts
|
|
|
|
"${LIBWEBM_SRC_DIR}/common/libwebm_utils.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/common/libwebm_utils.h"
|
|
|
|
"${LIBWEBM_SRC_DIR}/webm2pes.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/webm2pes.h"
|
|
|
|
"${LIBWEBM_SRC_DIR}/vpxpes2ts.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/vpxpes2ts.h")
|
|
|
|
|
|
|
|
# webm2pes section.
|
|
|
|
add_executable(webm2pes
|
|
|
|
"${LIBWEBM_SRC_DIR}/webm2pes_main.cc")
|
|
|
|
target_link_libraries(webm2pes LINK_PUBLIC webm webmts)
|
|
|
|
|
|
|
|
# webm2ts section.
|
|
|
|
add_executable(webm2ts "${LIBWEBM_SRC_DIR}/vpxpes2ts_main.cc")
|
|
|
|
target_link_libraries(webm2ts LINK_PUBLIC webm webmts)
|
|
|
|
endif ()
|
2016-01-22 20:24:55 +01:00
|
|
|
|
2016-01-12 03:46:55 +01:00
|
|
|
if (ENABLE_TESTS)
|
|
|
|
add_subdirectory("${GTEST_SRC_DIR}" "${GTEST_BUILD_DIR}")
|
|
|
|
include_directories("${GTEST_SRC_DIR}/googletest/include")
|
|
|
|
|
|
|
|
add_executable(muxer_tests
|
|
|
|
"${LIBWEBM_SRC_DIR}/testing/muxer_tests.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/testing/test_util.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/testing/test_util.h")
|
2016-02-17 20:16:38 +01:00
|
|
|
target_link_libraries(muxer_tests LINK_PUBLIC gtest webm)
|
2016-01-12 03:46:55 +01:00
|
|
|
|
|
|
|
add_executable(parser_tests
|
|
|
|
"${LIBWEBM_SRC_DIR}/testing/parser_tests.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/testing/test_util.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/testing/test_util.h")
|
2016-02-17 20:16:38 +01:00
|
|
|
target_link_libraries(parser_tests LINK_PUBLIC gtest webm)
|
2016-01-21 20:50:37 +01:00
|
|
|
|
2016-02-24 19:03:37 +01:00
|
|
|
if (ENABLE_WEBMTS)
|
|
|
|
add_executable(webm2pes_tests
|
|
|
|
"${LIBWEBM_SRC_DIR}/testing/test_util.cc"
|
|
|
|
"${LIBWEBM_SRC_DIR}/testing/test_util.h"
|
|
|
|
"${LIBWEBM_SRC_DIR}/testing/webm2pes_tests.cc")
|
|
|
|
target_link_libraries(webm2pes_tests LINK_PUBLIC gtest webm webmts)
|
|
|
|
endif ()
|
|
|
|
endif ()
|
2016-01-22 20:24:55 +01:00
|
|
|
|