README.cmake 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. Warning cmake is unsupported build type.
  2. 0. Contents
  3. ------------
  4. 1. Basic syntax
  5. 2. How do I...
  6. 3. Crosscompiling using CMake
  7. 4. Creating an installer binary for Windows
  8. This readme explains the most common parameters to CMake needed for
  9. building mana, as well as setting up a cross build environement to
  10. create Windows builds.
  11. 1. Basic syntax
  12. ---------------
  13. cmake [options] <source directory>
  14. If you don't need any special options just change to the directory where
  15. you extracted the sources and do `cmake . && make'
  16. The syntax for setting variables to control CMakes behaviour is
  17. -D <variable>=<value>
  18. 2. How do I...
  19. --------------
  20. - Use a custom install prefix (like --prefix on autoconf)?
  21. CMAKE_INSTALL_PREFIX=/path/to/prefix
  22. - Create a debug build?
  23. CMAKE_BUILD_TYPE=Debug .
  24. - Add additional package search directories?
  25. CMAKE_PREFIX_PATH=/prefix/path
  26. - Add additional include search directories?
  27. CMAKE_INCLUDE_PATH=/include/path
  28. For example, to build mana to install in /opt/mana, with libraries in
  29. /build/mana/lib, and SDL-headers in /build/mana/include/SDL you'd use
  30. the following command:
  31. cmake -D CMAKE_PREFIX_PATH=/build/mana \
  32. -D CMAKE_INCLUDE_PATH=/build/mana/include/SDL \
  33. -D CMAKE_INSTALL_PREFIX=/opt/mana .
  34. 3. Crosscompiling using CMake
  35. -----------------------------
  36. The following example assumes you're doing a Windows-build from within a
  37. UNIX environement, using mingw32 installed in /build/mingw32.
  38. - create a toolchain-file describing your environement:
  39. $ cat /build/toolchain.cmake
  40. # the name of the target operating system
  41. SET(CMAKE_SYSTEM_NAME Windows)
  42. # toolchain prefix, can be overridden by -DTOOLCHAIN=...
  43. IF (NOT TOOLCHAIN)
  44. SET(TOOLCHAIN "i386-mingw32-")
  45. ENDIF()
  46. # which compilers to use for C and C++
  47. SET(CMAKE_C_COMPILER ${TOOLCHAIN}gcc)
  48. SET(CMAKE_CXX_COMPILER ${TOOLCHAIN}g++)
  49. # here is the target environment located
  50. SET(CMAKE_FIND_ROOT_PATH /build/mingw32 /build/mana-libs )
  51. # adjust the default behaviour of the FIND_XXX() commands:
  52. # search headers and libraries in the target environment, search
  53. # programs in the host environment
  54. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  55. set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  56. set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  57. - set your PATH to include the bin-directory of your mingw32-installation:
  58. $ export PATH=/build/mingw32/bin:$PATH
  59. - configure the source tree for the build, using the toolchain file:
  60. $ cmake -DCMAKE_TOOLCHAIN_FILE=/build/toolchain.cmake .
  61. - use make for building the application
  62. 4. Creating an installer binary for Windows
  63. -------------------------------------------
  64. Call cmake with the following flags:
  65. - CMAKE_TOOLCHAIN_FILE=/build/toolchain.cmake
  66. The path to your toolchain file from chapter 3
  67. - VERSION=$VERSION
  68. The version number for the build, used to set client identification and
  69. EXE meta information. Needs to be in the form Major.Minor.Release.Build
  70. - CMAKE_BUILD_TYPE=RelWithDebInfo|Release
  71. RelWithDebInfo is the prefered build type, as it provides some backtrace
  72. information without blowing the binary up too much. Don't use Debug.
  73. Install nsis (on Debian, apt-get install nsis), and get the UnTGZ plugin:
  74. http://nsis.sourceforge.net/UnTGZ_plug-in
  75. Place untgz.dll in nsis plugins directory (on Debian, /usr/share/nsis/Plugins/)
  76. Now chdir to packaging/windows. Make sure you have the msgfmt program (from
  77. gettext), and execute make-translations.sh to generate translations from the
  78. po-files in ../../translations/
  79. Check that you've got the translations, and call `makensis setup.nsi' with the
  80. following parameters:
  81. -DDLLDIR=/build/mana-libs/lib/
  82. The directory you've put the libraries. It's the one from the toolchain file
  83. with /lib/ added at the end. If you'd like to include the Dr. MingW crash
  84. handler place exchndl.dll in this directory.
  85. -DPRODUCT_VERSION=$VERSION
  86. Same as above
  87. -DUPX=true
  88. Set to upx if you'd like to compress the binaries using upx (and install upx,
  89. of course). Will remove debug symbols.
  90. -DEXESUFFIX=/src
  91. Suffix to the source directory, pointing to the directory where the binaries
  92. are. For cmake-builds that's /src.
  93. To build the installer for the 0.1.0.0 release you'd do the following:
  94. $ cmake -DVERSION=0.1.0.0 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  95. -DCMAKE_TOOLCHAIN_FILE=/build/toolchain.cmake .
  96. [...]
  97. $ make
  98. [...]
  99. $ cd packaging/windows
  100. $ ./make-translations.sh
  101. [...]
  102. $ makensis -DDLLDIR=/build/mana-libs/lib/ -DPRODUCT_VERSION=0.1.0.0 \
  103. -DUPX=true -DEXESUFFIX=/src setup.nsi
  104. and end up with the installer in mana-0.1.0.0-win32.exe