Difference between revisions of "Compiling with CMake (OpenXcom)"
m |
|||
Line 22: | Line 22: | ||
ccmake is a command line tool which allows you to configure the build interactively. You can launch it with: | ccmake is a command line tool which allows you to configure the build interactively. You can launch it with: | ||
− | cd | + | cd build |
− | ccmake -G 'Generator name' | + | ccmake -G 'Generator name' .. |
Generator name, is the name of the build system you wish to use. You can see possible values with: | Generator name, is the name of the build system you wish to use. You can see possible values with: | ||
cmake help | cmake help | ||
Line 32: | Line 32: | ||
'''Using CMake command line tools''' | '''Using CMake command line tools''' | ||
− | cd | + | cd build |
− | cmake -G 'Generator name' -DOPTION_NAME=OPTION_VALUE | + | cmake -G 'Generator name' -DOPTION_NAME=OPTION_VALUE .. |
You can check options value with: | You can check options value with: | ||
cmake -L | cmake -L | ||
To change the value of an option: | To change the value of an option: | ||
− | cmake -DOPTION_NAME=OPTION_VALUE | + | cmake -DOPTION_NAME=OPTION_VALUE .. |
+ | For example: | ||
+ | cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/bin/openxcom.inst .. | ||
Once the project is generated, you can use it as you would have done without using CMake. | Once the project is generated, you can use it as you would have done without using CMake. | ||
Line 44: | Line 46: | ||
== End-to-end example == | == End-to-end example == | ||
− | This will get you up and running from scratch to a fully functional installation. This example is written with Linux users in mind, but can be adapted easily for Windows or OSX | + | This will get you up and running from scratch to a fully functional installation. This example is written with Linux users in mind, but can be adapted easily for Windows or OSX. |
− | |||
− | |||
− | |||
git clone [email protected]:SupSuper/OpenXcom.git openxcom | git clone [email protected]:SupSuper/OpenXcom.git openxcom | ||
− | {copy XCOM1 assets into openxcom/bin/ | + | OR "git clone https://github.com/SupSuper/OpenXcom.git openxcom" if the above doesn't work for whatever reason |
+ | {copy XCOM1 assets into openxcom/bin/UFO and XCOM2 assets into openxcom/bin/TFTD} | ||
mkdir openxcom/build | mkdir openxcom/build | ||
cd openxcom/build | cd openxcom/build |
Revision as of 03:14, 18 May 2015
Before building
In addition to the OpenXcom dependencies, you will need CMake version 2.8.0 or later.
CMake can be used to build OpenXcom with differents tools. So far only the Makefile and Visual Studio have been tried. Other Generators (Xcode/Code blocks, ...) might work, but if you choose to use them, we currently have no way to make sure that they work. If broken, patches are welcome to make them work.
Note : Once a project has been generated, you don't need to regenerate it after updating the source. CMake will automatically check for modifications and regenerate the project for you.
Source dir/build dir: CMake allows you to separate the source directory (where the source resides) from the build directory (where the project is generated). This allows you to always have a clean source directory (no clutter left from builds). The source and build directories can be the same, but it's generally recommended to separate them. The standard name for the build directory is "build", which you must create yourself under the top level OpenXcom directory (where the README.md file is).
Generate a build project
Using CMake GUI tool
- Launch the CMake configuration tools. First specify the path to the OpenXcom source tree.
- Then specify where the OpenXcom project should be generated (e.g. the "build" directory that you created).
- Click on configure. The first time, CMake will ask you which kind of build tool you wish to use.
- Now CMake will analyze your system and once finished, you will be presented with a list of options. If all is fine for you, then click on generate.
Using CMake interactive command line tools
ccmake is a command line tool which allows you to configure the build interactively. You can launch it with:
cd build ccmake -G 'Generator name' ..
Generator name, is the name of the build system you wish to use. You can see possible values with:
cmake help
If omitted, cmake will default to 'Unix Makefile'. Note that this needed only the first time you generate the project.
As with the GUI, tweak the options as needed and then configure the project before generating it.
Using CMake command line tools
cd build cmake -G 'Generator name' -DOPTION_NAME=OPTION_VALUE ..
You can check options value with:
cmake -L
To change the value of an option:
cmake -DOPTION_NAME=OPTION_VALUE ..
For example:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/bin/openxcom.inst ..
Once the project is generated, you can use it as you would have done without using CMake.
End-to-end example
This will get you up and running from scratch to a fully functional installation. This example is written with Linux users in mind, but can be adapted easily for Windows or OSX.
git clone [email protected]:SupSuper/OpenXcom.git openxcom OR "git clone https://github.com/SupSuper/OpenXcom.git openxcom" if the above doesn't work for whatever reason {copy XCOM1 assets into openxcom/bin/UFO and XCOM2 assets into openxcom/bin/TFTD} mkdir openxcom/build cd openxcom/build cmake .. ccmake .. {set CMAKE_BUILD_TYPE to Release (or Debug if you want useful stack traces, but that will slow the game /way/ down)} {set CMAKE_INSTALL_PREFIX to /home/yourusername/bin/OpenXcom (or whatever)} {configure, generate, and exit} make -j3 make install
Then create an executable shell script in your $HOME/bin directory (ensure it is in your PATH) named openxcom with the contents:
#!/bin/sh "$HOME/bin/OpenXcom/bin/openxcom" -data "$HOME/bin/OpenXcom/share/openxcom/data"
now just run
openxcom
to play : )