02.CMake 源码:使用CMAKE配置和生成解决方案
详细教程见 http://www.trinitycore.info/
============================================================================
0. 必须安装几个软件才能CMake
①CMake
②vcredist_2008SP1x86.exe
③Win32OpenSSL-1_0_1c.exe
④VS2008及以上
⑤MySQL
============================================================================
1. Open the CMake GUI (default install directory is C:\Program Files (x86)\CMake 2.8\bin).
The two top text areas are used to tell where CMake should look for the source tree, and also where to put the build files.
2. Click Browse Source... -> Select the source directory (C:/Trinity)
选择源码路径,是整个根目录,不是单一的src目录
3. Click Browse Build... -> Select the build directory (D:/Build)
选择解决方案生成的路径
4. Click Configure,出一个对话框
5. Make sure Use default native compilers is checked
配置时,选择Use default native compilers
6. In the drop-down menu, choose the version of the compiler you downloaded in the Software Required section (which version of Visual C++ Express did you install?).
Note: CMake is not a compiler. It merely generates the build files required for the compiler you choose, so choose wisely.
选择实用编译器的类型(如VS2008),貌似生成时,电脑上必须安装了该编译器
7. Click Finish. CMake will begin chewing through the source code and analyzing the CMakeLists.txt spread all over the source tree.
点Finish,CMake工具会搜索源码配置,分析出一些编译选项来。确保cmake-gui下面的信息提示里面没有ERROR字样,否则根据具体错误修正后重来。
8. CMake shows you a list of options for selecting different components of the build.
①Check "Tools". This will compile the map extractors needed later in the setup. NOTE: This is VERY important for you to follow.
选择"Tools"选项,关于地图的解压缩工具是否生成,即在默认的情况下,选择多TOOLS。
②All other default selections are OK in most cases, however, if your MySQL server version is different than 5.5.x, we strongly recommend to uncheck the USE_MYSQL_SOURCES option. This tells CMake to look for include files and client libraries in your MySQL server installation instead of using the MySQL source files provided with TrinityCore. This also requires that your selected compiler is for the same architecture (32bit or 64bit) as your MySQL Server Community Edition.
如果MySQL不是5.5.x不要选USE_MYSQL_SOURCES。
9. When your selection is done, click Configure again.
Here are some useful things to learn about the information in the large white text box at the bottom of the window (your configuration may be slightly different):
①It detected that we're on a 64-bit platform
检查系统是否64位
②It detected that we have a proper version of MySQL
检查MySQL版本
③It detected that we have properly installed OpenSSL libraries/headers
检查OpenSSL 库和头文件
10. Click Generate. This will install the selected build files into your D:/Build folder.
最后点Generate,CMake会在D:\Trinity\Build下面生成Visual Stdio 2008的项目文件。
===============================================================================
可能出现的问题:
1、第10步里面_GIT_EXEC应该是msysgit中git的绝对路径,如果没有则是msysgit安装的时候没有把自己加到系统路径里面去。
2、如果下面出现红色的ERROR提示,类似于
Could not copy from: D:/dev/cmake/share/cmake-2.8/Templates/CMakeVSMacros2.vsmacros
to: C:/Documents and Settings/Administrator/ÎÒµÄÎĵµ/Visual Studio 2010/Projects/VSMacros80/CMakeMacros/CMakeVSMacros2.vsmacros
这个好像是因为CMake没法识别中文路径,把“我的文档”的位置改一下吧,改成路径不带中文的。或者直接自己把提示中的CMakeVSMacros2.vsmacros拷到“我的文档”下的Visual Studio 2010/Projects/VSMacros80/CMakeMacros/。