CMakeLists.txt 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #
  2. # Copyright (c) 2008-2014 the Urho3D project.
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a copy
  5. # of this software and associated documentation files (the "Software"), to deal
  6. # in the Software without restriction, including without limitation the rights
  7. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. # copies of the Software, and to permit persons to whom the Software is
  9. # furnished to do so, subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be included in
  12. # all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. # THE SOFTWARE.
  21. #
  22. # Set project name
  23. project (Urho3D)
  24. # Set minimum version
  25. cmake_minimum_required (VERSION 2.8.6)
  26. if (COMMAND cmake_policy)
  27. cmake_policy (SET CMP0003 NEW)
  28. endif ()
  29. # Set CMake modules search path
  30. set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
  31. # Include Urho3D cmake common module
  32. include (Urho3D-CMake-common)
  33. # Check existence of stdint.h for LibCpuId
  34. include (CheckIncludeFiles)
  35. CHECK_INCLUDE_FILES (stdint.h HAVE_STDINT_H)
  36. if (HAVE_STDINT_H)
  37. add_definitions (-DHAVE_STDINT_H)
  38. endif ()
  39. # Setup SDK install destinations
  40. if (WIN32)
  41. # CMake already automatically prepends "Urho3D" to CMAKE_INSTALL_PREFIX on Windows platform
  42. set (SCRIPT_PATTERN *.bat)
  43. else ()
  44. set (PATH_SUFFIX /Urho3D)
  45. if (ENABLE_64BIT) # TODO: Revisit this again when ARM also supports 64bit, for now ARM architecture ignores ENABLE_64BIT build option
  46. if (NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/lib64)
  47. # Probably target system is a RedHat-based distro
  48. set (LIB_SUFFIX 64)
  49. endif ()
  50. endif ()
  51. if (IOS)
  52. # Use 'ios' arch subdirectory to differentiate, in case both Mac OS X and iOS build are installed at the same destination
  53. set (LIB_SUFFIX ${LIB_SUFFIX}/ios)
  54. endif ()
  55. set (SCRIPT_PATTERN *.sh)
  56. endif ()
  57. set (DEST_INCLUDE_DIR include${PATH_SUFFIX})
  58. set (DEST_SHARE_DIR share${PATH_SUFFIX})
  59. set (DEST_RUNTIME_DIR ${DEST_SHARE_DIR}/Bin)
  60. set (DEST_LIBRARY_DIR lib${LIB_SUFFIX}${PATH_SUFFIX}) # Note to Linux package maintainer: ${PATH_SUFFIX} for library could be patched out if the suffix is not desirable
  61. set (DEST_PKGCONFIG_DIR lib${LIB_SUFFIX}/pkgconfig)
  62. # Install application launcher scripts
  63. file (GLOB APP_SCRIPTS ${PROJECT_ROOT_DIR}/Bin/${SCRIPT_PATTERN})
  64. install (FILES ${APP_SCRIPTS} DESTINATION ${DEST_RUNTIME_DIR} PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) # 755
  65. # Install resource directories required by applications built with Urho3D library
  66. install (DIRECTORY ${PROJECT_ROOT_DIR}/Bin/CoreData ${PROJECT_ROOT_DIR}/Bin/Data DESTINATION ${DEST_RUNTIME_DIR} USE_SOURCE_PERMISSIONS)
  67. # Install CMake modules and toolchains provided by and for Urho3D
  68. install (DIRECTORY ${PROJECT_ROOT_DIR}/Source/CMake/ DESTINATION ${DEST_SHARE_DIR}/CMake USE_SOURCE_PERMISSIONS) # Note: the trailing slash is significant
  69. # Install CMake launcher scripts
  70. file (GLOB CMAKE_SCRIPTS ${PROJECT_ROOT_DIR}/${SCRIPT_PATTERN})
  71. install (FILES ${CMAKE_SCRIPTS} DESTINATION ${DEST_SHARE_DIR}/Scripts PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  72. # Setup package variables
  73. set (URHO3D_DESCRIPTION "Urho3D is a lightweight, cross-platform rendering and game engine implemented in C++ and released under the MIT license. Greatly inspired by OGRE (http://www.ogre3d.org) and Horde3D (http://www.horde3d.org).")
  74. set (CPACK_PACKAGE_DESCRIPTION_SUMMARY ${URHO3D_DESCRIPTION})
  75. set (URHO3D_URL "https://github.com/urho3d/Urho3D")
  76. set (CPACK_PACKAGE_VENDOR ${URHO3D_URL})
  77. set (CPACK_PACKAGE_CONTACT ${URHO3D_URL})
  78. execute_process (COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/CMake/Modules/GetUrho3DRevision.cmake OUTPUT_VARIABLE URHO3D_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  79. set (CPACK_PACKAGE_VERSION ${URHO3D_VERSION})
  80. string (REGEX MATCH "([^.]+)\\.([^.]+)\\.(.+)" MATCHED ${URHO3D_VERSION})
  81. if (MATCHED)
  82. set (CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})
  83. set (CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})
  84. set (CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3})
  85. endif ()
  86. set (CPACK_RESOURCE_FILE_LICENSE ${PROJECT_ROOT_DIR}/License.txt)
  87. set (CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
  88. set (CPACK_GENERATOR TGZ)
  89. if (ANDROID)
  90. set (CPACK_SYSTEM_NAME Android)
  91. elseif (RASPI)
  92. set (CPACK_SYSTEM_NAME Raspberry-Pi)
  93. elseif (IOS)
  94. set (CPACK_SYSTEM_NAME iOS)
  95. elseif (APPLE)
  96. set (CPACK_SYSTEM_NAME OSX)
  97. elseif (WIN32)
  98. set (CPACK_GENERATOR ZIP)
  99. elseif (CPACK_SYSTEM_NAME STREQUAL Linux)
  100. list (APPEND CPACK_GENERATOR RPM DEB)
  101. endif ()
  102. if (ENABLE_64BIT)
  103. set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-64bit)
  104. endif ()
  105. set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-${URHO3D_LIB_TYPE}-snapshot)
  106. include (CPack)
  107. # Add targets
  108. foreach (TARGET Bullet Civetweb Detour FreeType JO kNet LZ4 PugiXml Recast SDL StanHull STB)
  109. add_subdirectory (ThirdParty/${TARGET})
  110. endforeach ()
  111. if (ENABLE_ANGELSCRIPT)
  112. add_subdirectory (ThirdParty/AngelScript)
  113. endif ()
  114. if (ENABLE_LUA)
  115. add_subdirectory (Engine/LuaScript)
  116. add_subdirectory (ThirdParty/Lua${JIT})
  117. add_subdirectory (ThirdParty/toluapp/src/lib)
  118. endif ()
  119. if (NOT IOS AND NOT ANDROID AND NOT RASPI)
  120. if (USE_OPENGL)
  121. add_subdirectory (ThirdParty/GLEW)
  122. else ()
  123. add_subdirectory (ThirdParty/MojoShader)
  124. endif ()
  125. add_subdirectory (ThirdParty/LibCpuId)
  126. endif ()
  127. # Urho3D game engine library
  128. add_subdirectory (Engine)
  129. # Urho3D tools
  130. add_subdirectory (Tools)
  131. # Urho3D samples
  132. # Samples are built on iOS platform too when enabled
  133. # Although samples should also work for Android platform, currently there is no available mechanism to package each sample apps into individual *.apk
  134. if (NOT ANDROID AND ENABLE_SAMPLES)
  135. add_subdirectory (Samples)
  136. endif ()
  137. # Urho3D extras
  138. # Do not build extras for iOS and Android regardless of its build option
  139. if (NOT IOS AND NOT ANDROID AND ENABLE_EXTRAS)
  140. add_subdirectory (Extras)
  141. endif ()
  142. # Urho3D documentation
  143. add_subdirectory (../Docs ${PROJECT_BINARY_DIR}/Docs)