Skip to content

Compiling GAALOP Precompiler

Oshgnacknak edited this page Jun 2, 2022 · 1 revision

Prerequisites

Getting the source

Use shell command git clone -b gaalop_precompiler https://github.com/CallForSanity/Gaalop.git or your git client GUI to fetch the sources. Alternatively, you can also download sources manually as archive from GAALOP repository.

Make sure to be on the branch gaalop_precompiler!

Compilation of GAALOP precompiler lib

Open CMake GUI and choose the checkout branch as source directory. Define a build directory and press Configure. After selection of the preferred C/C++ compiler, Configuring is done. The default values are valid, but the CMAKE_INSTALL_PREFIX variable can be changed to a non-system directory (e.g. directory in user's home space), so that no administrator privileges are required to install the library. Keep the selected directory in mind, it is required on each GAALOP Precompiler project in future.

Press Generate button and navigate to the build directory. Now you can build your solution (how to build depends on your build chain. For makefiles, go to the shell and type make).

IMPORTANT NOTE: Currently, after first successful make of project, display the CMake GUI again and press again Configure and then Generate. This is required to collect all GAALOP jars and will be fixed in future. Again, run make again in the build directory.

Navigate to build directory again and install the package (using make, you can use the shell command make install). After installation, the GAALOP precompiler library is located in the directory which was selected in CMAKE_INSTALL_PREFIX variable. This directory is also available as precompiled binaries on GAALOP Website.

Using GAALOP precompiler

To use GAALOP precompiler in your CMake-based C/C++ project, add the files FindGPC.cmake and run_gpc.bat.in (Windows) or run_gpc.sh.in (Linux) into source directory of your project. Both files can be found in the pre-/compiled GPC library in the directory share/cmake-2.8/Modules/ and must be copied to the source directory of your project.

Add the following lines in CMakeLists.txt (example project horizon with a file horizon.cpg):

  • PROJECT(horizon)
  • FIND_PACKAGE(GPC)
  • GPC_CXX_ADD_EXECUTABLE(horizon "horizon.cpg")

As an example, download and see the Example Code from the GPC_Manual.

Now you should open CMake GUI again and select your project as source directory (if not already done) and select a build destination directory. Press Configure and select the build chain to be used.

Set the variable GPC_ROOT_DIR to the root path of the directory of the pre-/compiled GAALOP Precompiler library and press Configure button again. Now the red warning lines should disappear and the variables

  • GPC_BASE_LIBRARY
  • GPC_INCLUDE_DIR
  • GPC_JAR

should be subdirectories of the GAALOP Precompiler library root path.

You can now adjust variables, which are used on the invocation of GAALOP when compiling your project:

  • GPC_ALGEBRA_NAME: Name of the used geometric algebra (default: cga)

  • GPC_ALGEBRA_BASEDIRECTORY: The base directory of your individual geometric algebras (default: '')

  • GPC_USE_DOUBLE: Use double precision of floating-point numbers (default is single precision)

  • GPC_USE_GAPP: Activate the usage of the GAPP Optimization stage, which enables GAPP Code generation

  • GPC_WITH_MAXIMA: Selecting this option enables Maxima. Press Configure again and tell CMake, where to find the maxima executable by using the variable MAXIMA_BIN.

Click Generate and navigate to build directory. You can now build your solution (how to build depends on your build chain. For makefiles, go to the shell and type make). The GAALOP compiler is invoked and the executable is created.

Note (for people new to CMake): For source changes in source directory, simply build project again, you don't have to configure with CMake again. Exception: If you change the CMakeLists.txt, then you might want to first Configure and Generate again and then build your project.

Further documents

GPC-Manual.pdf