|
1 | 1 | #.rst: |
2 | | -# FindPanda3d |
| 2 | +# Findpanda3d |
3 | 3 | # -------------- |
4 | 4 | # |
5 | | -# FindPanda3d.cmake |
| 5 | +# Findpanda3d.cmake |
6 | 6 | # |
7 | 7 | # Author: Younguk Kim (bluekyu) |
8 | 8 | # Date : 2016-08-02 |
|
12 | 12 | # |
13 | 13 | # This module defines the following variables:: |
14 | 14 | # |
15 | | -# Panda3d_INCLUDE_DIRS - Include directories for Panda3D |
16 | | -# Panda3d_LIBRARIES - Libraries to link against Panda3D |
17 | | -# Panda3d_FOUND - True if Panda3D has been found and can be used |
18 | | -# Panda3d_VERSION - Library version for Panda3D |
19 | | -# Panda3d_VERSION_STRING - Library version for Panda3D |
20 | | -# Panda3d_VERSION_MAJOR - Library major version for Panda3D |
21 | | -# Panda3d_VERSION_MINOR - Library minor version for Panda3D |
22 | | -# Panda3d_VERSION_PATCH - Library patch version for Panda3D |
| 15 | +# panda3d_FOUND - True if panda3d has been found and can be used |
| 16 | +# panda3d_VERSION - Library version for panda3d |
| 17 | +# panda3d_VERSION_STRING - Library version for panda3d |
| 18 | +# panda3d_VERSION_MAJOR - Library major version for panda3d |
| 19 | +# panda3d_VERSION_MINOR - Library minor version for panda3d |
| 20 | +# panda3d_VERSION_PATCH - Library patch version for panda3d |
23 | 21 | # |
24 | | -# and the following imported targets:: |
| 22 | +# The following `IMPORTED` targets are also defined:: |
25 | 23 | # |
26 | | -# Panda3d::Panda3d - The Panda3D library |
| 24 | +# panda3d::panda3d - Target for the Panda3D necessary libraries. |
| 25 | +# panda3d::<C> - Target for specific Panda3D component. |
27 | 26 |
|
28 | 27 | cmake_minimum_required(VERSION 3.2) |
29 | 28 |
|
30 | | -find_path(Panda3d_INCLUDE_DIR |
| 29 | +find_path(panda3d_INCLUDE_DIR |
31 | 30 | NAMES "pandaFramework.h" |
32 | 31 | HINTS "${PANDA3D_ROOT}/include" |
33 | 32 | ) |
34 | 33 |
|
35 | | -foreach(COMPONENT_NAME ${Panda3d_FIND_COMPONENTS}) |
36 | | - find_library(PANDA3D_${COMPONENT_NAME}_LIBRARY |
37 | | - NAMES ${COMPONENT_NAME} |
| 34 | +set(panda3d_DEFAULT_COMPONENTS p3framework panda pandaexpress p3dtool p3dtoolconfig p3direct p3interrogatedb) |
| 35 | + |
| 36 | +list(APPEND panda3d_FIND_COMPONENTS ${panda3d_DEFAULT_COMPONENTS}) |
| 37 | +list(REMOVE_DUPLICATES panda3d_FIND_COMPONENTS) |
| 38 | + |
| 39 | +set(panda3d_NON_DEFAULT_COMPONENTS ${panda3d_FIND_COMPONENTS}) |
| 40 | +list(REMOVE_ITEM panda3d_NON_DEFAULT_COMPONENTS ${panda3d_DEFAULT_COMPONENTS}) |
| 41 | + |
| 42 | +foreach(COMPONENT_NAME ${panda3d_FIND_COMPONENTS}) |
| 43 | + find_library(panda3d_${COMPONENT_NAME}_LIBRARY |
| 44 | + NAMES lib${COMPONENT_NAME} |
38 | 45 | HINTS "${PANDA3D_ROOT}/lib" |
39 | 46 | ) |
40 | | - list(APPEND Panda3d_LIBRARY ${PANDA3D_${COMPONENT_NAME}_LIBRARY}) |
| 47 | + list(APPEND panda3d_LIBRARY ${panda3d_${COMPONENT_NAME}_LIBRARY}) |
41 | 48 | endforeach() |
42 | | -#find_library(Panda3d_LIBRARY_DEBUG |
43 | | -# NAMES ${Panda3d_FIND_COMPONENTS} |
44 | | -# HINTS ${PANDA3D_LIBRARYDIR} |
| 49 | +#find_library(panda3d_LIBRARY_DEBUG |
| 50 | +# NAMES ${panda3d_FIND_COMPONENTS} |
| 51 | +# HINTS ${panda3d_LIBRARYDIR} |
45 | 52 | # PATH_SUFFIXES lib64 lib |
46 | 53 | #) |
47 | 54 |
|
48 | | -# Set Panda3d_FOUND |
| 55 | +# Set panda3d_FOUND |
49 | 56 | include(FindPackageHandleStandardArgs) |
50 | | -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Panda3d |
51 | | - FOUND_VAR Panda3d_FOUND |
52 | | - REQUIRED_VARS Panda3d_LIBRARY Panda3d_INCLUDE_DIR |
53 | | - VERSION_VAR Panda3d_VERSION |
| 57 | +FIND_PACKAGE_HANDLE_STANDARD_ARGS(panda3d |
| 58 | + FOUND_VAR panda3d_FOUND |
| 59 | + REQUIRED_VARS panda3d_LIBRARY panda3d_INCLUDE_DIR |
| 60 | + VERSION_VAR panda3d_VERSION |
54 | 61 | ) |
55 | 62 |
|
56 | | -if(Panda3d_FOUND) |
57 | | - message(STATUS "Found the following Panda3D libraries:") |
58 | | - foreach(COMPONENT ${Panda3d_FIND_COMPONENTS}) |
| 63 | +if(panda3d_FOUND) |
| 64 | + message(STATUS "Found the following panda3d libraries:") |
| 65 | + foreach(COMPONENT ${panda3d_FIND_COMPONENTS}) |
59 | 66 | message (STATUS " ${COMPONENT}") |
60 | 67 | endforeach() |
61 | 68 |
|
62 | | - # found both |
63 | | - if(Panda3d_LIBRARY AND Panda3d_LIBRARY_DEBUG) |
64 | | - set(Panda3d_LIBRARIES |
65 | | - optimized ${Panda3d_LIBRARY} |
66 | | - debug ${Panda3d_LIBRARY_DEBUG}) |
67 | | - # found only release |
68 | | - elseif(Panda3d_LIBRARY) |
69 | | - set(Panda3d_LIBRARIES ${Panda3d_LIBRARY}) |
70 | | - # found only debug |
71 | | - elseif(Panda3d_LIBRARY_DEBUG) |
72 | | - set(Panda3d_LIBRARIES ${Panda3d_LIBRARY_DEBUG}) |
| 69 | + # create targets of found components |
| 70 | + foreach(COMPONENT_NAME ${panda3d_FIND_COMPONENTS}) |
| 71 | + if(NOT TARGET panda3d::${COMPONENT_NAME}) |
| 72 | + add_library(panda3d::${COMPONENT_NAME} UNKNOWN IMPORTED) |
| 73 | + set_target_properties(panda3d::${COMPONENT_NAME} PROPERTIES |
| 74 | + INTERFACE_INCLUDE_DIRECTORIES "${panda3d_INCLUDE_DIR}" |
| 75 | + IMPORTED_LOCATION "${panda3d_${COMPONENT_NAME}_LIBRARY}" |
| 76 | + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" |
| 77 | + ) |
| 78 | + endif() |
| 79 | + endforeach() |
| 80 | + |
| 81 | + # create default target |
| 82 | + if(NOT TARGET panda3d::panda3d) |
| 83 | + add_library(panda3d::panda3d INTERFACE IMPORTED) |
| 84 | + |
| 85 | + foreach(COMPONENT_NAME ${panda3d_DEFAULT_COMPONENTS}) |
| 86 | + list(APPEND _panda3d_DEFAULT_TARGET_DEPENDENCIES panda3d::${COMPONENT_NAME}) |
| 87 | + endforeach() |
| 88 | + |
| 89 | + set_target_properties(panda3d::panda3d PROPERTIES |
| 90 | + INTERFACE_INCLUDE_DIRECTORIES "${panda3d_INCLUDE_DIR}" |
| 91 | + INTERFACE_LINK_LIBRARIES "${_panda3d_DEFAULT_TARGET_DEPENDENCIES}" |
| 92 | + ) |
73 | 93 | endif() |
74 | | - set(Panda3d_INCLUDE_DIRS ${Panda3d_INCLUDE_DIR}) |
75 | 94 | endif() |
76 | | - |
77 | | -mark_as_advanced( |
78 | | - Panda3d_INCLUDE_DIRS |
79 | | - Panda3d_LIBRARIES |
80 | | -) |
|
0 commit comments