Difference between revisions of "Compiling with CMake (OpenXcom)"
m (typo) |
|||
Line 6: | Line 6: | ||
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. |
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 |
+ | 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). |
Line 13: | Line 13: | ||
'''Using CMake GUI tool''' |
'''Using CMake GUI tool''' |
||
*Launch the CMake configuration tools. First specify the path to the OpenXcom source tree. |
*Launch the CMake configuration tools. First specify the path to the OpenXcom source tree. |
||
− | *Then specify where the OpenXcom project should be generated. |
+ | *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. |
*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. |
*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. |
||
Line 19: | Line 19: | ||
'''Using CMake interactive command line tools''' |
'''Using CMake interactive command line tools''' |
||
− | ccmake is a command line |
+ | ccmake is a command line tool which allows you to configure the build interactively. You can launch it with: |
cd "openxcom build dir" && |
cd "openxcom build dir" && |
||
ccmake -G 'Generator name' "path to openxcom source tree" |
ccmake -G 'Generator name' "path to openxcom source tree" |
||
Line 36: | Line 36: | ||
To change the value of an option: |
To change the value of an option: |
||
cmake -DOPTION_NAME=OPTION_VALUE "path to openxcom source tree" |
cmake -DOPTION_NAME=OPTION_VALUE "path to openxcom source tree" |
||
− | |||
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. |
||
+ | |||
+ | |||
+ | '''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. It assumes that you do not have OpenXcom installed in system directories (e.g. /usr/share/openxcom). If you do have a system-level OpenXcom installed, copy the /usr/share/openxcom/data directory to your OpenXcom source checkout directory (see below) and uninstall OpenXcom from your system. Otherwise, it will interact in unfriendly ways with the nightly build you are creating and running here. |
||
+ | |||
+ | git clone git@github.com:SupSuper/OpenXcom.git openxcom |
||
+ | {copy XCOM1 assets into openxcom/bin/data} |
||
+ | mkdir openxcom/build |
||
+ | cd openxcom/build |
||
+ | cmake .. |
||
+ | ccmake .. |
||
+ | {set CMAKE_BUILD_TYPE to Release (or Debug if you want useful stack traces)} |
||
+ | {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 : ) |
||
[[Category:OpenXcom]] |
[[Category:OpenXcom]] |
Revision as of 19:25, 23 October 2014
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 "openxcom build dir" && ccmake -G 'Generator name' "path to openxcom source tree"
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 "openxcom build dir" && cmake -G 'Generator name' -DOPTION_NAME=OPTION_VALUE "path to openxcom source tree"
You can check options value with:
cmake -L
To change the value of an option:
cmake -DOPTION_NAME=OPTION_VALUE "path to openxcom source tree"
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. It assumes that you do not have OpenXcom installed in system directories (e.g. /usr/share/openxcom). If you do have a system-level OpenXcom installed, copy the /usr/share/openxcom/data directory to your OpenXcom source checkout directory (see below) and uninstall OpenXcom from your system. Otherwise, it will interact in unfriendly ways with the nightly build you are creating and running here.
git clone git@github.com:SupSuper/OpenXcom.git openxcom {copy XCOM1 assets into openxcom/bin/data} mkdir openxcom/build cd openxcom/build cmake .. ccmake .. {set CMAKE_BUILD_TYPE to Release (or Debug if you want useful stack traces)} {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 : )