File: Platform.cmake

package info (click to toggle)
libmongocrypt 1.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,572 kB
  • sloc: ansic: 70,067; python: 4,547; cpp: 615; sh: 460; makefile: 44; awk: 8
file content (50 lines) | stat: -rw-r--r-- 1,497 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#[[
    Defines a platform-support target _mongocrypt::platform.

    This target sets certain internal-only compile definitions, and defines
    usage requirements on certain platform features required by libmongocrypt
    (Threads, dlopen(), math)
]]

add_library (lmc-platform INTERFACE)
add_library (mongocrypt::platform ALIAS lmc-platform)
install (TARGETS lmc-platform EXPORT mongocrypt_targets)
set_property (
    TARGET lmc-platform
    PROPERTY EXPORT_NAME mongocrypt::platform
    )

# Threads:
find_package (Threads REQUIRED)

# Special math:
if (NOT APPLE)
    find_library (M_LIBRARY m)
endif ()

# Special runtime:
find_library (RT_LIBRARY rt)

# Endian detection:
if (DEFINED CMAKE_C_BYTE_ORDER)
    # Newer CMake knows this immediately:
    set (MONGOCRYPT_ENDIAN_DEF "MONGOCRYPT_${CMAKE_C_BYTE_ORDER}")
else ()
    include (TestBigEndian)
    test_big_endian (_is_big)
    set (MONGOCRYPT_ENDIAN_DEF "MONGOCRYPT_$<IF:${_is_big},BIG,LITTLE>_ENDIAN")
endif ()

target_compile_definitions (lmc-platform INTERFACE
    "$<BUILD_INTERFACE:${MONGOCRYPT_ENDIAN_DEF}>"
    )
target_link_libraries (lmc-platform INTERFACE
    Threads::Threads
    # These are build-interface libs, but still required. These will be added
    # to the platform library in mongocrypt-config.cmake using the same
    # find_library() calls:
    $<BUILD_INTERFACE:${CMAKE_DL_LIBS}>
    $<BUILD_INTERFACE:$<$<BOOL:${M_LIBRARY}>:${M_LIBRARY}>>
    $<BUILD_INTERFACE:$<$<BOOL:${RT_LIBRARY}>:${RT_LIBRARY}>>
    )