• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# How to build sfntly C++ port
2
3## Build Environment Requirements
4
5*   cmake 2.6 or above
6*   C++ compiler requirement
7    *   Windows: Visual C++ 2008, Visual C++ 2010
8    *   Linux: g++ 4.3 or above.
9        g++ must support built-in atomic ops and has companion libstd++.
10    *   Mac: Apple XCode 3.2.5 or above.
11
12## External Dependencies
13
14sfntly is dependent on several external packages.
15
16*   [Google C++ Testing Framework](https://github.com/google/googletest)
17
18    You can download the package yourself or extract the one from `ext/redist`.
19    The package needs to be extracted to ext and rename/symbolic link to `gtest`.
20
21    sfntly C++ port had been tested with gTest 1.6.0.
22
23*   ICU
24
25    For Linux, default ICU headers in system will be used.
26    Linux users please make sure you have dev packages for ICU.
27    For example, you can run `sudo apt-get install libicu-dev` in Ubuntu and see if the required library is installed.
28
29    For Windows, download from http://site.icu-project.org/download or extract the one from `ext/redist`.
30    You can also provide your own ICU package.
31    However, you need to alter the include path, library path, and provide `icudt.dll`.
32
33    Tested with ICU 4.6.1 binary release.
34
35    For Mac users, please download ICU source tarball from http://site.icu-project.org/download
36    and install according to ICU documents.
37
38## Getting the Source
39
40Clone the Git repository from https://github.com/googlei18n/sfntly.
41
42## Building on Windows
43
44Let's assume your folder for sfntly is `d:\src\sfntly`.
45
461.  If you don't have cmake installed, extract the cmake-XXX.zip
47    into `d:\src\sfntly\cpp\ext\cmake` removing the "-XXX" part.
48    The extracted binary should be in `d:\src\sfntly\cpp\ext\cmake\bin\cmake.exe`.
492.  Extract gtest-XXX.zip into `d:\src\sfntly\cpp\ext\gtest`
50    removing the "-XXX" part.
513.  Extract icu4c-XXX.zip into `d:\src\sfntly\cpp\ext\icu`
52    removing the "-XXX" part.
534.  Run the following commands to create the Visual Studio solution files:
54
55    ```
56    d:
57    cd d:\src\sfntly\cpp
58    md build
59    cd build
60    ..\ext\cmake\bin\cmake ..
61    ```
62
63You should see `sfntly.sln` in `d:\src\sfntly\cpp\build`.
64
655.  Until the test is modified to access the fonts in the `ext\data` directory:
66    copy the test fonts from `d:\src\sfntly\cpp\data\ext\` to `d:\src\sfntly\cpp\build\bin\Debug`.
676.  Open sfntly.sln.
68    Since sfntly use STL extensively, please patch your Visual Studio for any STL-related hotfixes/service packs.
697.  Build the solution (if the icuuc dll is not found,
70    you may need to add `d:\src\sfntly\cpp\ext\icu\bin` to the system path).
71
72### Building on Windows via Command Line
73
74Visual Studio 2008 and 2010 support command line building,
75therefore you dont need the IDE to build the project.
76
77For Visual Studio 2008 (assume its installed at `c:\vs08`)
78
79    cd d:\src\sfntly\cpp\build
80    ..\ext\cmake\bin\cmake .. -G "Visual Studio 9 2008"
81    c:\vs08\common7\tools\vsvars32.bat
82    vcbuild sfntly.sln
83
84We invoke the cmake with `-G` to make sure
85Visual Studio 2008 solution/project files are generated.
86You can also use `devenv sfntly.sln /build`
87to build the solution instead of using `vcbuild`.
88
89There are subtle differences between `devenv` and `vcbuild`.
90Please refer to your Visual Studio manual for more details.
91
92For Visual Studio 2010 (assume its installed at `c:\vs10`)
93
94
95    cd d:\src\sfntly\cpp\build
96    ..\ext\cmake\bin\cmake .. -G "Visual Studio 10"
97    c:\vs10\common7\tools\vsvars32.bat
98    msbuild sfntly.sln
99
100If you install both Visual Studio 2008 and 2010 on your system,
101you cant run the scripts above in the same Command Prompt window.
102`vsvars32.bat` assumes that it is run from a clean Command Prompt.
103
104## Building on Linux/Mac
105
106### Recommended Out-of-Source Building
107
1081.  `cd` *<sfntly dir>*
1092.  `mkdir build`
1103.  `cd build`
1114.  `cmake ..`
1125.  `make`
113
114### Default In-Source Building
115
116> This is not recommended.
117> Please use out-of-source whenever possible.
118
1191.  `cd` *<sfntly dir>*
1202.  `cmake .`
1213.  `make`
122
123### Using clang Instead
124
125Change the `cmake` command line to
126
127    CC=clang CXX=clang++ cmake ..
128
129The generated Makefile will use clang.
130Please note that sfntly uses a lot of advanced C++ semantics that
131might not be understood or compiled correctly by earlier versions
132of clang (2.8 and before).
133
134sfntly is tested to compile and run correctly on clang 3.0 (trunk 135314).
135clang 2.9 might work but unfortunately we dont have the resource to test it.
136
137### Debug and Release Builds
138
139Currently Debug builds are set as default.
140To build Release builds, you can either modify the `CMakeList.txt`,
141or set environment variable `CMAKE_BUILD_TYPE` to `Release`
142before invoking `cmake`.
143
144Windows users can just switch the configuration in Visual Studio.
145
146## Running Unit Test
147
148A program named `unit_test` will be generated after a full compilation.
149It expects fonts in `data/ext` to be in the same directory it resides to execute the unit tests.
150Windows users also needs to copy `icudt.dll` and `icuuc.dll` to that directory.
151