History: CMake Quick Start Guide
Source of version: 16
- «
- »
Copy to clipboard
{BOX(width="100%",class="Layout_box9")}{SPLIT(colsize=10%|70%)}{IMG(src="img/wiki_up/Star.png",imalign="left",link="CMake Quick Start Guide",title="CMake Quick Start Guide")}{IMG}
---
{DIV(class="bigBold")}((CMake Quick Start Guide|Quick Start Guide)){DIV}
For the impatient: Learn how to build Ogre with CMake in two minutes. If you encounter any problems or need some more advanced procedures, do read the rest of the sections below!
{SPLIT}{BOX}
!!Introduction
This guide is designed to get you building OGRE from source with the default settings in the shortest possible time, showing you the barest minimum of CMake to do that, and minus any real discussion. Remember that there is a lot more to the hows and whys of this process, so it's a good idea to go back to the ((Getting Started With CMake)) page and read the whole thing when you have time.
We assume here that you've already downloaded / extracted the OGRE source code into a folder on your local machine. From here, go to the section for your platform.
{VERSIONS(nav="y",default="Windows")}Hello
# Make sure you have downloaded, extracted and built the [http://www.ogre3d.org/forums/viewtopic.php?f=1&t=54533|dependencies package]
# [http://www.cmake.org/cmake/resources/software.html|Download CMake]. You want the 'Win32 installer' release in the binary distribution section
# Run the CMake installer, install wherever you like
# Launch CMake via Start > Program Files > CMake 2.8 > CMake
# In the "Where is the source code" box, type or browse to the root directory of your OGRE source (the one that contains the OgreMain folder)
# In the "Where to build the binaries" box, type or browse to any folder you like - this will be where the build output will go (libraries, headers, dlls & sample exes). The folder does not have to exist yet. Note that you can run this process more than once with different output folders if you want (but we won't complicate matters now)
# Hit the 'Configure' button near the bottom of the screen
# Pick your target compiler, e.g. "Visual Studio 8 2005"
# Answer 'Ok' when asked if you want to create the build directory
# Wait for the configure process to finish
# The screen will now have a bunch of configuration options on it, which will be red (this is to indicate this is the first time you've seen them). You can see the potential for customising your build here, but for now just click the 'Configure' button again
# The values will turn grey, and the 'Generate' button at the bottom will now be enabled. Click 'Generate'
# Build files will now be generated in the location you picked, and CMake will say "Generating done"
That's it for CMake! You now have a set of project files that are very much like you're used to in previous versions of OGRE, in the output folder you chose. Just browse there and open the main project file (e.g. OGRE.sln). You can build as before, but there is now a special target called 'ALL_BUILD' which is a quick way to build all targets for a specific configuration. Note that all build output is now stored in a subfolder of this build folder, and not in the original OGRE source folder - so you can create multiple builds from one source directory now.
---(Linux)--------------------------
# Install CMake via your distribution's package repository. For example, on Ubuntu type ~pp~sudo apt-get install cmake~/pp~ If your distribution does not provide an official CMake package, go to the [http://www.cmake.org|CMake website] and either download a binary package or download and compile CMake from source.
# Create a build directory somewhere on your filesystem - this will be where the build output will go.
# In a console, cd to the build directory and call cmake with the path to the source dir (i. e. where you extracted the Ogre source files): ~pp~cmake /path/to/Ogre/source/dir~/pp~
# Compile Ogre. Type: ~pp~make~/pp~ Don't forget that make provides the -j option which you can use to spawn multiple make processes to speed up compiling on a multi-core PC! For example, this works well on a dual-core: ~pp~make -j3~/pp~
# Install Ogre. Type as root: ~pp~make install (or: sudo make install)~/pp~ This will install the Ogre libraries to /usr/local
Essentially, building with CMake is very similar to a traditional autoconf build. CMake simply takes the role of ./configure! In order to learn how to change build settings, please refer to ((Getting Started With CMake)) and ((Building Ogre With CMake)).
---(Mac OS X)--------------------------
!!!Installing Dependencies
''Option 1:'' Extract the [http://www.ogre3d.org/forums/viewtopic.php?f=1&t=54533 dependencies] into your ogre source root
''Option 2:'' Install Ogre dependencies system-wide via [http://www.macports.org/install.php MacPorts]. Be forewarned if you intend to distribute binaries, your users will have to do this as well! However for distributed development teams, this may be easier to manage for individual developers.
{CODE(wrap="1", colors="bash")} sudo port install libpng jpeg libxml2 +universal
sudo port install freetype freeimage +universal
sudo port install pkgconfig xmlto autoconf automake libtool +no_x11
sudo port install libzzip boost +universal
sudo port install cmake{CODE}
* Ogre3D requires a 32 bit build due to use of Carbon interfaces via OIS. Thus the +universal specifications to ensure 32 and 64 bit builds for libraries.
* You need the first line even if you already have libpng/jpeg/xml2 installed because they will be re-installed within the package system and we need to ensure universal build.
* The third line is the runtime dependencies of libzzip, they do not need to be universal, but use +no_x11 to avoid unnecessary additional packages
Finally, from the terminal:
{CODE(wrap="1", colors="bash")} touch ~/.bash_profile
open -a TextEdit ~/.bash_profile{CODE}
If it is not already present, add:
{CODE(wrap="1", colors="bash")}export CPPFLAGS="-I/opt/local/include"
export LDFLAGS="-L/opt/local/lib"{CODE}
Finally, you need to install [http://developer.nvidia.com/object/cg_download.html|Cg] and [http://sourceforge.net/projects/wgois/|OIS].
!!!Building Ogre (CMake GUI)
# [http://www.cmake.org/cmake/resources/software.html|Download CMake]. You want the 'Mac OS X Universal' release in the binary distribution section
# The .dmg will probably auto-mount when it downloads, if not, double-click it to open
# Double-click the .pkg installer, install on your main drive and opt to install the command-line tools too (in case you want to use them later, we will use the GUI here)
# Launch CMake via Applications
# In the "Where is the source code" box, type or browse to the root directory of your OGRE source (the one that contains the OgreMain folder)
# In the "Where to build the binaries" box, type or browse to any folder you like - this will be where the build output will go (libraries, headers, dlls & sample exes). The folder does not have to exist yet. Note that you can run this process more than once with different output folders if you want (but we won't complicate matters now)
# Hit the 'Configure' button near the bottom of the screen
# Pick 'Xcode' as the generator and opt to use native compilers
# Answer 'Ok' when asked if you want to create the build directory
# Wait for the configure process to finish
# The screen will now have a bunch of configuration options on it, which will be red (this is to indicate this is the first time you've seen them). You can see the potential for customising your build here, but for now just click the 'Configure' button again
# The values will turn grey, and the 'Generate' button at the bottom will now be enabled. Click 'Generate'
# Build files will now be generated in the location you picked
# Now, open OGRE.xcodeproj in the build directory you picked, open it in Xcode. ALL_BUILD will build everything!
!!!Building Ogre (Command Line)
{CODE(wrap="1", colors="bash")} mkdir ogrebuild
cd ogrebuild
cmake -GXcode ../path/to/ogre_src
xcodebuild{CODE}
You may wish to pass {MONO()}-configuration RelWithDebInfo{MONO} to xcodebuild to build with optimization.
!!!Installing Ogre
You will find Ogre.framework in 'lib' within your build directory. You can embed this in your application bundle, or drag it to /Library/Frameworks for system-wide installation.
You will also find plugins (Plugin_*.dylib and RenderSystem_GL.dylib) in the same location, you can copy these to the framework's Resource directory or your own application's bundle. Be sure to configure you applications' plugins.cfg to match (e.g. /Library/Frameworks/Ogre.framework/Resources/)
---(iPhone)--------------------------
Detailed instructions on building OGRE for iPhone can be found on this page [Building From Source (for iPhone)]
{VERSIONS}