CMakeLists.txt 5.7 KB

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