-
Notifications
You must be signed in to change notification settings - Fork 1
Setup game project with Bubba3D using CMake
DunderRoffe edited this page Jun 20, 2016
·
11 revisions
- Git with support for submodules
Create a git-repository for the game.
mkdir awesome-bubba-game
cd awesome-bubba-game
git init
Import Bubba-3D into the repository.
git submodule add [email protected]:Bubbers/Bubba-3D
Specify the version of Bubba-3D you want to use (not necessary if you want the latest version from commit).
cd Bubba-3D
git checkout <desired commit/branch from the Bubba-3D repository>
make install
cd ..
Create the project structure.
mkdir src
touch src/main.cpp
echo "int main( int argc, char *argv[] ) { return 0; }" >> src/main.cpp
Create a CMakeLists.txt file for the game with the following.
cmake_minimum_required(VERSION 3.0)
PROJECT(<awesome-bubba-game>)
# Set flags
set(LIBRARY_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/build")
set(OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLEW_STATIC")
# Compile BUBBA-3D
add_subdirectory(Bubba-3D)
# Files to compile
set(GAME_SOURCE_FILES src/main.cpp)
# Define the executable
set(EXECUTABLE_NAME AwesomeBubbaGame)
add_executable(${EXECUTABLE_NAME} ${GAME_SOURCE_FILES})
# Link in BUBBA-3D in the executable
target_link_libraries(${EXECUTABLE_NAME} LINK_PUBLIC Bubba3D)
Keep in mind that this is a rather simple cmake setup that works only because the awesome bubba game project is quite small at the moment. It is advised to have a cmake file in each directory in the src folder which adds the cpp files in that directory to GAME_SOURCE_FILES. Otherwise, the cmake file will get quite messy as the project grows.
Make the setup commit.
git add CMakeLists.txt src
git commit -m "Setup of my totally awesome Bubba-3D game!"