CMakeLists.txt 3.5 KB

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