gnidmoo

Untitled

May 21st, 2015
249
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #------------------------------------------------------------------------------
  2. # CMakeLists.txt
  3. # By gnidmoo <gnidmoo@gmail.com>
  4. #------------------------------------------------------------------------------
  5. cmake_minimum_required(VERSION 2.8)
  6.  
  7. project(ZeldaOOL)
  8.  
  9. #------------------------------------------------------------------------------
  10. # Get source files
  11. #------------------------------------------------------------------------------
  12. file(GLOB_RECURSE SOURCE_FILES source/*/*.cpp external/*.cpp)
  13. file(GLOB_RECURSE HEADER_FILES include/*.hpp external/*.hpp)
  14.  
  15. foreach(HEADER_FILE ${HEADER_FILES})
  16.     get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY)
  17.     include_directories(${HEADER_DIRECTORY})
  18. endforeach(HEADER_FILE)
  19.  
  20. #------------------------------------------------------------------------------
  21. # Unit testing
  22. #------------------------------------------------------------------------------
  23. find_package(CxxTest QUIET)
  24.  
  25. if(CXXTEST_FOUND)
  26.     include_directories(${CXXTEST_INCLUDE_DIRS})
  27.     enable_testing()
  28.    
  29.     file(GLOB_RECURSE TEST_FILES tests/*.hpp)
  30.    
  31.     CXXTEST_ADD_TEST(${CMAKE_PROJECT_NAME}_tests tests/unit-test.cpp ${TEST_FILES})
  32. else(CXXTEST_FOUND)
  33.     message(WARNING "CxxTest not found!")
  34. endif(CXXTEST_FOUND)
  35.  
  36. #------------------------------------------------------------------------------
  37. # Add executables
  38. #------------------------------------------------------------------------------
  39. add_library(${CMAKE_PROJECT_NAME}_lib STATIC
  40.             ${SOURCE_FILES})
  41.  
  42. add_executable(${CMAKE_PROJECT_NAME}
  43.                source/main.cpp)
  44.  
  45. #------------------------------------------------------------------------------
  46. # Compiler flags
  47. #------------------------------------------------------------------------------
  48. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++11")
  49. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wfatal-errors -pedantic")
  50. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros")
  51. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
  52.  
  53. #------------------------------------------------------------------------------
  54. # Packages
  55. #------------------------------------------------------------------------------
  56. # - OpenGL
  57. #------------------------------------------------------------------------------
  58. find_package(OpenGL REQUIRED)
  59. # find_package(GLM REQUIRED)
  60.  
  61. if(NOT OPENGL_FOUND)
  62.     message(FATAL_ERROR "OpenGL not found!")
  63. endif(NOT OPENGL_FOUND)
  64.  
  65. # if(NOT GLM_FOUND)
  66. #   message(FATAL_ERROR "glm not found!")
  67. # endif(NOT GLM_FOUND)
  68. #
  69. # include_directories(${GLM_INCLUDE_DIRS})
  70.  
  71. #------------------------------------------------------------------------------
  72. # - SDL2, SDL2_image, SDL2_mixer
  73. #------------------------------------------------------------------------------
  74. include(FindPkgConfig)
  75.  
  76. pkg_search_module(SDL2 REQUIRED sdl2)
  77. pkg_search_module(SDL2IMAGE REQUIRED SDL2_image)
  78. pkg_search_module(SDL2MIXER REQUIRED SDL2_mixer)
  79.  
  80. if(NOT SDL2_FOUND)
  81.     message(FATAL_ERROR "SDL2 not found!")
  82. endif(NOT SDL2_FOUND)
  83.  
  84. if(NOT SDL2IMAGE_FOUND)
  85.     message(FATAL_ERROR "SDL2_image not found!")
  86. endif(NOT SDL2IMAGE_FOUND)
  87.  
  88. if(NOT SDL2MIXER_FOUND)
  89.     message(FATAL_ERROR "SDL2_mixer not found!")
  90. endif(NOT SDL2MIXER_FOUND)
  91.  
  92. include_directories(${SDL2_INCLUDE_DIRS}
  93.                     ${SDL2IMAGE_INCLUDE_DIRS}
  94.                     ${SDL2MIXER_INCLUDE_DIRS})
  95.  
  96. #------------------------------------------------------------------------------
  97. # Link options
  98. #------------------------------------------------------------------------------
  99. if(CXXTEST_FOUND)
  100.     target_link_libraries(${CMAKE_PROJECT_NAME}_tests
  101.                           ${CMAKE_PROJECT_NAME}_lib
  102.                           ${OPENGL_LIBRARIES}
  103.                           ${SDL2_LIBRARIES}
  104.                           ${SDL2IMAGE_LIBRARIES}
  105.                           ${SDL2MIXER_LIBRARIES})
  106. endif(CXXTEST_FOUND)
  107.  
  108. target_link_libraries(${CMAKE_PROJECT_NAME}
  109.                       ${CMAKE_PROJECT_NAME}_lib
  110.                       ${OPENGL_LIBRARIES}
  111.                       ${SDL2_LIBRARIES}
  112.                       ${SDL2IMAGE_LIBRARIES}
  113.                       ${SDL2MIXER_LIBRARIES})
RAW Paste Data