Debian Codegraph @

cmake/FindWrapQt3DAssimp.cmake

raw
1 # Copyright (C) 2022 The Qt Company Ltd.
2 # SPDX-License-Identifier: BSD-3-Clause
3
4 if(TARGET WrapQt3DAssimp::WrapQt3DAssimp)
5 set(WrapQt3DAssimp_FOUND TRUE)
6 return()
7 endif()
8
9 set(WrapQt3DAssimp_FOUND FALSE)
10
11 find_package(assimp ${WrapQt3DAssimp_FIND_VERSION} CONFIG QUIET)
12 if (assimp_FOUND AND TARGET assimp::assimp)
13 add_library(WrapQt3DAssimp::WrapQt3DAssimp INTERFACE IMPORTED)
14 target_link_libraries(WrapQt3DAssimp::WrapQt3DAssimp INTERFACE assimp::assimp)
15
16 # The Assimp configuration file is broken, and sets only the Release location, without advertising
17 # that it's available via IMPORTED_CONFIGURATIONS. Thus when configuring with a different
18 # configuration, you get a assimp::assimp-NOTFOUND at build time.
19 # Make the release configuration be the default one.
20 get_target_property(_assimp_library_location assimp::assimp IMPORTED_LOCATION)
21 if(NOT _assimp_library_location)
22 get_target_property(_assimp_library_location_release assimp::assimp IMPORTED_LOCATION_RELEASE)
23 if(_assimp_library_location_release)
24 set_target_properties(assimp::assimp PROPERTIES
25 IMPORTED_LOCATION "${_assimp_library_location_release}")
26 endif()
27 endif()
28
29 # Work around Debian bug #973361
30 set(_assimp_fixed_include_dirs)
31 get_target_property(_assimp_include_dirs assimp::assimp INTERFACE_INCLUDE_DIRECTORIES)
32 if(NOT _assimp_include_dirs MATCHES "-NOTFOUND$")
33 foreach(dir IN LISTS _assimp_include_dirs)
34 if(dir STREQUAL "/usr/lib/include"
35 AND NOT EXISTS "/usr/lib/include"
36 AND EXISTS "/usr/include")
37 set(dir "/usr/include")
38 endif()
39 list(APPEND _assimp_fixed_include_dirs "${dir}")
40 endforeach()
41 endif()
42 set_property(TARGET assimp::assimp
43 PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_assimp_fixed_include_dirs}")
44 unset(_assimp_fixed_include_dirs)
45 unset(_assimp_include_dirs)
46
47 set(WrapQt3DAssimp_FOUND TRUE)
48 elseif(assimp_FOUND AND assimp_LIBRARIES AND assimp_INCLUDE_DIRS)
49 add_library(WrapQt3DAssimp::WrapQt3DAssimp INTERFACE IMPORTED)
50 target_link_libraries(WrapQt3DAssimp::WrapQt3DAssimp INTERFACE ${assimp_LIBRARIES})
51 target_include_directories(WrapQt3DAssimp::WrapQt3DAssimp INTERFACE ${assimp_INCLUDE_DIRS})
52 set(WrapQt3DAssimp_FOUND TRUE)
53 endif()
54
55 include(FindPackageHandleStandardArgs)
56 find_package_handle_standard_args(WrapQt3DAssimp DEFAULT_MSG WrapQt3DAssimp_FOUND)