CMakeLists.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. cmake_minimum_required(VERSION 2.6)
  2. if(${CMAKE_VERSION} STREQUAL "2.8.2")
  3. # bug http://vtk.org/Bug/view.php?id=11020
  4. message( WARNING "CMake/CPack version 2.8.2 will not create working .deb packages!")
  5. endif(${CMAKE_VERSION} STREQUAL "2.8.2")
  6. # This can be read from ${PROJECT_NAME} after project() is called
  7. project(minetest)
  8. set(VERSION_MAJOR 0)
  9. set(VERSION_MINOR 2)
  10. set(VERSION_PATCH 20110922_1)
  11. set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
  12. # Configuration options
  13. if(WIN32)
  14. set(RUN_IN_PLACE 1 CACHE BOOL "Run directly in source directory structure")
  15. else()
  16. set(RUN_IN_PLACE 0 CACHE BOOL "Run directly in source directory structure")
  17. endif()
  18. set(BUILD_CLIENT 1 CACHE BOOL "Build client")
  19. if(WIN32)
  20. set(BUILD_SERVER 0 CACHE BOOL "Build server")
  21. else()
  22. set(BUILD_SERVER 1 CACHE BOOL "Build server")
  23. endif()
  24. set(WARN_ALL 1 CACHE BOOL "Enable -Wall for Release build")
  25. if(NOT CMAKE_BUILD_TYPE)
  26. # Default to release
  27. set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
  28. endif()
  29. # Included stuff
  30. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
  31. include(${CMAKE_SOURCE_DIR}/cmake/Modules/misc.cmake)
  32. # This is done here so that relative search paths are more reasnable
  33. find_package(Irrlicht)
  34. #
  35. # Installation
  36. #
  37. if(WIN32)
  38. set(DATADIR "data")
  39. set(BINDIR "bin")
  40. set(DOCDIR "doc")
  41. set(EXAMPLE_CONF_DIR ".")
  42. elseif(APPLE)
  43. # random placeholders
  44. set(DATADIR "share/${PROJECT_NAME}")
  45. set(BINDIR "bin")
  46. set(DOCDIR "share/doc/${PROJECT_NAME}")
  47. set(EXAMPLE_CONF_DIR ".")
  48. elseif(UNIX) # Linux, BSD etc
  49. set(DATADIR "share/${PROJECT_NAME}")
  50. set(BINDIR "bin")
  51. set(DOCDIR "share/doc/${PROJECT_NAME}")
  52. set(EXAMPLE_CONF_DIR "share/doc/${PROJECT_NAME}")
  53. endif()
  54. install(FILES "doc/README.txt" DESTINATION "${DOCDIR}")
  55. install(FILES "doc/changelog.txt" DESTINATION "${DOCDIR}")
  56. install(FILES "minetest.conf.example" DESTINATION "${DOCDIR}")
  57. #
  58. # Subdirectories
  59. # Be sure to add all relevant definitions above this
  60. #
  61. add_subdirectory(src)
  62. # CPack
  63. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An InfiniMiner/Minecraft inspired game")
  64. set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
  65. set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
  66. set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
  67. set(CPACK_PACKAGE_VENDOR "celeron55")
  68. set(CPACK_PACKAGE_CONTACT "Perttu Ahola <celeron55@gmail.com>")
  69. if(WIN32)
  70. # For some reason these aren't copied otherwise
  71. # NOTE: For some reason now it seems to work without these
  72. #if(BUILD_CLIENT)
  73. # install(FILES bin/minetest.exe DESTINATION bin)
  74. #endif()
  75. #if(BUILD_SERVER)
  76. # install(FILES bin/minetestserver.exe DESTINATION bin)
  77. #endif()
  78. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
  79. set(CPACK_GENERATOR ZIP)
  80. # This might be needed for some installer
  81. #set(CPACK_PACKAGE_EXECUTABLES bin/minetest.exe "Minetest" bin/minetestserver.exe "Minetest Server")
  82. elseif(APPLE)
  83. # TODO
  84. # see http://cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29
  85. #
  86. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx")
  87. set(CPACK_PACKAGE_ICON "")
  88. set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
  89. set(CPACK_BUNDLE_ICON "")
  90. set(CPACK_BUNDLE_PLIST "")
  91. set(CPACK_BUNDLE_STARTUP_COMMAND "Contents/MacOS/${PROJECT_NAME}")
  92. set(CPACK_GENERATOR "Bundle")
  93. else()
  94. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
  95. set(CPACK_GENERATOR TGZ)
  96. set(CPACK_SOURCE_GENERATOR TGZ)
  97. endif()
  98. include(CPack)