SHARE
TWEET

CMakeOgre

a guest Apr 28th, 2016 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #/*
  2. #-----------------------------------------------------------------------------
  3. #Filename:    CMakeLists.txt
  4. #-----------------------------------------------------------------------------
  5. #
  6. #This source file is part of the
  7. #   ___                 __    __ _ _    _
  8. #  /___\__ _ _ __ ___  / / /\ \ (_) | _(_)
  9. # //  // _` | '__/ _ \ \ \/  \/ / | |/ / |
  10. #/ \_// (_| | | |  __/  \  /\  /| |   <| |
  11. #\___/ \__, |_|  \___|   \/  \/ |_|_|\_\_|
  12. #      |___/
  13. #      Tutorial Framework
  14. #      http://www.ogre3d.org/tikiwiki/
  15. #-----------------------------------------------------------------------------
  16. #*/
  17. cmake_minimum_required(VERSION 2.6)
  18.  
  19. project(bomberman)
  20.  
  21. if(WIN32)
  22.     set(CMAKE_MODULE_PATH "$ENV{OGRE_HOME}/CMake/;${CMAKE_MODULE_PATH}")
  23.     set(OGRE_SAMPLES_INCLUDEPATH
  24.         $ENV{OGRE_HOME}/Samples/include
  25.     )
  26. endif(WIN32)
  27.  
  28. if(UNIX)
  29.     if(EXISTS "/usr/local/lib/OGRE/cmake")
  30.  
  31.       set(CMAKE_MODULE_PATH "/usr/local/lib/OGRE/cmake/;${CMAKE_MODULE_PATH}")
  32.       set(OGRE_SAMPLES_INCLUDEPATH "/usr/local/share/OGRE/samples/Common/include/") # We could just *assume* that developers uses this basepath : /usr/local
  33.  
  34.     elseif(EXISTS "/usr/lib/OGRE/cmake")
  35.  
  36.       set(CMAKE_MODULE_PATH "/usr/lib/OGRE/cmake/;${CMAKE_MODULE_PATH}")
  37.       set(OGRE_SAMPLES_INCLUDEPATH "/usr/share/OGRE/samples/Common/include/") # Otherwise, this one
  38.  
  39.     else ()
  40.       message(SEND_ERROR "Failed to find module path.")
  41.     endif()
  42. endif(UNIX)
  43.  
  44. if (CMAKE_BUILD_TYPE STREQUAL "")
  45.   # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up
  46.   # differentiation between debug and release builds.
  47.   set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
  48. endif ()
  49.  
  50. set(CMAKE_DEBUG_POSTFIX "_d")
  51.  
  52. set(CMAKE_CXX_FLAGS "-std=c++11 -Wall")
  53.  
  54. set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/dist")
  55.  
  56. find_package(OGRE REQUIRED)
  57.  
  58. #if(NOT "${OGRE_VERSION_NAME}" STREQUAL "Cthugha")
  59. #  message(SEND_ERROR "You need Ogre 1.7 Cthugha to build this.")
  60. #endif()
  61.  
  62. find_package(OIS REQUIRED)
  63.  
  64. if(NOT OIS_FOUND)
  65.     message(SEND_ERROR "Failed to find OIS.")
  66. endif()
  67.  
  68. # Find Boost
  69. if (NOT OGRE_BUILD_PLATFORM_IPHONE)
  70.     if (WIN32 OR APPLE)
  71.         set(Boost_USE_STATIC_LIBS TRUE)
  72.     else ()
  73.         # Statically linking boost to a dynamic Ogre build doesn't work on Linux 64bit
  74.         set(Boost_USE_STATIC_LIBS ${OGRE_STATIC})
  75.     endif ()
  76.     if (MINGW)
  77.         # this is probably a bug in CMake: the boost find module tries to look for
  78.         # boost libraries with name libboost_*, but CMake already prefixes library
  79.         # search names with "lib". This is the workaround.
  80.         set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "")
  81.     endif ()
  82.     set(Boost_ADDITIONAL_VERSIONS "1.44" "1.44.0" "1.42" "1.42.0" "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" )
  83.     # Components that need linking (NB does not include header-only components like bind)
  84.     set(OGRE_BOOST_COMPONENTS thread date_time)
  85.  
  86.     find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET)
  87.     if (NOT Boost_FOUND)
  88.         # Try again with the other type of libs
  89.         set(Boost_USE_STATIC_LIBS NOT ${Boost_USE_STATIC_LIBS})
  90.         find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET)
  91.     endif()
  92.     find_package(Boost QUIET)
  93.  
  94.     # Set up referencing of Boost
  95.     include_directories(${Boost_INCLUDE_DIR})
  96.     add_definitions(-DBOOST_ALL_NO_LIB)
  97.     set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES})
  98. endif()
  99.  
  100. set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/;${CMAKE_MODULE_PATH}")
  101. find_package(CEGUI REQUIRED OGRE)
  102.  
  103.  if(NOT CEGUI_FOUND)
  104.    message(SEND_ERROR "Failed to find CEGUI.")
  105.  endif()
  106.  
  107. set(HDRS
  108. )
  109.  
  110. set(SRCS
  111.     ./src/main.cpp
  112.   ./src/Menu.cpp
  113.   ./src/InputListener.cpp
  114. )
  115.  
  116. set(INCLUDE_DIRECTORY
  117.   ./include
  118. )
  119.  
  120. include_directories( ${OIS_INCLUDE_DIRS}
  121.     ${OGRE_INCLUDE_DIRS}
  122.     ${OGRE_SAMPLES_INCLUDEPATH}
  123.     ${OGRE_Overlay_INCLUDE_DIRS}
  124.     ${CEGUI_INCLUDE_DIRS}
  125.     ${INCLUDE_DIRECTORY}
  126. )
  127.  
  128. add_executable(OgreApp WIN32 ${HDRS} ${SRCS})
  129.  
  130. set_target_properties(OgreApp PROPERTIES DEBUG_POSTFIX _d)
  131.  
  132. target_link_libraries(OgreApp ${OGRE_LIBRARIES} ${OIS_LIBRARIES} ${OGRE_Overlay_LIBRARIES} ${CEGUI_LIBRARIES})
  133.  
  134. file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dist/bin)
  135. file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dist/media)
  136.  
  137. # post-build copy for win32
  138. if(WIN32 AND NOT MINGW)
  139.     add_custom_command( TARGET OgreApp PRE_BUILD
  140.         COMMAND if not exist .\\dist\\bin mkdir .\\dist\\bin )
  141.     add_custom_command( TARGET OgreApp POST_BUILD
  142.         COMMAND copy \"$(TargetPath)\" .\\dist\\bin )
  143. endif(WIN32 AND NOT MINGW)
  144.  
  145. if(MINGW OR UNIX)
  146.     set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/dist/bin)
  147. endif(MINGW OR UNIX)
  148.  
  149. if(WIN32)
  150.  
  151.     install(TARGETS OgreApp
  152.         RUNTIME DESTINATION bin
  153.         CONFIGURATIONS All)
  154.  
  155.     install(DIRECTORY ${CMAKE_SOURCE_DIR}/dist/Media
  156.         DESTINATION ./
  157.         CONFIGURATIONS Release RelWithDebInfo Debug
  158.     )
  159.  
  160.     install(FILES ${CMAKE_SOURCE_DIR}/dist/bin/plugins.cfg
  161.         ${CMAKE_SOURCE_DIR}/dist/bin/resources.cfg
  162.         DESTINATION bin
  163.         CONFIGURATIONS Release RelWithDebInfo
  164.     )
  165.  
  166.     install(FILES ${CMAKE_SOURCE_DIR}/dist/bin/plugins_d.cfg
  167.         ${CMAKE_SOURCE_DIR}/dist/bin/resources_d.cfg
  168.         DESTINATION bin
  169.         CONFIGURATIONS Debug
  170.     )
  171.  
  172.         # NOTE: for the 1.7.1 sdk the OIS dll is called OIS.dll instead of libOIS.dll
  173.         # so you'll have to change that to make it work with 1.7.1
  174.     install(FILES ${OGRE_PLUGIN_DIR_REL}/OgreMain.dll
  175.         ${OGRE_PLUGIN_DIR_REL}/RenderSystem_Direct3D9.dll
  176.         ${OGRE_PLUGIN_DIR_REL}/RenderSystem_GL.dll
  177.         ${OGRE_PLUGIN_DIR_REL}/libOIS.dll
  178.         DESTINATION bin
  179.         CONFIGURATIONS Release RelWithDebInfo
  180.     )
  181.  
  182.     install(FILES ${OGRE_PLUGIN_DIR_DBG}/OgreMain_d.dll
  183.         ${OGRE_PLUGIN_DIR_DBG}/RenderSystem_Direct3D9_d.dll
  184.         ${OGRE_PLUGIN_DIR_DBG}/RenderSystem_GL_d.dll
  185.         ${OGRE_PLUGIN_DIR_DBG}/libOIS_d.dll
  186.         DESTINATION bin
  187.         CONFIGURATIONS Debug
  188.     )
  189.  
  190.    # as of sdk 1.7.2 we need to copy the boost dll's as well
  191.    # because they're not linked statically (it worked with 1.7.1 though)
  192.    install(FILES ${Boost_DATE_TIME_LIBRARY_RELEASE}
  193.       ${Boost_THREAD_LIBRARY_RELEASE}
  194.       DESTINATION bin
  195.       CONFIGURATIONS Release RelWithDebInfo
  196.    )
  197.  
  198.    install(FILES ${Boost_DATE_TIME_LIBRARY_DEBUG}
  199.       ${Boost_THREAD_LIBRARY_DEBUG}
  200.       DESTINATION bin
  201.       CONFIGURATIONS Debug
  202.    )
  203. endif(WIN32)
  204.  
  205. if(UNIX)
  206.  
  207.     install(TARGETS OgreApp
  208.         RUNTIME DESTINATION bin
  209.         CONFIGURATIONS All)
  210.  
  211.     install(DIRECTORY ${CMAKE_SOURCE_DIR}/dist/media
  212.         DESTINATION ./
  213.         CONFIGURATIONS Release RelWithDebInfo Debug
  214.     )
  215.  
  216.     install(FILES ${CMAKE_SOURCE_DIR}/dist/bin/plugins.cfg
  217.         ${CMAKE_SOURCE_DIR}/dist/bin/resources.cfg
  218.         DESTINATION bin
  219.         CONFIGURATIONS Release RelWithDebInfo Debug
  220.     )
  221.  
  222. endif(UNIX)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top