CMakeLists.txt 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. cmake_minimum_required(VERSION 2.6)
  2. project(QGears)
  3. # The version number.
  4. set(QGears_VERSION_MAJOR 0)
  5. set(QGears_VERSION_MINOR 22)
  6. option(QGears_BUILD_PLUGINS "Build the plugins" TRUE)
  7. option(QGears_BUILD_UTILITIES "Build the utilities" TRUE)
  8. option(QGears_BUILD_TESTS "Build the unit tests" TRUE)
  9. option(QGears_MULTITHREADING "Enable multithreading" FALSE)
  10. option(QGears_SOUND "Enable Sound" FALSE)
  11. find_path(OGRE_CMAKE_MODULE_PATH FindOGRE.cmake
  12. HINTS
  13. "$ENV{OGRE_HOME}/CMake/"
  14. "/usr/local/lib/OGRE/cmake"
  15. "/usr/lib/OGRE/cmake"
  16. "/usr/share/OGRE/cmake/modules"
  17. )
  18. if(OGRE_CMAKE_MODULE_PATH-NOTFOUND)
  19. message(SEND_ERROR "Failed to find OGRE module path.")
  20. else()
  21. set(CMAKE_MODULE_PATH "${OGRE_CMAKE_MODULE_PATH};${CMAKE_MODULE_PATH}")
  22. endif()
  23. set(CMAKE_MODULE_PATH "${OGRE_CMAKE_MODULE_PATH};${CMAKE_MODULE_PATH}")
  24. set(CMAKE_MODULE_PATH
  25. "${CMAKE_MODULE_PATH}"
  26. "${QGears_SOURCE_DIR}/CMake"
  27. )
  28. if (CMAKE_BUILD_TYPE STREQUAL "")
  29. # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up
  30. # differentiation between debug and release builds.
  31. set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
  32. endif ()
  33. set(CMAKE_DEBUG_POSTFIX "_d")
  34. if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  35. set(CMAKE_INSTALL_PREFIX
  36. "${QGears_SOURCE_DIR}/output" CACHE PATH "Q-Gears install prefix" FORCE
  37. )
  38. endif()
  39. find_package( ZLIB REQUIRED )
  40. find_package(OGRE REQUIRED)
  41. find_package(OIS REQUIRED)
  42. if(NOT OIS_FOUND)
  43. message(SEND_ERROR "Failed to find OIS.")
  44. endif()
  45. # Find Boost
  46. if (NOT OGRE_BUILD_PLATFORM_IPHONE)
  47. if (WIN32 OR APPLE)
  48. set(Boost_USE_STATIC_LIBS TRUE)
  49. else ()
  50. # Statically linking boost to a dynamic Ogre build doesn't work on Linux 64bit
  51. set(Boost_USE_STATIC_LIBS ${OGRE_STATIC})
  52. endif ()
  53. if (MINGW)
  54. # this is probably a bug in CMake: the boost find module tries to look for
  55. # boost libraries with name libboost_*, but CMake already prefixes library
  56. # search names with "lib". This is the workaround.
  57. set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "")
  58. endif ()
  59. set(Boost_ADDITIONAL_VERSIONS "1.53" "1.53.0" "1.52" "1.52.0" "1.51" "1.51.0" "1.50" "1.50.0" "1.49" "1.49.0" "1.48" "1.48.0" "1.47" "1.47.0" "1.46" "1.46.0" "1.45" "1.45.0" "1.44" "1.44.0" "1.42" "1.42.0" "1.41.0" "1.41" "1.40.0" "1.40")
  60. # Components that need linking (NB does not include header-only components like bind)
  61. set(OGRE_BOOST_COMPONENTS thread date_time)
  62. find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET)
  63. if (NOT Boost_FOUND)
  64. set(Boost_USE_STATIC_LIBS NOT ${Boost_USE_STATIC_LIBS})
  65. find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET)
  66. endif()
  67. if(Boost_FOUND AND Boost_VERSION GREATER 104900)
  68. set(OGRE_BOOST_COMPONENTS thread date_time system chrono)
  69. find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET)
  70. endif()
  71. # Set up referencing of Boost
  72. include_directories(${Boost_INCLUDE_DIR})
  73. add_definitions(-DBOOST_ALL_NO_LIB)
  74. set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES})
  75. find_package(Boost COMPONENTS program_options filesystem QUIET)
  76. set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES})
  77. set(QGears_LIBRARIES ${OGRE_LIBRARIES})
  78. if(QGears_SOUND)
  79. find_package(OpenAL REQUIRED)
  80. find_package(OggVorbis REQUIRED)
  81. add_definitions(-DQGears_SOUND)
  82. set(QGears_LIBRARIES
  83. ${QGears_LIBRARIES}
  84. ${OPENAL_LIBRARY}
  85. ${OGGVORBIS_LIBRARIES}
  86. )
  87. endif()
  88. if(QGears_MULTITHREADING)
  89. # Find Threads
  90. find_package (Threads REQUIRED)
  91. set(QGears_LIBRARIES
  92. ${QGears_LIBRARIES}
  93. ${CMAKE_THREAD_LIBS_INIT}
  94. )
  95. endif()
  96. if(QGears_BUILD_TESTS)
  97. find_package(Boost COMPONENTS unit_test_framework QUIET)
  98. set(QGears_TEST_LIBRARIES
  99. ${OGRE_LIBRARIES}
  100. ${Boost_LIBRARIES}
  101. )
  102. # enable CTest
  103. enable_testing()
  104. endif()
  105. endif()
  106. set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_Overlay_LIBRARIES})
  107. find_package(Boost COMPONENTS unit_test_framework REQUIRED)
  108. if (Boost_LIBRARIES STREQUAL "")
  109. message(SEND_ERROR "Boost_LIBRARIES is not set")
  110. endif()
  111. set(QGears_INCLUDE_DIRS
  112. ${OIS_INCLUDE_DIRS}
  113. ${OGRE_INCLUDE_DIRS}
  114. ${OGRE_Overlay_INCLUDE_DIRS}
  115. ${OGRE_SAMPLES_INCLUDEPATH}
  116. ${CMAKE_CURRENT_SOURCE_DIR}/dependencies
  117. )
  118. # Enable C++11, you may need to use -std=c++0x if using an older compiler
  119. if (MSVC)
  120. else()
  121. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
  122. endif()
  123. add_definitions(-DTIXML_USE_STL)
  124. add_subdirectory(dependencies)
  125. add_subdirectory(QGearsMain)
  126. add_subdirectory(SupportedGames)
  127. if(QGears_BUILD_PLUGINS)
  128. add_subdirectory(PlugIns)
  129. endif()
  130. if(QGears_BUILD_UTILITIES)
  131. add_subdirectory(utilities)
  132. endif()
  133. if(QGears_BUILD_TESTS)
  134. add_subdirectory(Tests)
  135. endif()