aboutsummaryrefslogtreecommitdiffhomepage
path: root/CMakeModules/FindUnicorn.cmake
blob: 71fc08ac37dd1249e3ac7e8b5f5416d20af349ce (plain)
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
# Exports:
#
# Variables:
#  LIBUNICORN_FOUND
#  LIBUNICORN_INCLUDE_DIR
#  LIBUNICORN_LIBRARY
#
# Target:
#  Unicorn::Unicorn
#

find_path(LIBUNICORN_INCLUDE_DIR
          unicorn/unicorn.h
          HINTS $ENV{UNICORNDIR}
          PATH_SUFFIXES include)

find_library(LIBUNICORN_LIBRARY
             NAMES unicorn
             HINTS $ENV{UNICORNDIR})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Unicorn DEFAULT_MSG LIBUNICORN_LIBRARY LIBUNICORN_INCLUDE_DIR)

if (UNICORN_FOUND)
    set(THREADS_PREFER_PTHREAD_FLAG ON)
    find_package(Threads REQUIRED)
    unset(THREADS_PREFER_PTHREAD_FLAG)

    add_library(Unicorn::Unicorn UNKNOWN IMPORTED)
    set_target_properties(Unicorn::Unicorn PROPERTIES
        IMPORTED_LOCATION ${LIBUNICORN_LIBRARY}
        INTERFACE_INCLUDE_DIRECTORIES ${LIBUNICORN_INCLUDE_DIR}
        INTERFACE_LINK_LIBRARIES Threads::Threads
    )
endif()

mark_as_advanced(LIBUNICORN_INCLUDE_DIR LIBUNICORN_LIBRARY)