CMakeLists.txt 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #
  2. # Copyright (c) 2008-2013 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 module
  32. include (Urho3D-CMake-magic)
  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. # Add targets
  73. foreach (TARGET Bullet Civetweb Detour FreeType JO kNet LZ4 PugiXml Recast SDL StanHull STB)
  74. add_subdirectory (ThirdParty/${TARGET})
  75. endforeach ()
  76. if (ENABLE_ANGELSCRIPT)
  77. add_subdirectory (ThirdParty/AngelScript)
  78. endif ()
  79. if (ENABLE_LUA)
  80. add_subdirectory (Engine/LuaScript)
  81. add_subdirectory (ThirdParty/Lua${JIT})
  82. add_subdirectory (ThirdParty/toluapp/src/lib)
  83. endif ()
  84. if (NOT IOS AND NOT ANDROID AND NOT RASPI)
  85. if (USE_OPENGL)
  86. add_subdirectory (ThirdParty/GLEW)
  87. endif ()
  88. add_subdirectory (ThirdParty/LibCpuId)
  89. endif ()
  90. # Urho3D game engine library
  91. add_subdirectory (Engine)
  92. # Urho3D tools
  93. add_subdirectory (Tools)
  94. # Urho3D samples
  95. # Samples are built on iOS platform too when enabled
  96. # Although samples should also work for Android platform, currently there is no available mechanism to package each sample apps into individual *.apk
  97. if (NOT ANDROID AND ENABLE_SAMPLES)
  98. add_subdirectory (Samples)
  99. endif ()
  100. # Urho3D extras
  101. # Do not build extras for iOS and Android regardless of its build option
  102. if (NOT IOS AND NOT ANDROID AND ENABLE_EXTRAS)
  103. add_subdirectory (Extras)
  104. endif ()
  105. # Urho3D documentation
  106. add_subdirectory (../Docs ${PROJECT_BINARY_DIR}/Docs)