CMakeLists.txt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Copyright (C) 2018 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
  2. # Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. cmake_minimum_required(VERSION 2.8)
  17. project(TTT3D CXX)
  18. # Binary filename
  19. set(TARGET_NAME "ttt3d")
  20. set(TARGET_VERSION "v1.0")
  21. # Use DEBUG by default
  22. if(NOT CMAKE_BUILD_TYPE)
  23. set(CMAKE_BUILD_TYPE "release")
  24. endif()
  25. string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
  26. message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
  27. # prefer newer versions of OpenGL
  28. set(OpenGL_GL_PREFERENCE "GLVND")
  29. find_package(OpenGL REQUIRED)
  30. find_package(GLEW REQUIRED)
  31. find_package(GLUT REQUIRED)
  32. find_package(PkgConfig REQUIRED)
  33. pkg_search_module(ASSIMP REQUIRED assimp)
  34. pkg_search_module(SDL2 REQUIRED sdl2)
  35. include_directories(
  36. SYSTEM ${ASSIMP_INCLUDE_DIRS}
  37. SYSTEM ${SDL2_INCLUDE_DIRS})
  38. set(SRCS
  39. "src/AssetManager.cpp"
  40. "src/Camera.cpp"
  41. "src/Logger.cpp"
  42. "src/Main.cpp"
  43. "src/Model.cpp"
  44. "src/Shader.cpp"
  45. "src/System.cpp")
  46. # Define C++ compiler flags
  47. set(CMAKE_CXX_FLAGS "-std=c++14 -Wall -Wextra -Wpedantic -Wfatal-errors -Werror -pedantic-errors -fno-elide-constructors")
  48. set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
  49. set(CMAKE_CXX_FLAGS_RELEASE "-O3")
  50. set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3")
  51. set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
  52. if(CMAKE_BUILD_TYPE STREQUAL "debug" OR CMAKE_BUILD_TYPE STREQUAL "relwithdebinfo")
  53. add_definitions("-DDEBUG")
  54. else()
  55. add_definitions("-DNDEBUG")
  56. endif()
  57. add_definitions("-DVERSION=\"${TARGET_VERSION}\"")
  58. add_executable(${TARGET_NAME}
  59. ${SRCS})
  60. target_link_libraries(${TARGET_NAME}
  61. OpenGL::OpenGL
  62. OpenGL::GLU
  63. ${ASSIMP_LIBRARIES}
  64. ${GLEW_LIBRARIES}
  65. ${GLUT_LIBRARIES}
  66. ${SDL2_LIBRARIES})