Haiku.cmake 4.9 KB

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