summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2023-06-05 13:13:28 -0700
committerJames Zern <jzern@google.com>2023-06-05 15:07:26 -0700
commitf7da30b247bde1bb662ec7d59687302b138f8268 (patch)
tree0cc76b024d43e3b994d2c4d1137c995cd9e9c75f
parent930a160fe2034797397754be5177644de634c409 (diff)
downloadlibwebm-f7da30b247bde1bb662ec7d59687302b138f8268.tar.gz
CMakeLists.txt,**/.cmake: apply cmake-format
using version 0.6.13 and --first-comment-is-literal true. .cmake-format.py contains the same configuration. Change-Id: I1b53a3466eeeb322ddab87ea857c2a7dac767877
-rw-r--r--.cmake-format.py240
-rw-r--r--CMakeLists.txt142
-rw-r--r--CONTRIBUTING.md12
-rw-r--r--build/cxx_flags.cmake78
-rw-r--r--build/msvc_runtime.cmake34
-rw-r--r--build/x86-mingw-gcc.cmake42
-rw-r--r--build/x86_64-mingw-gcc.cmake38
7 files changed, 420 insertions, 166 deletions
diff --git a/.cmake-format.py b/.cmake-format.py
new file mode 100644
index 0000000..f1db75d
--- /dev/null
+++ b/.cmake-format.py
@@ -0,0 +1,240 @@
+# ----------------------------------
+# Options affecting listfile parsing
+# ----------------------------------
+with section("parse"):
+
+ # Specify structure for custom cmake functions
+ additional_commands = { 'foo': { 'flags': ['BAR', 'BAZ'],
+ 'kwargs': {'DEPENDS': '*', 'HEADERS': '*', 'SOURCES': '*'}}}
+
+ # Override configurations per-command where available
+ override_spec = {}
+
+ # Specify variable tags.
+ vartags = []
+
+ # Specify property tags.
+ proptags = []
+
+# -----------------------------
+# Options affecting formatting.
+# -----------------------------
+with section("format"):
+
+ # Disable formatting entirely, making cmake-format a no-op
+ disable = False
+
+ # How wide to allow formatted cmake files
+ line_width = 80
+
+ # How many spaces to tab for indent
+ tab_size = 2
+
+ # If true, lines are indented using tab characters (utf-8 0x09) instead of
+ # <tab_size> space characters (utf-8 0x20). In cases where the layout would
+ # require a fractional tab character, the behavior of the fractional
+ # indentation is governed by <fractional_tab_policy>
+ use_tabchars = False
+
+ # If <use_tabchars> is True, then the value of this variable indicates how
+ # fractional indentions are handled during whitespace replacement. If set to
+ # 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set
+ # to `round-up` fractional indentation is replaced with a single tab character
+ # (utf-8 0x09) effectively shifting the column to the next tabstop
+ fractional_tab_policy = 'use-space'
+
+ # If an argument group contains more than this many sub-groups (parg or kwarg
+ # groups) then force it to a vertical layout.
+ max_subgroups_hwrap = 2
+
+ # If a positional argument group contains more than this many arguments, then
+ # force it to a vertical layout.
+ max_pargs_hwrap = 6
+
+ # If a cmdline positional group consumes more than this many lines without
+ # nesting, then invalidate the layout (and nest)
+ max_rows_cmdline = 2
+
+ # If true, separate flow control names from their parentheses with a space
+ separate_ctrl_name_with_space = False
+
+ # If true, separate function names from parentheses with a space
+ separate_fn_name_with_space = False
+
+ # If a statement is wrapped to more than one line, than dangle the closing
+ # parenthesis on its own line.
+ dangle_parens = False
+
+ # If the trailing parenthesis must be 'dangled' on its on line, then align it
+ # to this reference: `prefix`: the start of the statement, `prefix-indent`:
+ # the start of the statement, plus one indentation level, `child`: align to
+ # the column of the arguments
+ dangle_align = 'prefix'
+
+ # If the statement spelling length (including space and parenthesis) is
+ # smaller than this amount, then force reject nested layouts.
+ min_prefix_chars = 4
+
+ # If the statement spelling length (including space and parenthesis) is larger
+ # than the tab width by more than this amount, then force reject un-nested
+ # layouts.
+ max_prefix_chars = 10
+
+ # If a candidate layout is wrapped horizontally but it exceeds this many
+ # lines, then reject the layout.
+ max_lines_hwrap = 2
+
+ # What style line endings to use in the output.
+ line_ending = 'unix'
+
+ # Format command names consistently as 'lower' or 'upper' case
+ command_case = 'canonical'
+
+ # Format keywords consistently as 'lower' or 'upper' case
+ keyword_case = 'unchanged'
+
+ # A list of command names which should always be wrapped
+ always_wrap = []
+
+ # If true, the argument lists which are known to be sortable will be sorted
+ # lexicographicall
+ enable_sort = True
+
+ # If true, the parsers may infer whether or not an argument list is sortable
+ # (without annotation).
+ autosort = False
+
+ # By default, if cmake-format cannot successfully fit everything into the
+ # desired linewidth it will apply the last, most agressive attempt that it
+ # made. If this flag is True, however, cmake-format will print error, exit
+ # with non-zero status code, and write-out nothing
+ require_valid_layout = False
+
+ # A dictionary mapping layout nodes to a list of wrap decisions. See the
+ # documentation for more information.
+ layout_passes = {}
+
+# ------------------------------------------------
+# Options affecting comment reflow and formatting.
+# ------------------------------------------------
+with section("markup"):
+
+ # What character to use for bulleted lists
+ bullet_char = '*'
+
+ # What character to use as punctuation after numerals in an enumerated list
+ enum_char = '.'
+
+ # If comment markup is enabled, don't reflow the first comment block in each
+ # listfile. Use this to preserve formatting of your copyright/license
+ # statements.
+ first_comment_is_literal = True
+
+ # If comment markup is enabled, don't reflow any comment block which matches
+ # this (regex) pattern. Default is `None` (disabled).
+ literal_comment_pattern = None
+
+ # Regular expression to match preformat fences in comments default=
+ # ``r'^\s*([`~]{3}[`~]*)(.*)$'``
+ fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
+
+ # Regular expression to match rulers in comments default=
+ # ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
+ ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
+
+ # If a comment line matches starts with this pattern then it is explicitly a
+ # trailing comment for the preceeding argument. Default is '#<'
+ explicit_trailing_pattern = '#<'
+
+ # If a comment line starts with at least this many consecutive hash
+ # characters, then don't lstrip() them off. This allows for lazy hash rulers
+ # where the first hash char is not separated by space
+ hashruler_min_length = 10
+
+ # If true, then insert a space between the first hash char and remaining hash
+ # chars in a hash ruler, and normalize its length to fill the column
+ canonicalize_hashrulers = True
+
+ # enable comment markup parsing and reflow
+ enable_markup = True
+
+# ----------------------------
+# Options affecting the linter
+# ----------------------------
+with section("lint"):
+
+ # a list of lint codes to disable
+ disabled_codes = []
+
+ # regular expression pattern describing valid function names
+ function_pattern = '[0-9a-z_]+'
+
+ # regular expression pattern describing valid macro names
+ macro_pattern = '[0-9A-Z_]+'
+
+ # regular expression pattern describing valid names for variables with global
+ # (cache) scope
+ global_var_pattern = '[A-Z][0-9A-Z_]+'
+
+ # regular expression pattern describing valid names for variables with global
+ # scope (but internal semantic)
+ internal_var_pattern = '_[A-Z][0-9A-Z_]+'
+
+ # regular expression pattern describing valid names for variables with local
+ # scope
+ local_var_pattern = '[a-z][a-z0-9_]+'
+
+ # regular expression pattern describing valid names for privatedirectory
+ # variables
+ private_var_pattern = '_[0-9a-z_]+'
+
+ # regular expression pattern describing valid names for public directory
+ # variables
+ public_var_pattern = '[A-Z][0-9A-Z_]+'
+
+ # regular expression pattern describing valid names for function/macro
+ # arguments and loop variables.
+ argument_var_pattern = '[a-z][a-z0-9_]+'
+
+ # regular expression pattern describing valid names for keywords used in
+ # functions or macros
+ keyword_pattern = '[A-Z][0-9A-Z_]+'
+
+ # In the heuristic for C0201, how many conditionals to match within a loop in
+ # before considering the loop a parser.
+ max_conditionals_custom_parser = 2
+
+ # Require at least this many newlines between statements
+ min_statement_spacing = 1
+
+ # Require no more than this many newlines between statements
+ max_statement_spacing = 2
+ max_returns = 6
+ max_branches = 12
+ max_arguments = 5
+ max_localvars = 15
+ max_statements = 50
+
+# -------------------------------
+# Options affecting file encoding
+# -------------------------------
+with section("encode"):
+
+ # If true, emit the unicode byte-order mark (BOM) at the start of the file
+ emit_byteorder_mark = False
+
+ # Specify the encoding of the input file. Defaults to utf-8
+ input_encoding = 'utf-8'
+
+ # Specify the encoding of the output file. Defaults to utf-8. Note that cmake
+ # only claims to support utf-8 so be careful when using anything else
+ output_encoding = 'utf-8'
+
+# -------------------------------------
+# Miscellaneous configurations options.
+# -------------------------------------
+with section("misc"):
+
+ # A dictionary containing any per-command configuration overrides. Currently
+ # only `command_case` is supported.
+ per_command = {}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ea9abd3..2318917 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,19 +1,19 @@
-## 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.
+# 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.
cmake_minimum_required(VERSION 3.2)
project(LIBWEBM CXX)
include(GNUInstallDirs)
include("${CMAKE_CURRENT_SOURCE_DIR}/build/cxx_flags.cmake")
-if (NOT BUILD_SHARED_LIBS)
+if(NOT BUILD_SHARED_LIBS)
include("${CMAKE_CURRENT_SOURCE_DIR}/build/msvc_runtime.cmake")
-endif ()
+endif()
set(LIBWEBM_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
@@ -26,7 +26,9 @@ option(ENABLE_WERROR "Enable warnings as errors." OFF)
option(ENABLE_WEBM_PARSER "Enables new parser API." OFF)
option(ENABLE_SAMPLE_PROGRAMS "Enables building sample programs." ON)
-if(WIN32 OR CYGWIN OR MSYS)
+if(WIN32
+ OR CYGWIN
+ OR MSYS)
# Allow use of rand_r() / fdopen() and other POSIX functions.
require_cxx_flag_nomsvc("-std=gnu++11")
else()
@@ -40,15 +42,15 @@ add_cxx_preproc_definition("__STDC_LIMIT_MACROS")
# Set up compiler flags and build properties.
include_directories("${LIBWEBM_SRC_DIR}")
-if (MSVC)
+if(MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_cxx_flag_if_supported("/W4")
# Disable MSVC warnings that suggest making code non-portable.
add_cxx_flag_if_supported("/wd4996")
- if (ENABLE_WERROR)
+ if(ENABLE_WERROR)
add_cxx_flag_if_supported("/WX")
- endif ()
-else ()
+ endif()
+else()
add_cxx_flag_if_supported("-Wall")
add_cxx_flag_if_supported("-Wc++14-compat")
add_cxx_flag_if_supported("-Wc++17-compat")
@@ -57,16 +59,15 @@ else ()
add_cxx_flag_if_supported("-Wnarrowing")
add_cxx_flag_if_supported("-Wno-deprecated")
add_cxx_flag_if_supported("-Wshorten-64-to-32")
- if (ENABLE_WERROR)
+ if(ENABLE_WERROR)
add_cxx_flag_if_supported("-Werror")
- endif ()
-endif ()
+ endif()
+endif()
# Source list variables.
set(dumpvtt_sources "${LIBWEBM_SRC_DIR}/dumpvtt.cc")
-set(libwebm_common_public_headers
- "${LIBWEBM_SRC_DIR}/common/webmids.h")
+set(libwebm_common_public_headers "${LIBWEBM_SRC_DIR}/common/webmids.h")
set(libwebm_common_sources
${libwebm_common_public_headers}
@@ -98,13 +99,11 @@ set(mkvmuxer_tests_sources
"${LIBWEBM_SRC_DIR}/testing/test_util.cc"
"${LIBWEBM_SRC_DIR}/testing/test_util.h")
-set(mkvparser_public_headers
- "${LIBWEBM_SRC_DIR}/mkvparser/mkvparser.h"
- "${LIBWEBM_SRC_DIR}/mkvparser/mkvreader.h")
+set(mkvparser_public_headers "${LIBWEBM_SRC_DIR}/mkvparser/mkvparser.h"
+ "${LIBWEBM_SRC_DIR}/mkvparser/mkvreader.h")
set(mkvparser_sources
- ${mkvparser_public_headers}
- "${LIBWEBM_SRC_DIR}/mkvparser/mkvparser.cc"
+ ${mkvparser_public_headers} "${LIBWEBM_SRC_DIR}/mkvparser/mkvparser.cc"
"${LIBWEBM_SRC_DIR}/mkvparser/mkvreader.cc"
"${LIBWEBM_SRC_DIR}/common/webmids.h")
@@ -324,39 +323,32 @@ set(webm2pes_tests_sources
"${LIBWEBM_SRC_DIR}/m2ts/tests/webm2pes_tests.cc")
set(webm2ts_sources "${LIBWEBM_SRC_DIR}/m2ts/vpxpes2ts_main.cc")
-set(webvtt_common_headers
- "${LIBWEBM_SRC_DIR}/webvtt/vttreader.h"
- "${LIBWEBM_SRC_DIR}/webvtt/webvttparser.h")
+set(webvtt_common_headers "${LIBWEBM_SRC_DIR}/webvtt/vttreader.h"
+ "${LIBWEBM_SRC_DIR}/webvtt/webvttparser.h")
set(webvtt_common_sources
- ${webvtt_common_headers}
- "${LIBWEBM_SRC_DIR}/webvtt/vttreader.cc"
+ ${webvtt_common_headers} "${LIBWEBM_SRC_DIR}/webvtt/vttreader.cc"
"${LIBWEBM_SRC_DIR}/webvtt/webvttparser.cc")
-set(vttdemux_sources
- ${webvtt_common_sources}
- "${LIBWEBM_SRC_DIR}/vttdemux.cc")
+set(vttdemux_sources ${webvtt_common_sources} "${LIBWEBM_SRC_DIR}/vttdemux.cc")
# Public headers that will be installed with the library.
-set(webm_public_headers
- ${mkvmuxer_public_headers}
- ${mkvparser_public_headers})
+set(webm_public_headers ${mkvmuxer_public_headers} ${mkvparser_public_headers})
# Targets.
add_library(mkvmuxer OBJECT ${mkvmuxer_sources})
add_library(mkvparser OBJECT ${mkvparser_sources})
add_library(webvtt_common OBJECT ${webvtt_common_sources})
-add_library(webm ${libwebm_common_sources}
- $<TARGET_OBJECTS:mkvmuxer>
- $<TARGET_OBJECTS:mkvparser>)
+add_library(webm ${libwebm_common_sources} $<TARGET_OBJECTS:mkvmuxer>
+ $<TARGET_OBJECTS:mkvparser>)
if(ENABLE_SAMPLE_PROGRAMS)
add_executable(mkvparser_sample ${mkvparser_sample_sources})
target_link_libraries(mkvparser_sample LINK_PUBLIC webm)
add_executable(mkvmuxer_sample ${mkvmuxer_sample_sources}
- $<TARGET_OBJECTS:webvtt_common>)
+ $<TARGET_OBJECTS:webvtt_common>)
target_link_libraries(mkvmuxer_sample LINK_PUBLIC webm)
add_executable(dumpvtt ${dumpvtt_sources} $<TARGET_OBJECTS:webvtt_common>)
@@ -366,12 +358,12 @@ if(ENABLE_SAMPLE_PROGRAMS)
target_link_libraries(vttdemux LINK_PUBLIC webm)
endif()
-if (ENABLE_WEBMINFO)
+if(ENABLE_WEBMINFO)
add_executable(webm_info ${webm_info_sources})
target_link_libraries(webm_info LINK_PUBLIC webm)
-endif ()
+endif()
-if (ENABLE_WEBM_PARSER)
+if(ENABLE_WEBM_PARSER)
include_directories(webm_parser webm_parser/include)
add_library(webm_parser OBJECT ${webm_parser_sources})
target_sources(webm PUBLIC $<TARGET_OBJECTS:webm_parser>)
@@ -380,9 +372,9 @@ if (ENABLE_WEBM_PARSER)
target_link_libraries(webm_parser_demo LINK_PUBLIC webm)
list(APPEND webm_public_headers ${webm_parser_public_headers})
-endif ()
+endif()
-if (ENABLE_WEBMTS)
+if(ENABLE_WEBMTS)
add_library(webmts OBJECT ${webmts_sources})
add_executable(webm2pes ${webm2pes_sources} $<TARGET_OBJECTS:webmts>)
@@ -390,20 +382,21 @@ if (ENABLE_WEBMTS)
add_executable(webm2ts ${webm2ts_sources} $<TARGET_OBJECTS:webmts>)
target_link_libraries(webm2ts LINK_PUBLIC webm)
-endif ()
+endif()
-if (ENABLE_TESTS)
- set(GTEST_SRC_DIR "${LIBWEBM_SRC_DIR}/../googletest" CACHE PATH
- "Path to Googletest git repository.")
+if(ENABLE_TESTS)
+ 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")
- if (LIBWEBM_DISABLE_GTEST_CMAKE)
+ if(LIBWEBM_DISABLE_GTEST_CMAKE)
add_library(gtest STATIC "${GTEST_SRC_DIR}/googletest/src/gtest-all.cc")
include_directories("${GTEST_SRC_DIR}/googletest")
- else ()
+ else()
add_subdirectory("${GTEST_SRC_DIR}" "${GTEST_BUILD_DIR}")
- endif ()
+ endif()
include_directories("${GTEST_SRC_DIR}/googletest/include")
add_executable(mkvmuxer_tests ${mkvmuxer_tests_sources})
@@ -418,21 +411,21 @@ if (ENABLE_TESTS)
add_executable(vp9_level_stats_tests ${vp9_level_stats_tests_sources})
target_link_libraries(vp9_level_stats_tests LINK_PUBLIC gtest webm)
- if (ENABLE_WEBMTS)
+ if(ENABLE_WEBMTS)
add_executable(webm2pes_tests ${webm2pes_tests_sources}
- $<TARGET_OBJECTS:webmts>)
+ $<TARGET_OBJECTS:webmts>)
target_link_libraries(webm2pes_tests LINK_PUBLIC gtest webm)
- endif ()
+ endif()
- if (ENABLE_WEBM_PARSER)
+ if(ENABLE_WEBM_PARSER)
include_directories("${GTEST_SRC_DIR}/googlemock/include")
add_executable(webm_parser_tests ${webm_parser_tests_sources})
target_link_libraries(webm_parser_tests LINK_PUBLIC gmock gtest webm)
- endif ()
-endif ()
+ endif()
+endif()
# Include-what-you-use.
-if (ENABLE_IWYU)
+if(ENABLE_IWYU)
# Make sure all the tools necessary for IWYU are present.
find_program(iwyu_path NAMES include-what-you-use)
find_program(iwyu_tool_path NAMES iwyu_tool.py)
@@ -442,32 +435,35 @@ if (ENABLE_IWYU)
# PYTHONINTERP_FOUND is empty without explicitly looking for it.
find_package(PythonInterp)
- if (iwyu_path AND iwyu_tool_path AND PYTHONINTERP_FOUND)
+ if(iwyu_path
+ AND iwyu_tool_path
+ AND PYTHONINTERP_FOUND)
# Enable compilation command export (needed for iwyu_tool.py)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Add a custom target to run iwyu across all targets.
- add_custom_target(iwyu
- ALL
- COMMAND "${PYTHON_EXECUTABLE}" "${iwyu_tool_path}" -p
- "${CMAKE_BINARY_DIR}"
- COMMENT "Running include-what-you-use..."
- VERBATIM)
- else ()
+ add_custom_target(
+ iwyu ALL
+ COMMAND "${PYTHON_EXECUTABLE}" "${iwyu_tool_path}" -p
+ "${CMAKE_BINARY_DIR}"
+ COMMENT "Running include-what-you-use..."
+ VERBATIM)
+ else()
message(STATUS "Ignoring ENABLE_IWYU because reasons:")
message(STATUS " iwyu_path=" ${iwyu_path})
message(STATUS " iwyu_tool_path=" ${iwyu_tool_path})
message(STATUS " PYTHONINTERP_FOUND=" ${PYTHONINTERP_FOUND})
message(STATUS " See README.libwebm for more information.")
- endif ()
-endif ()
+ endif()
+endif()
set_target_properties(webm PROPERTIES PUBLIC_HEADER "${webm_public_headers}")
-install(TARGETS webm
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webm)
+install(
+ TARGETS webm
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webm)
# Install common headers into a subdirectory to avoid breaking nested includes.
install(FILES ${libwebm_common_public_headers}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7a73a30..a30c512 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -23,6 +23,18 @@ https://chromium-review.googlesource.com for this purpose. See the
[WebM Project page](https://www.webmproject.org/code/contribute/submitting-patches/)
for additional details.
+## Code Style
+
+The C++ code style is based on the
+[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) and
+`clang-format --style=Google`. `clang-format -i --style=file` can be used to
+format individual files, it will use the settings from `.clang-format`.
+
+CMake files are formatted with
+[cmake-format](https://cmake-format.readthedocs.io/en/latest/). `cmake-format
+-i` can be used to format individual files, it will use the settings from
+`.cmake-format.py`.
+
## Community Guidelines
This project follows
diff --git a/build/cxx_flags.cmake b/build/cxx_flags.cmake
index 1aa6a86..e67137e 100644
--- a/build/cxx_flags.cmake
+++ b/build/cxx_flags.cmake
@@ -1,10 +1,10 @@
-## Copyright (c) 2016 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.
+# Copyright (c) 2016 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.
include(CheckCXXCompilerFlag)
@@ -14,59 +14,65 @@ set(LIBWEBM_FAILED_CXX_FLAGS)
# Checks C++ compiler for support of $cxx_flag. Adds $cxx_flag to
# $CMAKE_CXX_FLAGS when the compile test passes. Caches $c_flag in
# $LIBWEBM_FAILED_CXX_FLAGS when the test fails.
-function (add_cxx_flag_if_supported cxx_flag)
+function(add_cxx_flag_if_supported cxx_flag)
unset(CXX_FLAG_FOUND CACHE)
string(FIND "${CMAKE_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FOUND)
unset(CXX_FLAG_FAILED CACHE)
string(FIND "${LIBWEBM_FAILED_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FAILED)
- if (${CXX_FLAG_FOUND} EQUAL -1 AND ${CXX_FLAG_FAILED} EQUAL -1)
+ if(${CXX_FLAG_FOUND} EQUAL -1 AND ${CXX_FLAG_FAILED} EQUAL -1)
unset(CXX_FLAG_SUPPORTED CACHE)
message("Checking CXX compiler flag support for: " ${cxx_flag})
check_cxx_compiler_flag("${cxx_flag}" CXX_FLAG_SUPPORTED)
- if (CXX_FLAG_SUPPORTED)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_flag}" CACHE STRING ""
- FORCE)
- else ()
- set(LIBWEBM_FAILED_CXX_FLAGS "${LIBWEBM_FAILED_CXX_FLAGS} ${cxx_flag}"
+ if(CXX_FLAG_SUPPORTED)
+ set(CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS} ${cxx_flag}"
CACHE STRING "" FORCE)
- endif ()
- endif ()
-endfunction ()
+ else()
+ set(LIBWEBM_FAILED_CXX_FLAGS
+ "${LIBWEBM_FAILED_CXX_FLAGS} ${cxx_flag}"
+ CACHE STRING "" FORCE)
+ endif()
+ endif()
+endfunction()
# Checks CXX compiler for support of $cxx_flag and terminates generation when
# support is not present.
-function (require_cxx_flag cxx_flag)
+function(require_cxx_flag cxx_flag)
unset(CXX_FLAG_FOUND CACHE)
string(FIND "${CMAKE_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FOUND)
- if (${CXX_FLAG_FOUND} EQUAL -1)
+ if(${CXX_FLAG_FOUND} EQUAL -1)
unset(LIBWEBM_HAVE_CXX_FLAG CACHE)
message("Checking CXX compiler flag support for: " ${cxx_flag})
check_cxx_compiler_flag("${cxx_flag}" LIBWEBM_HAVE_CXX_FLAG)
- if (NOT LIBWEBM_HAVE_CXX_FLAG)
- message(FATAL_ERROR
- "${PROJECT_NAME} requires support for CXX flag: ${cxx_flag}.")
- endif ()
- set(CMAKE_CXX_FLAGS "${cxx_flag} ${CMAKE_CXX_FLAGS}" CACHE STRING "" FORCE)
- endif ()
-endfunction ()
+ if(NOT LIBWEBM_HAVE_CXX_FLAG)
+ message(
+ FATAL_ERROR
+ "${PROJECT_NAME} requires support for CXX flag: ${cxx_flag}.")
+ endif()
+ set(CMAKE_CXX_FLAGS
+ "${cxx_flag} ${CMAKE_CXX_FLAGS}"
+ CACHE STRING "" FORCE)
+ endif()
+endfunction()
# Checks only non-MSVC targets for support of $cxx_flag.
-function (require_cxx_flag_nomsvc cxx_flag)
- if (NOT MSVC)
+function(require_cxx_flag_nomsvc cxx_flag)
+ if(NOT MSVC)
require_cxx_flag(${cxx_flag})
- endif ()
-endfunction ()
+ endif()
+endfunction()
# Adds $preproc_def to CXX compiler command line (as -D$preproc_def) if not
# already present.
-function (add_cxx_preproc_definition preproc_def)
+function(add_cxx_preproc_definition preproc_def)
unset(PREPROC_DEF_FOUND CACHE)
string(FIND "${CMAKE_CXX_FLAGS}" "${preproc_def}" PREPROC_DEF_FOUND)
- if (${PREPROC_DEF_FOUND} EQUAL -1)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${preproc_def}" CACHE STRING ""
- FORCE)
- endif ()
-endfunction ()
+ if(${PREPROC_DEF_FOUND} EQUAL -1)
+ set(CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS} -D${preproc_def}"
+ CACHE STRING "" FORCE)
+ endif()
+endfunction()
diff --git a/build/msvc_runtime.cmake b/build/msvc_runtime.cmake
index 4f53a36..7058577 100644
--- a/build/msvc_runtime.cmake
+++ b/build/msvc_runtime.cmake
@@ -1,22 +1,22 @@
-## 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.
+# 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.
-if (MSVC)
+if(MSVC)
# CMake defaults to producing code linked to the DLL MSVC runtime. In libwebm
# static is typically desired. Force static code generation unless the user
# running CMake set MSVC_RUNTIME to dll.
- if (NOT "${MSVC_RUNTIME}" STREQUAL "dll")
- foreach (flag_var
- CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
- CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
- if (${flag_var} MATCHES "/MD")
+ if(NOT "${MSVC_RUNTIME}" STREQUAL "dll")
+ foreach(flag_var
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
- endif (${flag_var} MATCHES "/MD")
- endforeach (flag_var)
- endif ()
-endif ()
+ endif(${flag_var} MATCHES "/MD")
+ endforeach(flag_var)
+ endif()
+endif()
diff --git a/build/x86-mingw-gcc.cmake b/build/x86-mingw-gcc.cmake
index 8416eaf..3469df2 100644
--- a/build/x86-mingw-gcc.cmake
+++ b/build/x86-mingw-gcc.cmake
@@ -1,26 +1,26 @@
-## Copyright (c) 2017 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.
-if (NOT LIBWEBM_BUILD_X86_MINGW_GCC_CMAKE_)
-set(LIBWEBM_BUILD_X86_MINGW_GCC_CMAKE_ 1)
+# Copyright (c) 2017 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.
+if(NOT LIBWEBM_BUILD_X86_MINGW_GCC_CMAKE_)
+ set(LIBWEBM_BUILD_X86_MINGW_GCC_CMAKE_ 1)
-set(CMAKE_SYSTEM_PROCESSOR "x86")
-set(CMAKE_SYSTEM_NAME "Windows")
-set(CMAKE_C_COMPILER_ARG1 "-m32")
-set(CMAKE_CXX_COMPILER_ARG1 "-m32")
+ set(CMAKE_SYSTEM_PROCESSOR "x86")
+ set(CMAKE_SYSTEM_NAME "Windows")
+ set(CMAKE_C_COMPILER_ARG1 "-m32")
+ set(CMAKE_CXX_COMPILER_ARG1 "-m32")
-if ("${CROSS}" STREQUAL "")
- set(CROSS i686-w64-mingw32-)
-endif ()
+ if("${CROSS}" STREQUAL "")
+ set(CROSS i686-w64-mingw32-)
+ endif()
-set(CMAKE_C_COMPILER ${CROSS}gcc)
-set(CMAKE_CXX_COMPILER ${CROSS}g++)
+ set(CMAKE_C_COMPILER ${CROSS}gcc)
+ set(CMAKE_CXX_COMPILER ${CROSS}g++)
-# Disable googletest CMake usage for mingw cross compiles.
-set(LIBWEBM_DISABLE_GTEST_CMAKE 1)
+ # Disable googletest CMake usage for mingw cross compiles.
+ set(LIBWEBM_DISABLE_GTEST_CMAKE 1)
-endif () # LIBWEBM_BUILD_X86_MINGW_GCC_CMAKE_
+endif() # LIBWEBM_BUILD_X86_MINGW_GCC_CMAKE_
diff --git a/build/x86_64-mingw-gcc.cmake b/build/x86_64-mingw-gcc.cmake
index 9db28b7..c8d8fe4 100644
--- a/build/x86_64-mingw-gcc.cmake
+++ b/build/x86_64-mingw-gcc.cmake
@@ -1,24 +1,24 @@
-## Copyright (c) 2017 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.
-if (NOT LIBWEBM_BUILD_X86_64_MINGW_GCC_CMAKE_)
-set(LIBWEBM_BUILD_X86_64_MINGW_GCC_CMAKE_ 1)
+# Copyright (c) 2017 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.
+if(NOT LIBWEBM_BUILD_X86_64_MINGW_GCC_CMAKE_)
+ set(LIBWEBM_BUILD_X86_64_MINGW_GCC_CMAKE_ 1)
-set(CMAKE_SYSTEM_PROCESSOR "x86_64")
-set(CMAKE_SYSTEM_NAME "Windows")
+ set(CMAKE_SYSTEM_PROCESSOR "x86_64")
+ set(CMAKE_SYSTEM_NAME "Windows")
-if ("${CROSS}" STREQUAL "")
- set(CROSS x86_64-w64-mingw32-)
-endif ()
+ if("${CROSS}" STREQUAL "")
+ set(CROSS x86_64-w64-mingw32-)
+ endif()
-set(CMAKE_C_COMPILER ${CROSS}gcc)
-set(CMAKE_CXX_COMPILER ${CROSS}g++)
+ set(CMAKE_C_COMPILER ${CROSS}gcc)
+ set(CMAKE_CXX_COMPILER ${CROSS}g++)
-# Disable googletest CMake usage for mingw cross compiles.
-set(LIBWEBM_DISABLE_GTEST_CMAKE 1)
+ # Disable googletest CMake usage for mingw cross compiles.
+ set(LIBWEBM_DISABLE_GTEST_CMAKE 1)
-endif () # LIBWEBM_BUILD_X86_64_MINGW_GCC_CMAKE_
+endif() # LIBWEBM_BUILD_X86_64_MINGW_GCC_CMAKE_