CMakeLists.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright (c) 2008-2023 the Urho3D project
  2. # Copyright (c) 2022-2023 the Dviglo project
  3. # License: MIT
  4. # Check existence of various header files and their functions required by some of the third-party libraries and Urho3D library
  5. # Set the CMake variables in this scope but only add the compiler defines in the respective library's scope
  6. include (CheckIncludeFile)
  7. foreach (HEADER stdint.h inttypes.h malloc.h)
  8. string (TOUPPER HAVE_${HEADER} HAVE_HEADER)
  9. string (REPLACE . _ HAVE_HEADER ${HAVE_HEADER})
  10. check_include_file (${HEADER} ${HAVE_HEADER})
  11. endforeach ()
  12. include (CheckFunctionExists)
  13. foreach (FUNCT __sincosf malloc_usable_size)
  14. string (TOUPPER HAVE_${FUNCT} HAVE_FUNCT)
  15. check_function_exists (${FUNCT} ${HAVE_FUNCT})
  16. endforeach ()
  17. include (CheckLibraryExists)
  18. check_library_exists (m sincosf "" HAVE_SINCOSF)
  19. if (MINGW)
  20. include (CheckStructHasMember)
  21. check_struct_has_member (RTL_OSVERSIONINFOW dwOSVersionInfoSize minwindef.h\;winnt.h HAVE_RTL_OSVERSIONINFOW)
  22. endif ()
  23. # Setup RPATH settings
  24. if (URHO3D_LIB_TYPE STREQUAL SHARED AND NOT WIN32 AND NOT ANDROID AND NOT IOS AND NOT TVOS AND NOT WEB)
  25. # Add RPATH entries when building
  26. set (CMAKE_SKIP_BUILD_RPATH FALSE)
  27. # And set the RPATH entries so that the executable works both in the build tree and install destination
  28. set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
  29. if (APPLE)
  30. set (CMAKE_MACOSX_RPATH TRUE)
  31. set (ORIGIN @loader_path)
  32. else ()
  33. set (ORIGIN $ORIGIN)
  34. endif ()
  35. # Library location relative to the executable in the build tree
  36. set (CMAKE_INSTALL_RPATH ${ORIGIN}/../lib)
  37. # Library location relative to the executable in the tool directory in the build tree
  38. list (APPEND CMAKE_INSTALL_RPATH ${ORIGIN}/../../lib) # The tools are installed one directory further down from normal executable
  39. # Library location relative to the executable in the install destination
  40. list (APPEND CMAKE_INSTALL_RPATH ${ORIGIN}/../lib${LIB_SUFFIX}/${PATH_SUFFIX}) # The library location is based on SDK install destination
  41. # Library location relative to the executable in the tool directory in the install destination
  42. list (APPEND CMAKE_INSTALL_RPATH ${ORIGIN}/../../lib${LIB_SUFFIX}/${PATH_SUFFIX})
  43. # 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
  44. list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} isSystemDir)
  45. if (isSystemDir STREQUAL -1)
  46. list (APPEND CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${DEST_LIBRARY_DIR})
  47. endif ()
  48. endif ()
  49. add_subdirectory (ThirdParty)
  50. add_subdirectory (Urho3D)
  51. # In order to get clean module segregation, always exclude player/samples from AAR
  52. if (NOT ANDROID)
  53. add_subdirectory (Tools)
  54. add_subdirectory (Samples)
  55. endif ()
  56. if (URHO3D_EXTRAS)
  57. add_subdirectory (Extras)
  58. endif ()