Tom Finegan | b386aa5 | 2015-02-13 11:23:40 -0800 | [diff] [blame] | 1 | Building Libwebm |
| 2 | |
| 3 | To build libwebm you must first create project files. To do this run cmake |
| 4 | and pass it the path to your libwebm repo. |
| 5 | |
| 6 | Makefile.unix can be used as a fallback on systems that cmake does not |
| 7 | support. |
| 8 | |
| 9 | |
| 10 | CMake Basics |
| 11 | |
| 12 | To generate project/make files for the default toolchain on your system simply |
| 13 | run cmake with the path to the libwebm repo: |
| 14 | |
| 15 | $ cmake path/to/libwebm |
| 16 | |
| 17 | On Windows the above command will produce Visual Studio project files for the |
| 18 | newest Visual Studio detected on the system. On Mac OS X and Linux systems, the |
| 19 | above command will produce a makefile. |
| 20 | |
| 21 | To control what types of projects are generated the -G parameter is added to |
| 22 | the cmake command line. This argument must be followed by the name of a |
| 23 | generator. Running cmake with the --help argument will list the available |
| 24 | generators for your system. |
| 25 | |
| 26 | On Mac OS X you would run the following command to generate Xcode projects: |
| 27 | |
| 28 | $ cmake path/to/libwebm -G Xcode |
| 29 | |
| 30 | On a Windows box you would run the following command to generate Visual Studio |
| 31 | 2013 projects: |
| 32 | |
| 33 | $ cmake path/to/libwebm -G "Visual Studio 12" |
| 34 | |
| 35 | To generate 64-bit Windows Visual Studio 2013 projects: |
| 36 | |
| 37 | $ cmake path/to/libwebm "Visual Studio 12 Win64" |
| 38 | |
| 39 | |
| 40 | CMake Makefiles: Debugging and Optimization |
| 41 | |
| 42 | Unlike Visual Studio and Xcode projects, the build configuration for make builds |
| 43 | is controlled when you run cmake. The following examples demonstrate various |
| 44 | build configurations. |
| 45 | |
| 46 | Omitting the build type produces makefiles that use build flags containing |
| 47 | neither optimization nor debug flags: |
| 48 | $ cmake path/to/libwebm |
| 49 | |
| 50 | A makefile using release (optimized) flags is produced like this: |
| 51 | $ cmake path/to/libwebm -DCMAKE_BUILD_TYPE=release |
| 52 | |
| 53 | A release build with debug info can be produced as well: |
| 54 | $ cmake path/to/libwebm -DCMAKE_BUILD_TYPE=relwithdebinfo |
| 55 | |
| 56 | And your standard debug build will be produced using: |
| 57 | $ cmake path/to/libwebm -DCMAKE_BUILD_TYPE=debug |
Tom Finegan | 9299bbb | 2016-01-11 18:46:55 -0800 | [diff] [blame] | 58 | |
| 59 | |
| 60 | Tests |
| 61 | |
| 62 | To enable libwebm tests add -DENABLE_TESTS=ON CMake generation command line. For |
| 63 | example: |
| 64 | |
| 65 | $ cmake path/to/libwebm -G Xcode -DENABLE_TESTS=ON |
| 66 | |
| 67 | Libwebm tests depend on googletest. By default googletest is expected to be a |
| 68 | sibling directory of the Libwebm repository. To change that, update your CMake |
| 69 | command to be similar to the following: |
| 70 | |
| 71 | $ cmake path/to/libwebm -G Xcode -DENABLE_TESTS=ON \ |
| 72 | -DGTEST_SRC_DIR=/path/to/googletest |
| 73 | |
| 74 | The tests rely upon the LIBWEBM_TEST_DATA_PATH environment variable to locate |
| 75 | test input. The following example demonstrates running the muxer tests from the |
| 76 | build directory: |
| 77 | |
Vignesh Venkatasubramanian | a0d67d0 | 2017-03-07 11:34:39 -0800 | [diff] [blame] | 78 | $ LIBWEBM_TEST_DATA_PATH=path/to/libwebm/testing/testdata ./mkvmuxer_tests |
Tom Finegan | 9299bbb | 2016-01-11 18:46:55 -0800 | [diff] [blame] | 79 | |
Tom Finegan | e569ab0 | 2016-01-25 15:13:34 -0500 | [diff] [blame] | 80 | Note: Libwebm Googletest integration was built with googletest from |
| 81 | https://github.com/google/googletest.git at git revision |
Tom Finegan | 9299bbb | 2016-01-11 18:46:55 -0800 | [diff] [blame] | 82 | ddb8012eb48bc203aa93dcc2b22c1db516302b29. |
| 83 | |
Tom Finegan | 16524e8 | 2016-03-10 13:22:51 -0800 | [diff] [blame] | 84 | |
| 85 | CMake Include-what-you-use integration |
| 86 | |
| 87 | Include-what-you-use is an analysis tool that helps ensure libwebm includes the |
| 88 | C/C++ header files actually in use. To enable the integration support |
| 89 | ENABLE_IWYU must be turned on at cmake run time: |
| 90 | |
| 91 | $ cmake path/to/libwebm -G "Unix Makefiles" -DENABLE_IWYU=ON |
| 92 | |
| 93 | This adds the iwyu target to the build. To run include-what-you-use: |
| 94 | |
| 95 | $ make iwyu |
| 96 | |
| 97 | The following requirements must be met for ENABLE_IWYU to enable the iwyu |
| 98 | target: |
| 99 | |
| 100 | 1. include-what-you-use and iwyu_tool.py must be in your PATH. |
| 101 | 2. A python interpreter must be on the system and available to CMake. |
| 102 | |
| 103 | The values of the following variables are used to determine if the requirements |
| 104 | have been met. Values to the right of the equals sign are what a successful run |
| 105 | might look like: |
| 106 | iwyu_path=/path/to/iwyu_tool.py |
| 107 | iwyu_tool_path=/path/to/include-what-you-use |
| 108 | PYTHONINTERP_FOUND=TRUE |
| 109 | |
| 110 | An empty PYTHONINTERP_FOUND, or iwyu_path/iwyu_tool_path suffixed with NOTFOUND |
| 111 | are failures. |
| 112 | |
| 113 | For Include-what-you-use setup instructions, see: |
| 114 | https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/InstructionsForUsers.md |
| 115 | |
| 116 | If, when building the iwyu target, compile errors reporting failures loading |
| 117 | standard include files occur, one solution can be found here: |
| 118 | https://github.com/include-what-you-use/include-what-you-use/issues/100 |
| 119 | |
| 120 | |
Tom Finegan | a1cba34 | 2016-04-01 11:58:28 -0400 | [diff] [blame] | 121 | CMake cross compile |
James Zern | 87443a6 | 2016-04-07 10:46:24 -0700 | [diff] [blame] | 122 | To cross compile libwebm for Windows using mingw-w64 run cmake with the |
| 123 | following arguments: |
Tom Finegan | a1cba34 | 2016-04-01 11:58:28 -0400 | [diff] [blame] | 124 | |
James Zern | 87443a6 | 2016-04-07 10:46:24 -0700 | [diff] [blame] | 125 | $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/libwebm/build/mingw-w64_toolchain.cmake \ |
Tom Finegan | a1cba34 | 2016-04-01 11:58:28 -0400 | [diff] [blame] | 126 | path/to/libwebm |
| 127 | |
James Zern | 87443a6 | 2016-04-07 10:46:24 -0700 | [diff] [blame] | 128 | Note1: As of this writing googletest will not build via mingw-w64 without |
Tom Finegan | a1cba34 | 2016-04-01 11:58:28 -0400 | [diff] [blame] | 129 | disabling pthreads. |
| 130 | googletest hash: d225acc90bc3a8c420a9bcd1f033033c1ccd7fe0 |
| 131 | |
James Zern | 87443a6 | 2016-04-07 10:46:24 -0700 | [diff] [blame] | 132 | To build with tests when using mingw-w64 use the following arguments when |
| 133 | running CMake: |
Tom Finegan | a1cba34 | 2016-04-01 11:58:28 -0400 | [diff] [blame] | 134 | |
James Zern | 87443a6 | 2016-04-07 10:46:24 -0700 | [diff] [blame] | 135 | $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/libwebm/build/mingw-w64_toolchain.cmake \ |
Tom Finegan | a1cba34 | 2016-04-01 11:58:28 -0400 | [diff] [blame] | 136 | -DENABLE_TESTS=ON -Dgtest_disable_pthreads=ON path/to/libwebm |
| 137 | |
| 138 | Note2: i686-w64-mingw32 is the default compiler. This can be controlled using |
| 139 | the MINGW_PREFIX variable: |
| 140 | |
James Zern | 87443a6 | 2016-04-07 10:46:24 -0700 | [diff] [blame] | 141 | $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/libwebm/build/mingw-w64_toolchain.cmake \ |
Tom Finegan | a1cba34 | 2016-04-01 11:58:28 -0400 | [diff] [blame] | 142 | -DMINGW_PREFIX=x86_64-w64-mingw32 path/to/libwebm |
Tom Finegan | 16524e8 | 2016-03-10 13:22:51 -0800 | [diff] [blame] | 143 | |