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