CMakeLists.txt 4.6 KB

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