CMakeLists.txt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #
  2. # Copyright (c) 2008-2017 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. # Check existence of various header files and their functions required by some of the third-party libraries and Urho3D library
  23. # Set the CMake variables in this scope but only add the compiler defines in the respective library's scope
  24. include (CheckIncludeFile)
  25. foreach (HEADER stdint.h inttypes.h malloc.h)
  26. string (TOUPPER HAVE_${HEADER} HAVE_HEADER)
  27. string (REPLACE . _ HAVE_HEADER ${HAVE_HEADER})
  28. check_include_file (${HEADER} ${HAVE_HEADER})
  29. endforeach ()
  30. include (CheckFunctionExists)
  31. foreach (FUNCT __sincosf malloc_usable_size)
  32. string (TOUPPER HAVE_${FUNCT} HAVE_FUNCT)
  33. check_function_exists (${FUNCT} ${HAVE_FUNCT})
  34. endforeach ()
  35. include (CheckLibraryExists)
  36. check_library_exists (m sincosf "" HAVE_SINCOSF)
  37. if (MINGW)
  38. include (CheckStructHasMember)
  39. check_struct_has_member (RTL_OSVERSIONINFOW dwOSVersionInfoSize minwindef.h\;winnt.h HAVE_RTL_OSVERSIONINFOW)
  40. endif ()
  41. # Setup RPATH settings
  42. if (URHO3D_LIB_TYPE STREQUAL SHARED AND NOT WIN32 AND NOT ANDROID AND NOT IOS AND NOT TVOS AND NOT WEB)
  43. # Add RPATH entries when building
  44. set (CMAKE_SKIP_BUILD_RPATH FALSE)
  45. # But don't set them yet in the build tree
  46. set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  47. if (APPLE)
  48. set (CMAKE_MACOSX_RPATH TRUE)
  49. set (ORIGIN @loader_path)
  50. else ()
  51. set (ORIGIN $ORIGIN)
  52. endif ()
  53. # When installing/packaging set the first RPATH entry to the library location relative to the executable
  54. set (CMAKE_INSTALL_RPATH ${ORIGIN}/../lib${LIB_SUFFIX}/${PATH_SUFFIX}) # The library location is based on SDK install destination
  55. # The second entry to the library location relative to the executable in the tool directory
  56. list (APPEND CMAKE_INSTALL_RPATH ${ORIGIN}/../../lib${LIB_SUFFIX}/${PATH_SUFFIX}) # The tools are installed one directory further down from normal executable
  57. # The last entry to the install destination of the library, if the destination location is not in the system default search path
  58. list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} isSystemDir)
  59. if (isSystemDir STREQUAL -1)
  60. list (APPEND CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${DEST_LIBRARY_DIR})
  61. endif ()
  62. endif ()
  63. # Add targets
  64. foreach (TARGET FreeType JO LZ4 PugiXml rapidjson SDL StanHull STB)
  65. add_subdirectory (ThirdParty/${TARGET})
  66. endforeach ()
  67. if (URHO3D_ANGELSCRIPT)
  68. add_subdirectory (ThirdParty/AngelScript)
  69. if (WEB OR (ARM AND URHO3D_64BIT))
  70. add_subdirectory (ThirdParty/boost)
  71. endif ()
  72. endif ()
  73. if (URHO3D_LUA)
  74. add_subdirectory (ThirdParty/Lua${JIT})
  75. add_subdirectory (ThirdParty/toluapp/src/lib)
  76. endif ()
  77. if (URHO3D_NETWORK)
  78. add_subdirectory (ThirdParty/Civetweb)
  79. add_subdirectory (ThirdParty/kNet)
  80. endif ()
  81. if (URHO3D_DATABASE_ODBC)
  82. add_subdirectory (ThirdParty/nanodbc)
  83. endif ()
  84. if (URHO3D_DATABASE_SQLITE)
  85. add_subdirectory (ThirdParty/SQLite)
  86. endif ()
  87. if (URHO3D_IK)
  88. add_subdirectory (ThirdParty/ik)
  89. endif ()
  90. if (URHO3D_NAVIGATION)
  91. add_subdirectory (ThirdParty/Detour)
  92. add_subdirectory (ThirdParty/DetourCrowd)
  93. add_subdirectory (ThirdParty/DetourTileCache)
  94. add_subdirectory (ThirdParty/Recast)
  95. endif ()
  96. if (URHO3D_URHO2D)
  97. add_subdirectory (ThirdParty/Box2D)
  98. if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/spine)
  99. add_subdirectory (ThirdParty/spine)
  100. # Add definition for Spine
  101. add_definitions (-DURHO3D_SPINE)
  102. endif ()
  103. endif ()
  104. if (URHO3D_WEBP)
  105. add_subdirectory (ThirdParty/WebP)
  106. endif ()
  107. if (URHO3D_PHYSICS)
  108. add_subdirectory (ThirdParty/Bullet)
  109. endif ()
  110. if (NOT ANDROID AND NOT ARM AND NOT WEB)
  111. if (URHO3D_OPENGL)
  112. add_subdirectory (ThirdParty/GLEW)
  113. elseif (NOT URHO3D_D3D11)
  114. add_subdirectory (ThirdParty/MojoShader)
  115. endif ()
  116. if (NOT CMAKE_SYSTEM_NAME STREQUAL Linux)
  117. add_subdirectory (ThirdParty/LibCpuId)
  118. endif ()
  119. endif ()
  120. # Urho3D game engine library
  121. add_subdirectory (Urho3D)
  122. # Urho3D Clang tools
  123. if (URHO3D_CLANG_TOOLS)
  124. add_subdirectory (Clang-Tools)
  125. endif ()
  126. # Urho3D tools
  127. add_subdirectory (Tools)
  128. # Urho3D samples
  129. # Samples are built on iOS/tvOS platform too when enabled. Currently there is no available mechanism to package each sample apps into individual *.apk
  130. # for Android platform, so we deploy all samples into one apk and use a simple list view activity launcher to select the sample to run
  131. if (URHO3D_SAMPLES)
  132. add_subdirectory (Samples)
  133. endif ()
  134. # Urho3D extras
  135. if (URHO3D_EXTRAS)
  136. add_subdirectory (Extras)
  137. endif ()