OpenBSD.cmake 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. include(Platform/NetBSD)
  2. # On OpenBSD, the compile time linker does not share it's configuration with
  3. # the runtime linker. This will extract the library search paths from the
  4. # system's ld.so.hints file which will allow CMake to set the appropriate
  5. # -rpath-link flags
  6. if(NOT CMAKE_PLATFORM_RUNTIME_PATH)
  7. execute_process(COMMAND /sbin/ldconfig -r
  8. OUTPUT_VARIABLE LDCONFIG_HINTS
  9. ERROR_QUIET)
  10. string(REGEX REPLACE ".*search\\ directories:\\ ([^\n]*).*" "\\1"
  11. LDCONFIG_HINTS "${LDCONFIG_HINTS}")
  12. string(REPLACE ":" ";"
  13. CMAKE_PLATFORM_RUNTIME_PATH
  14. "${LDCONFIG_HINTS}")
  15. endif()
  16. # OpenBSD requires -z origin to enable $ORIGIN expansion in RPATH.
  17. # This is not required for NetBSD.
  18. set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-z,origin,-rpath,")
  19. set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1)
  20. # OpenBSD has no multilib
  21. set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS FALSE)
  22. set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
  23. # OpenBSD policy requires that shared libraries be installed without
  24. # executable permission.
  25. set(CMAKE_INSTALL_SO_NO_EXE 1)
  26. if($ENV{LOCALBASE})
  27. set(OPENBSD_LOCALBASE $ENV{LOCALBASE})
  28. else()
  29. set(OPENBSD_LOCALBASE /usr/local)
  30. endif()
  31. if($ENV{X11BASE})
  32. set(OPENBSD_X11BASE $ENV{X11BASE})
  33. else()
  34. set(OPENBSD_X11BASE /usr/X11R6)
  35. endif()
  36. list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${OPENBSD_LOCALBASE})