trippy-cube/CMakeLists.txt

80 lines
2.4 KiB
CMake

# Copyright (C) 2018 Ortega Froysa, Nicolás <nortega@themusicinnoise.net> All rights reserved.
# Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
#
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
#
# 3. This notice may not be removed or altered from any source
# distribution.
cmake_minimum_required(VERSION 2.8)
project(TrippyCube C CXX)
# Binary filename
set(TARGET_NAME "trippy-cube")
set(TARGET_VERSION "v2.1")
# Use DEBUG by default
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "release")
endif()
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
# prefer newer versions of OpenGL
set(OpenGL_GL_PREFERENCE "GLVND")
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
find_package(GLEW REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_search_module(SDL2 REQUIRED sdl2)
include_directories(
${SDL2_INCLUDE_DIRS})
set(SRCS
"src/camera.cpp"
"src/cube.cpp"
"src/input.cpp"
"src/main.cpp"
"src/shaders.cpp"
"src/simulation.cpp")
# Define C++ compiler flags
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wpedantic -Wfatal-errors -Werror -pedantic-errors -fno-elide-constructors")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
if(CMAKE_BUILD_TYPE STREQUAL "debug" OR CMAKE_BUILD_TYPE STREQUAL "relwithdebinfo")
add_definitions("-DDEBUG")
else()
add_definitions("-DNDEBUG")
endif()
add_definitions("-DVERSION=\"${TARGET_VERSION}\"")
add_executable(${TARGET_NAME}
${SRCS})
target_link_libraries(${TARGET_NAME}
OpenGL::OpenGL
OpenGL::GLU
${GLUT_LIBRARIES}
${GLEW_LIBRARIES}
${SDL2_LIBRARIES})