-
Notifications
You must be signed in to change notification settings - Fork 32
UsingCMakeExternally
philthiel edited this page Apr 11, 2017
·
7 revisions
BALL uses the CMake build system and creates required project configuration files. Thus, you can a BALL in other CMake based projects. An example is shown here, which creates an executable example from example.cpp and links against BALL.
- Create a CMakeLists.txt project file in the location where your source file(s) are located with the following content:
#The name of the project to build
PROJECT(BALL_EXAMPLE)
# We currently require at least version 3.1 of CMake
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
# The path to the BALLConfig.cmake file. Usually located
# in the build directory of your BALL installation
SET(BALL_DIR "/path/to/BALL/build/cmake")
# Make cmake read the BALL configuration files
FIND_PACKAGE(BALL REQUIRED)
# Add required BALL include directories
INCLUDE_DIRECTORIES(${BALL_INCLUDE_DIRS})
# Add required BALL compiler flags and definitions
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BALL_CXX_FLAGS}")
ADD_DEFINITIONS("${BALL_COMPILE_DEFINITIONS}")
# Tell cmake to generate an executable called example that depends
# on the file example.cpp
ADD_EXECUTABLE(example example.cpp)
# Link example against BALL
TARGET_LINK_LIBRARIES(example BALL)
- Create a directory named build
- Change to this directory
- Configure the project (if you use the ball_contrib package you have to specify the path to its installation directory):
$ cmake .. -DCMAKE_PREFIX_PATH=<ball_contrib_build_dir>/install
- Build the project
$ make
You are done ;-)