• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Will add_directory the given path only if the directory exists. If the directory doesn't exist,
2# it will look for either arm64-android or x86_64-android variants of the path. If it finds either, or both,
3# then it will add the newer of the two.
4function(try_add_subdir path)
5    if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${path}")
6      add_subdirectory(${path})
7    endif()
8
9    set(path_arm64 ${path}-arm64-android)
10    if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${path_arm64}")
11        set(has_arm64 TRUE)
12    else()
13        set(has_arm64 FALSE)
14    endif()
15
16    set(path_x64 ${path}-x86_64-android)
17    if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${path_x64}")
18        set(has_x64 TRUE)
19    else()
20        set(has_x64 FALSE)
21    endif()
22
23    if (${has_arm64} AND ${has_x64})
24        if ("${CMAKE_CURRENT_SOURCE_DIR}/${path_arm64}/CMakeLists.txt" IS_NEWER_THAN
25                "${CMAKE_CURRENT_SOURCE_DIR}/${path_x64}/CMakeLists.txt")
26            add_subdirectory(${path_arm64})
27        else()
28            add_subdirectory(${path_x64})
29        endif()
30    elseif(${has_arm64})
31        add_subdirectory(${path_arm64})
32    elseif(${has_x64})
33        add_subdirectory(${path_x64})
34    endif()
35endfunction()