1. Christian Fischer
  2. wiesel

Wiki

Clone wiki

wiesel / ProjectSetup

At the current development stage, the HelloWiesel demo project included in the repository would be a good starting point.

After you have cloned the repository to your local disk, just take the sample project from samples/HelloWiesel and copy it to a custom location on your hard disk.

Now you have to customize a few files before you can build your project.

Desktop Build

project/CMakeLists.txt

# ensure a correct version of cmake is installed
cmake_minimum_required(VERSION 2.8)

# compatibility
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required


# set the project name
project(HelloWiesel)


# in this case, the engine folder is in the same repository,
# so we always know the correct location.
# when the engine location is different on various build environments,
# you may put the definition of WIESEL_DIR into a separate file under 
# config/local, where it is not committed into version control.
set(WIESEL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)

# include the main build file of the engine
include(${WIESEL_DIR}/build/build.cmake)


# Here we create the executable for our project.
# Tell the build script the name of the executable and the location of your sources.
wiesel_create_executable(HelloWiesel ./src)


# add required libraries
wiesel_module_add_dependency(HelloWiesel wiesel-base)
wiesel_module_add_dependency(HelloWiesel wiesel-common)

wiesel_target_add_compileflags(HelloWiesel "-DWIESEL_USE_LIBSDL")
  • Alter the name of your project at project(...) to change the project's.
  • It's also recommended to change the name of your executable at wiesel_create_executable(...) and the location of your sources, when they're different.
  • WIESEL_DIR is required to tell the build script where to find the library. This can be either an absolute or relative path to the repository.

When building on windows, you would need to add some extra library paths to project/config/local/paths.cmake, see SetupBuildEnvironmentWindowsCygwin

Prepare the CMake build scripts

At first you should create a new, empty directory somewhere in your workspace, for example project/build. Enter the directory and run cmake to create the build scripts:

cmake PATH/TO/YOUR/PROJECT

When getting an error like:

  sh.exe was found in your PATH, here:
  C:/MinGW/msys/1.0/bin/sh.exe

  For MinGW make to work correctly sh.exe must NOT be in your path.
  Run cmake from a shell that does not have sh.exe in your PATH.
  If you want to use a UNIX shell, then use MSYS Makefiles.

you can remove the MSYS path from your PATH environment variable, or when you're within the MSYS shell, you can run cmake with an command like this:

  PATH=.:/usr/local/bin:/mingw/bin:/PATH/TO/CMAKE/bin cmake -G "MinGW Makefiles" PATH/TO/YOUR/PROJECT

You also may use the GUI version of cmake and configure the compiler to use manually.

Now try to start the build with make and check, if the unit tests pass properly:

make
make test

IDE support

CMake already supports various IDEs.

IDE Projects can be created in the same way as the makefiles above with an additional argument to specify the generator to be used for creating project files. Please refer to the CMake help (cmake --help) to see which generators are supported on your platform.

For example, to create a project setup for Eclipse, using MinGW, try this:

mkdir eclipse_project
cd eclipse_project
cmake -G "Eclipse CDT4 - MinGW Makefiles" PATH/TO/YOUR/PROJECT

CMake also supports other popular IDEs like CodeBlocks or VisualStudio.

Android

I guess, you already have installed the Android SDK and NDK.

Now add the following file to your project:

project/android/local.properties

# Path to your android NDK and SDK
sdk.dir=path/to/sdk
ndk.dir=path/to/ndk

# path to the wiesel repository, either absolute or relative to the project's android directory (NOT the project's root directory)
wiesel.dir=path/to/wiesel

Additionally you would customize project/android/AndroidManifest.xml to customize your project's name and package-id.

Updated