OLD | NEW |
(Empty) | |
| 1 Experimental CMake build for adblockpluscore |
| 2 ============================================ |
| 3 |
| 4 This files describes an experimental build using CMake. For the duration of |
| 5 this experiment, this file will describe the build independently, leaving the |
| 6 existing README.md intact. |
| 7 |
| 8 Requirements |
| 9 ------------ |
| 10 |
| 11 * [CMake](https://cmake.org). The Emscripten toolchain file requires version |
| 12 3.4.3 or newer. |
| 13 * [Emscripten 1.37](https://kripken.github.io/emscripten-site/) |
| 14 |
| 15 Configuring CMake |
| 16 ----------------- |
| 17 |
| 18 CMake uses a cache to hold configuration information that is not an ordinary |
| 19 part of the write-build-test cycle. Thus the first invocation of CMake requires |
| 20 extra configuration parameters. Subsequent invocations do not require these. |
| 21 We require two such kinds of configuration data: |
| 22 * Generator for build system |
| 23 * Emscriptem tool chain |
| 24 |
| 25 ### Build system generator |
| 26 |
| 27 CMake is a cross-platform build system generator. It has the capability of |
| 28 generating project files for a number of build systems, including those that |
| 29 are an integral part of an IDE. Specifically, these include makefiles in |
| 30 several variants, ninja, Eclipse, Visual Studio, and XCode. |
| 31 |
| 32 To set up the cache with a generator, use the `-G` option on the CMake command |
| 33 line. The quickest way to find the exact text to use as the argument to this |
| 34 option is run CMake with the `--help` option`. Further information is available |
| 35 in the CMake documentation; see cmake-generators(7). |
| 36 |
| 37 ### Emscripten |
| 38 |
| 39 CMake treats Emscripten as a cross-compiler. CMake can auto-detect native |
| 40 compilers but requires pre-configuration for cross-compilers. Emscripten |
| 41 provides a CMake toolchain file for this purpose. The location of this file is |
| 42 what CMake ultimately needs. |
| 43 |
| 44 The most direct way to specify the path to the toolchain file is to define a |
| 45 cache variable directly on the CMake command line. The toolchain file is |
| 46 buried within the Emscripten installation. The name of the cache variable and |
| 47 the specific location of the file are visible within the following command |
| 48 line fragment: |
| 49 |
| 50 ``` |
| 51 cmake -DCMAKE_TOOLCHAIN_FILE=<EmscriptenRoot>/cmake/Modules/Platform/Emscrip
ten.cmake [...] |
| 52 ``` |
| 53 |
| 54 Note that the `<EmscriptenRoot>` about is _not_ the root of the Emscripten |
| 55 SDK. Within the SDK, the location is `<SdkRoot>/emscripten/<version>` |
| 56 |
| 57 #### Emscripten environment |
| 58 |
| 59 The Emscripten toolchain file is not particularly mature and can somewhat |
| 60 brittle in practice. In particular, it does not attempt to see if it's being |
| 61 used from within its SDK installation tree. Instead, it assumes that it is |
| 62 running from within an Emscripten shell. It requires all relevant executables |
| 63 to be present with the search path. It expects to find certain environment |
| 64 variables. |
| 65 |
| 66 Therefore, it is highly recommended that initial configuration of CMake be run |
| 67 from within an Emscripten shell. These are available from the Emscripten SDK. |
| 68 CMake will appear to configure correctly in other circumstances, but it can |
| 69 fail otherwise. |
| 70 |
| 71 Using CMake |
| 72 ----------- |
| 73 |
| 74 CMake supports build both inside the source tree and outside it. The CMake |
| 75 working directory is whatever the current directory is when CMake is initially |
| 76 configured. The project root is specified on the command line of this |
| 77 configuration run. For an in-source build, simply run CMake in the project root. |
| 78 |
| 79 The present CMakeLists.txt is better suited for an out-of-source build. It |
| 80 does not put its intermediate or output files in any special place, so they all |
| 81 end up in the build directory. |
| 82 |
| 83 ### Configurations |
| 84 |
| 85 The present CMakeLists.txt supports four configurations: |
| 86 * Release - `compile` |
| 87 * Debug - `compile -d` |
| 88 * ReleaseTrace - `compile -t` |
| 89 * DebugTrace - `compile -d -t` |
| 90 |
| 91 A single-configuration generator, such as `make` or `ninja`, supports only one |
| 92 configuration per CMake build directory. Multiple build directories for |
| 93 different configurations, however, work just fine; each build directory gets |
| 94 its own CMake cache and working directory. [EH: I have a test setup locally |
| 95 with all four configurations and some scripts to configure everything and to |
| 96 build everything.] If no configuration is specified, it defaults to "Release". |
| 97 |
| 98 ``` |
| 99 cmake -DCMAKE_BUILD_TYPE=Release [...] |
| 100 ``` |
| 101 |
| 102 A multiple-configuration generator, such as for Eclipse or XCode, makes all |
| 103 configurations available through the user interface of the IDE. |
| 104 |
| 105 Notes |
| 106 ----- |
| 107 |
| 108 ### Setting up Emscripten under Cygwin. |
| 109 |
| 110 tl;dr version: Don't. |
| 111 |
| 112 It's a known issue that the Emscripten tool chain as distributed does not work |
| 113 under Cygwin. The core of the issue is that Emscripten uses a number of native |
| 114 Windows executables and the transition from Cygwin path names to Windows path |
| 115 names doesn't work correctly. |
| 116 |
| 117 https://github.com/kripken/emscripten/issues/3947 |
| 118 |
| 119 Once the command `emcc -v` runs correctly, CMake will be able to set up the |
| 120 Emscripten tool chain. Even then, there will still be errors in other ways. |
| 121 |
| 122 |
| 123 Draft Notes |
| 124 ----------- |
| 125 |
| 126 There are a few known deficiencies. |
| 127 |
| 128 ### Other targets |
| 129 |
| 130 There are no targets for testing or documentation. |
| 131 |
| 132 ### eslint |
| 133 |
| 134 There's no provision for ignoring compiled-js files in eslint. This is only an |
| 135 issue for an in-source-tree build. |
OLD | NEW |