aboutsummaryrefslogtreecommitdiff
path: root/cmake/Find.cmake
blob: b3630525101e0461bf733149b1994710cca0d07d (plain) (blame)
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
# Functions to aid the built-in find_ functions

# Same as find_path, but always search in .deps directory first and then everything else.
function(find_path2)
  find_path_nvim(${ARGV})
  find_path(${ARGV})
endfunction()

function(find_path_nvim)
  set(CMAKE_FIND_FRAMEWORK NEVER)
  set(CMAKE_FIND_APPBUNDLE NEVER)
  find_path(${ARGV} NO_CMAKE_SYSTEM_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH)
endfunction()

# Same as find_library, but with the following search order:
# 1. Only search in .deps directory. Only search for static libraries.
# 2. Only search in .deps directory. Search all libraries
# 3. Search everywhere, all libraries
function(find_library2)
  find_library_nvim(STATIC ${ARGV})
  find_library_nvim(${ARGV})
  find_library(${ARGV})
endfunction()

function(find_library_nvim)
  cmake_parse_arguments(ARG
    "STATIC"
    ""
    ""
    ${ARGN})
  list(REMOVE_ITEM ARGN STATIC)

  if(ARG_STATIC)
    set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
  endif()
  set(CMAKE_FIND_FRAMEWORK NEVER)
  set(CMAKE_FIND_APPBUNDLE NEVER)
  find_library(${ARGN} NO_CMAKE_SYSTEM_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH)
endfunction()