Haiku.cmake 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # process only once
  2. if(HAIKU)
  3. return()
  4. endif()
  5. set(HAIKU 1)
  6. set(UNIX 1)
  7. set(CMAKE_DL_LIBS "")
  8. set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC")
  9. set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
  10. set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
  11. set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
  12. set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN")
  13. set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,")
  14. set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
  15. set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
  16. # Determine, if the C or C++ compiler is configured for a secondary
  17. # architecture. If so, that will change the search paths we set below. We check
  18. # whether the compiler's library search paths contain a
  19. # "/boot/system/develop/lib/<subdir>/", which we assume to be the secondary
  20. # architecture specific subdirectory and extract the name of the architecture
  21. # accordingly.
  22. # First of all, find a C or C++ compiler we can run. The "arg1" is necessary
  23. # here for compilers such as "distcc gcc-x86" or "ccache gcc-x86"
  24. # TODO See CMakeDetermineCompilerId.cmake for some more things we may want to do.
  25. if(CMAKE_C_COMPILER)
  26. set(__HAIKU_COMPILER ${CMAKE_C_COMPILER})
  27. string (STRIP "${CMAKE_C_COMPILER_ARG1}" __HAIKU_COMPILER_FLAGS)
  28. else()
  29. set(__HAIKU_COMPILER ${CMAKE_CXX_COMPILER})
  30. string (STRIP "${CMAKE_CXX_COMPILER_ARG1}" __HAIKU_COMPILER_FLAGS)
  31. endif()
  32. execute_process(
  33. COMMAND ${__HAIKU_COMPILER} ${__HAIKU_COMPILER_FLAGS} -print-search-dirs
  34. OUTPUT_VARIABLE _HAIKU_SEARCH_DIRS
  35. RESULT_VARIABLE _HAIKU_SEARCH_DIRS_FOUND
  36. OUTPUT_STRIP_TRAILING_WHITESPACE)
  37. string(REGEX MATCH "libraries: =?([^\n]*:)?/boot/system/develop/lib/([^/]*)/?(:?\n+)" _dummy "${_HAIKU_SEARCH_DIRS}\n")
  38. set(CMAKE_HAIKU_SECONDARY_ARCH "${CMAKE_MATCH_2}")
  39. if(NOT CMAKE_HAIKU_SECONDARY_ARCH)
  40. set(CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR "")
  41. unset(CMAKE_HAIKU_SECONDARY_ARCH)
  42. else()
  43. set(CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR "/${CMAKE_HAIKU_SECONDARY_ARCH}")
  44. # Override CMAKE_*LIBRARY_ARCHITECTURE. This will cause FIND_LIBRARY to search
  45. # the libraries in the correct subdirectory first. It still isn't completely
  46. # correct, since the parent directories shouldn't be searched at all. The
  47. # primary architecture library might still be found, if there isn't one
  48. # installed for the secondary architecture or it is installed in a less
  49. # specific location.
  50. set(CMAKE_LIBRARY_ARCHITECTURE ${CMAKE_HAIKU_SECONDARY_ARCH})
  51. set(CMAKE_C_LIBRARY_ARCHITECTURE ${CMAKE_HAIKU_SECONDARY_ARCH})
  52. set(CMAKE_CXX_LIBRARY_ARCHITECTURE ${CMAKE_HAIKU_SECONDARY_ARCH})
  53. endif()
  54. list(APPEND CMAKE_SYSTEM_PREFIX_PATH
  55. /boot/system/non-packaged
  56. /boot/system
  57. )
  58. LIST(APPEND CMAKE_HAIKU_COMMON_INCLUDE_DIRECTORIES
  59. /boot/system/non-packaged/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
  60. /boot/system/develop/headers/os
  61. /boot/system/develop/headers/os/app
  62. /boot/system/develop/headers/os/device
  63. /boot/system/develop/headers/os/drivers
  64. /boot/system/develop/headers/os/game
  65. /boot/system/develop/headers/os/interface
  66. /boot/system/develop/headers/os/kernel
  67. /boot/system/develop/headers/os/locale
  68. /boot/system/develop/headers/os/mail
  69. /boot/system/develop/headers/os/media
  70. /boot/system/develop/headers/os/midi
  71. /boot/system/develop/headers/os/midi2
  72. /boot/system/develop/headers/os/net
  73. /boot/system/develop/headers/os/opengl
  74. /boot/system/develop/headers/os/storage
  75. /boot/system/develop/headers/os/support
  76. /boot/system/develop/headers/os/translation
  77. /boot/system/develop/headers/os/add-ons/graphics
  78. /boot/system/develop/headers/os/add-ons/input_server
  79. /boot/system/develop/headers/os/add-ons/screen_saver
  80. /boot/system/develop/headers/os/add-ons/tracker
  81. /boot/system/develop/headers/os/be_apps/Deskbar
  82. /boot/system/develop/headers/os/be_apps/NetPositive
  83. /boot/system/develop/headers/os/be_apps/Tracker
  84. /boot/system/develop/headers/3rdparty
  85. /boot/system/develop/headers/bsd
  86. /boot/system/develop/headers/glibc
  87. /boot/system/develop/headers/gnu
  88. /boot/system/develop/headers/posix
  89. /boot/system/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
  90. )
  91. IF (CMAKE_HAIKU_SECONDARY_ARCH)
  92. LIST(APPEND CMAKE_HAIKU_COMMON_INCLUDE_DIRECTORIES
  93. /boot/system/develop/headers
  94. )
  95. ENDIF (CMAKE_HAIKU_SECONDARY_ARCH)
  96. LIST(APPEND CMAKE_HAIKU_C_INCLUDE_DIRECTORIES
  97. ${CMAKE_HAIKU_COMMON_INCLUDE_DIRECTORIES}
  98. )
  99. LIST(APPEND CMAKE_HAIKU_CXX_INCLUDE_DIRECTORIES
  100. ${CMAKE_HAIKU_COMMON_INCLUDE_DIRECTORIES})
  101. LIST(APPEND CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_HAIKU_C_INCLUDE_DIRECTORIES})
  102. LIST(APPEND CMAKE_HAIKU_DEVELOP_LIB_DIRECTORIES
  103. /boot/system/non-packaged/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
  104. /boot/system/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
  105. )
  106. LIST(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
  107. ${CMAKE_HAIKU_DEVELOP_LIB_DIRECTORIES}
  108. )
  109. LIST(APPEND CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_HAIKU_DEVELOP_LIB_DIRECTORIES})
  110. if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  111. set(CMAKE_INSTALL_PREFIX "/boot/system" CACHE PATH
  112. "Install path prefix, prepended onto install directories." FORCE)
  113. endif()