xref: /aosp_15_r20/external/libwebm/README.libwebm (revision 103e46e4cd4b6efcf6001f23fa8665fb110abf8d)
1*103e46e4SHarish MahendrakarBuilding Libwebm
2*103e46e4SHarish Mahendrakar
3*103e46e4SHarish MahendrakarTo build libwebm you must first create project files. To do this run cmake
4*103e46e4SHarish Mahendrakarand pass it the path to your libwebm repo.
5*103e46e4SHarish Mahendrakar
6*103e46e4SHarish MahendrakarMakefile.unix can be used as a fallback on systems that cmake does not
7*103e46e4SHarish Mahendrakarsupport.
8*103e46e4SHarish Mahendrakar
9*103e46e4SHarish Mahendrakar
10*103e46e4SHarish MahendrakarCMake Basics
11*103e46e4SHarish Mahendrakar
12*103e46e4SHarish MahendrakarTo generate project/make files for the default toolchain on your system simply
13*103e46e4SHarish Mahendrakarrun cmake with the path to the libwebm repo:
14*103e46e4SHarish Mahendrakar
15*103e46e4SHarish Mahendrakar$ cmake path/to/libwebm
16*103e46e4SHarish Mahendrakar
17*103e46e4SHarish MahendrakarOn Windows the above command will produce Visual Studio project files for the
18*103e46e4SHarish Mahendrakarnewest Visual Studio detected on the system. On Mac OS X and Linux systems, the
19*103e46e4SHarish Mahendrakarabove command will produce a makefile.
20*103e46e4SHarish Mahendrakar
21*103e46e4SHarish MahendrakarTo control what types of projects are generated the -G parameter is added to
22*103e46e4SHarish Mahendrakarthe cmake command line. This argument must be followed by the name of a
23*103e46e4SHarish Mahendrakargenerator. Running cmake with the --help argument will list the available
24*103e46e4SHarish Mahendrakargenerators for your system.
25*103e46e4SHarish Mahendrakar
26*103e46e4SHarish MahendrakarOn Mac OS X you would run the following command to generate Xcode projects:
27*103e46e4SHarish Mahendrakar
28*103e46e4SHarish Mahendrakar$ cmake path/to/libwebm -G Xcode
29*103e46e4SHarish Mahendrakar
30*103e46e4SHarish MahendrakarOn a Windows box you would run the following command to generate Visual Studio
31*103e46e4SHarish Mahendrakar2013 projects:
32*103e46e4SHarish Mahendrakar
33*103e46e4SHarish Mahendrakar$ cmake path/to/libwebm -G "Visual Studio 12"
34*103e46e4SHarish Mahendrakar
35*103e46e4SHarish MahendrakarTo generate 64-bit Windows Visual Studio 2013 projects:
36*103e46e4SHarish Mahendrakar
37*103e46e4SHarish Mahendrakar$ cmake path/to/libwebm "Visual Studio 12 Win64"
38*103e46e4SHarish Mahendrakar
39*103e46e4SHarish Mahendrakar
40*103e46e4SHarish MahendrakarCMake Makefiles: Debugging and Optimization
41*103e46e4SHarish Mahendrakar
42*103e46e4SHarish MahendrakarUnlike Visual Studio and Xcode projects, the build configuration for make builds
43*103e46e4SHarish Mahendrakaris controlled when you run cmake. The following examples demonstrate various
44*103e46e4SHarish Mahendrakarbuild configurations.
45*103e46e4SHarish Mahendrakar
46*103e46e4SHarish MahendrakarOmitting the build type produces makefiles that use build flags containing
47*103e46e4SHarish Mahendrakarneither optimization nor debug flags:
48*103e46e4SHarish Mahendrakar$ cmake path/to/libwebm
49*103e46e4SHarish Mahendrakar
50*103e46e4SHarish MahendrakarA makefile using release (optimized) flags is produced like this:
51*103e46e4SHarish Mahendrakar$ cmake path/to/libwebm -DCMAKE_BUILD_TYPE=release
52*103e46e4SHarish Mahendrakar
53*103e46e4SHarish MahendrakarA release build with debug info can be produced as well:
54*103e46e4SHarish Mahendrakar$ cmake path/to/libwebm -DCMAKE_BUILD_TYPE=relwithdebinfo
55*103e46e4SHarish Mahendrakar
56*103e46e4SHarish MahendrakarAnd your standard debug build will be produced using:
57*103e46e4SHarish Mahendrakar$ cmake path/to/libwebm -DCMAKE_BUILD_TYPE=debug
58*103e46e4SHarish Mahendrakar
59*103e46e4SHarish Mahendrakar
60*103e46e4SHarish MahendrakarTests
61*103e46e4SHarish Mahendrakar
62*103e46e4SHarish MahendrakarTo enable libwebm tests add -DENABLE_TESTS=ON CMake generation command line. For
63*103e46e4SHarish Mahendrakarexample:
64*103e46e4SHarish Mahendrakar
65*103e46e4SHarish Mahendrakar$ cmake path/to/libwebm -G Xcode -DENABLE_TESTS=ON
66*103e46e4SHarish Mahendrakar
67*103e46e4SHarish MahendrakarLibwebm tests depend on googletest. By default googletest is expected to be a
68*103e46e4SHarish Mahendrakarsibling directory of the Libwebm repository. To change that, update your CMake
69*103e46e4SHarish Mahendrakarcommand to be similar to the following:
70*103e46e4SHarish Mahendrakar
71*103e46e4SHarish Mahendrakar$ cmake path/to/libwebm -G Xcode -DENABLE_TESTS=ON \
72*103e46e4SHarish Mahendrakar  -DGTEST_SRC_DIR=/path/to/googletest
73*103e46e4SHarish Mahendrakar
74*103e46e4SHarish MahendrakarThe tests rely upon the LIBWEBM_TEST_DATA_PATH environment variable to locate
75*103e46e4SHarish Mahendrakartest input. The following example demonstrates running the muxer tests from the
76*103e46e4SHarish Mahendrakarbuild directory:
77*103e46e4SHarish Mahendrakar
78*103e46e4SHarish Mahendrakar$ LIBWEBM_TEST_DATA_PATH=path/to/libwebm/testing/testdata ./mkvmuxer_tests
79*103e46e4SHarish Mahendrakar
80*103e46e4SHarish MahendrakarNote: Libwebm Googletest integration was built with googletest from
81*103e46e4SHarish Mahendrakar      https://github.com/google/googletest.git at git revision
82*103e46e4SHarish Mahendrakar      ddb8012eb48bc203aa93dcc2b22c1db516302b29.
83*103e46e4SHarish Mahendrakar
84*103e46e4SHarish Mahendrakar
85*103e46e4SHarish MahendrakarCMake Include-what-you-use integration
86*103e46e4SHarish Mahendrakar
87*103e46e4SHarish MahendrakarInclude-what-you-use is an analysis tool that helps ensure libwebm includes the
88*103e46e4SHarish MahendrakarC/C++ header files actually in use. To enable the integration support
89*103e46e4SHarish MahendrakarENABLE_IWYU must be turned on at cmake run time:
90*103e46e4SHarish Mahendrakar
91*103e46e4SHarish Mahendrakar$ cmake path/to/libwebm -G "Unix Makefiles" -DENABLE_IWYU=ON
92*103e46e4SHarish Mahendrakar
93*103e46e4SHarish MahendrakarThis adds the iwyu target to the build. To run include-what-you-use:
94*103e46e4SHarish Mahendrakar
95*103e46e4SHarish Mahendrakar$ make iwyu
96*103e46e4SHarish Mahendrakar
97*103e46e4SHarish MahendrakarThe following requirements must be met for ENABLE_IWYU to enable the iwyu
98*103e46e4SHarish Mahendrakartarget:
99*103e46e4SHarish Mahendrakar
100*103e46e4SHarish Mahendrakar1. include-what-you-use and iwyu_tool.py must be in your PATH.
101*103e46e4SHarish Mahendrakar2. A python interpreter must be on the system and available to CMake.
102*103e46e4SHarish Mahendrakar
103*103e46e4SHarish MahendrakarThe values of the following variables are used to determine if the requirements
104*103e46e4SHarish Mahendrakarhave been met. Values to the right of the equals sign are what a successful run
105*103e46e4SHarish Mahendrakarmight look like:
106*103e46e4SHarish Mahendrakar  iwyu_path=/path/to/iwyu_tool.py
107*103e46e4SHarish Mahendrakar  iwyu_tool_path=/path/to/include-what-you-use
108*103e46e4SHarish Mahendrakar  PYTHONINTERP_FOUND=TRUE
109*103e46e4SHarish Mahendrakar
110*103e46e4SHarish MahendrakarAn empty PYTHONINTERP_FOUND, or iwyu_path/iwyu_tool_path suffixed with NOTFOUND
111*103e46e4SHarish Mahendrakarare failures.
112*103e46e4SHarish Mahendrakar
113*103e46e4SHarish MahendrakarFor Include-what-you-use setup instructions, see:
114*103e46e4SHarish Mahendrakarhttps://github.com/include-what-you-use/include-what-you-use/blob/master/docs/InstructionsForUsers.md
115*103e46e4SHarish Mahendrakar
116*103e46e4SHarish MahendrakarIf, when building the iwyu target, compile errors reporting failures loading
117*103e46e4SHarish Mahendrakarstandard include files occur, one solution can be found here:
118*103e46e4SHarish Mahendrakarhttps://github.com/include-what-you-use/include-what-you-use/issues/100
119*103e46e4SHarish Mahendrakar
120*103e46e4SHarish Mahendrakar
121*103e46e4SHarish MahendrakarCMake cross compile
122*103e46e4SHarish MahendrakarTo cross compile libwebm for Windows using mingw-w64 run cmake with the
123*103e46e4SHarish Mahendrakarfollowing arguments:
124*103e46e4SHarish Mahendrakar
125*103e46e4SHarish Mahendrakar$ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/libwebm/build/mingw-w64_toolchain.cmake \
126*103e46e4SHarish Mahendrakar  path/to/libwebm
127*103e46e4SHarish Mahendrakar
128*103e46e4SHarish MahendrakarNote1: As of this writing googletest will not build via mingw-w64 without
129*103e46e4SHarish Mahendrakardisabling pthreads.
130*103e46e4SHarish Mahendrakargoogletest hash: d225acc90bc3a8c420a9bcd1f033033c1ccd7fe0
131*103e46e4SHarish Mahendrakar
132*103e46e4SHarish MahendrakarTo build with tests when using mingw-w64 use the following arguments when
133*103e46e4SHarish Mahendrakarrunning CMake:
134*103e46e4SHarish Mahendrakar
135*103e46e4SHarish Mahendrakar$ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/libwebm/build/mingw-w64_toolchain.cmake \
136*103e46e4SHarish Mahendrakar  -DENABLE_TESTS=ON -Dgtest_disable_pthreads=ON path/to/libwebm
137*103e46e4SHarish Mahendrakar
138*103e46e4SHarish MahendrakarNote2: i686-w64-mingw32 is the default compiler. This can be controlled using
139*103e46e4SHarish Mahendrakarthe MINGW_PREFIX variable:
140*103e46e4SHarish Mahendrakar
141*103e46e4SHarish Mahendrakar$ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/libwebm/build/mingw-w64_toolchain.cmake \
142*103e46e4SHarish Mahendrakar  -DMINGW_PREFIX=x86_64-w64-mingw32 path/to/libwebm
143*103e46e4SHarish Mahendrakar
144