CMake Build

From K-3D

(Redirected from Generic Build)
Jump to: navigation, search

Build Overview

  • K-3D version: 0.7.
  • Build environment: cmake + gcc.
  • Runtime environment: All K-3D platforms (see Windows Build for Win32-specific instructions).
  • Pros
    • Preferred environment for most K-3D developers.
    • Preferred method of building K-3D, since it uses a 100% FOSS toolchain.
    • Native OpenGL performance.
    • Stable.
  • Cons
    • None.
  • Known Issues
    • None.
  • Requirements
    • CMake 2.6.3 (you may use 2.4, but some modules need 2.6.3)
    • gcc 3.4 or later (mingw on Win32)
    • boost
    • Disk space: 1.1Gb (for debug binaries)

Check External Dependencies for more details

Install CMake

You will need CMake http://www.cmake.org, a cross-platform free software tool for generating builds. Install CMake 2.4.5 or later.

Download Sources

Obtain the K-3D sources, from either Subversion or K-3D Downloads.

Initial Build Instructions

In a break from the past, K-3D now requires an out-of-source build. So assuming that you've downloaded the K-3D sources to ~/k3d, you will need to create a separate directory where the binaries will be created:

$ mkdir k3d-build

Now, you can cd into the build directory and run the curses version of cmake, giving it the path to the source tree:

$ cd k3d-build
$ ccmake ~/k3d

Follow the on-screen instructions to configure the build. When you hit 'c', cmake will examine your system, detect external libraries, and prompt you for needed information (it could be possible that you need to hit 'c' a second time before generate). Hit the 't' key to toggle visibility of advanced options. If you have external libraries in non-standard locations, you may have to manually edit the options, supplying the paths to library header files or binaries. Once all options have been set, hit 'g' to generate the K-3D makefiles.

Now, you may start the build:

$ make
TIP:If you have a multicore cpu you can add the -jN option to build using N cores. (-j2 in case of two cores, -j4 in case of 4, etc).

Once the program is built, you can run it out of the build directory:

$ make run
TIP:You can add "/fast" to any of these targets to skip dependency checking - for example, a useful time-saver is
$ make run/fast

If you need to troubleshoot problems use

$ make run-gdb/fast

... to run K-3D using the gdb debugger.

To install everything to its final destination:

$ make install
TIP: In case you get library errors after installing (usually running /usr/local/bin/k3d) you should add your /usr/local/lib path to the shared libraries path.
create or edit /etc/ld.so.conf.d/local.conf and add the /usr/local/lib path to it. Then run ldconfig with root privileges.

You should also check the other build targets in the CMake Targets article.

Subsequent Builds

Whenever you update your source tree from Subversion you should re-run cmake to ensure that your build is completely up-to-date. To do this, cd into your build directory and re-run cmake:

$ cd k3d-build
$ make edit_cache

From this point you can configure, deal with any new options that have been introduced in the source tree, and generate your new makefiles. cmake retains your old options, so you won't have to recreate any previous selections.