File: FindPylon.cmake

package info (click to toggle)
visp 3.7.0-7
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 166,380 kB
  • sloc: cpp: 392,705; ansic: 224,448; xml: 23,444; python: 13,701; java: 4,792; sh: 206; objc: 145; makefile: 118
file content (165 lines) | stat: -rw-r--r-- 5,835 bytes parent folder | download | duplicates (3)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#############################################################################
#
# ViSP, open source Visual Servoing Platform software.
# Copyright (C) 2005 - 2025 by Inria. All rights reserved.
#
# This software is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# See the file LICENSE.txt at the root directory of this source
# distribution for additional information about the GNU GPL.
#
# For using ViSP with software that can not be combined with the GNU
# GPL, please contact Inria about acquiring a ViSP Professional
# Edition License.
#
# See https://visp.inria.fr for more information.
#
# This software was developed at:
# Inria Rennes - Bretagne Atlantique
# Campus Universitaire de Beaulieu
# 35042 Rennes Cedex
# France
#
# If you have questions regarding the use of this file, please contact
# Inria at visp@inria.fr
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# Description:
# Try to find Basler Pylon library API
#
# PYLON_FOUND
# PYLON_INCLUDE_DIRS
# PYLON_LIBRARIES
# PYLON_VERSION
#
#
#############################################################################

if(APPLE)
  find_path(PYLON_INCLUDE_DIR pylon/PylonIncludes.h)
  find_path(PYLON_BASE_INCLUDE_DIR
    NAMES Base/GCTypes.h
    HINTS ${PYLON_INCLUDE_DIR}/Headers
    PATH_SUFFIXES GenICam)

  find_library(PYLON_LIBRARIES pylon)

  find_program(PYLON_CONFIG pylon-config
               HINTS ${PYLON_INCLUDE_DIR}
               PATH_SUFFIXES Versions/A/Resources/Tools)

  if(PYLON_INCLUDE_DIR)
    list(APPEND PYLON_INCLUDE_DIRS ${PYLON_INCLUDE_DIR})
  endif()
  if(PYLON_BASE_INCLUDE_DIR)
    list(APPEND PYLON_INCLUDE_DIRS ${PYLON_BASE_INCLUDE_DIR})
  endif()

  if(PYLON_CONFIG)
    execute_process(COMMAND ${PYLON_CONFIG} "--version"
                    OUTPUT_VARIABLE PYLON_VERSION_TMP
                    OUTPUT_STRIP_TRAILING_WHITESPACE)
    string(REPLACE "-n" "" PYLON_VERSION ${PYLON_VERSION_TMP})
    string(STRIP ${PYLON_VERSION} PYLON_VERSION)
  endif()

  if(PYLON_INCLUDE_DIRS AND PYLON_LIBRARIES)
    set(PYLON_FOUND TRUE)
  endif()

  mark_as_advanced(PYLON_BASE_INCLUDE_DIR)
elseif(MSVC)
  find_path(PYLON_INCLUDE_DIR pylon/PylonIncludes.h
    PATHS "$ENV{PYLON_HOME}/include"
        "C:/Program Files/Basler/pylon 5/Development/include"
        "C:/Program Files/Basler/pylon 6/Development/include")

  set(PYLON_LIB_SEARCH_PATH "$ENV{PYLON_HOME}/lib/x64")

  if(CMAKE_CL_64)
    list(APPEND PYLON_LIB_SEARCH_PATH "C:/Program Files/Basler/pylon 5/Development/lib/x64")
    list(APPEND PYLON_LIB_SEARCH_PATH "C:/Program Files/Basler/pylon 6/Development/lib/x64")
  else()
    list(APPEND PYLON_LIB_SEARCH_PATH "C:/Program Files/Basler/pylon 5/Development/lib/Win32")
    list(APPEND PYLON_LIB_SEARCH_PATH "C:/Program Files/Basler/pylon 6/Development/lib/Win32")
  endif()

  find_library(PYLON_BASE_LIBRARY
    NAMES PylonBase_v6_1.lib PylonBase_v5_1.lib PylonBase_MD_VC120_v5_0.lib
    PATHS ${PYLON_LIB_SEARCH_PATH})
  find_library(PYLON_GCBASE_LIBRARY
    NAMES GCBase_MD_VC141_v3_1_Basler_pylon.lib GCBase_MD_VC141_v3_1_Basler_pylon_v5_1.lib GCBase_MD_VC120_v3_0_Basler_pylon_v5_0.lib
    PATHS ${PYLON_LIB_SEARCH_PATH})
  find_library(PYLON_GENAPI_LIBRARY
    NAMES GenApi_MD_VC141_v3_1_Basler_pylon.lib GenApi_MD_VC141_v3_1_Basler_pylon_v5_1.lib GenApi_MD_VC120_v3_0_Basler_pylon_v5_0.lib
    PATHS ${PYLON_LIB_SEARCH_PATH})
  find_library(PYLON_UTILITY_LIBRARY
    NAMES PylonUtility_v6_1.lib PylonUtility_v5_1.lib PylonUtility_MD_VC120_v5_0.lib
    PATHS ${PYLON_LIB_SEARCH_PATH})

  if(PYLON_INCLUDE_DIR)
    list(APPEND PYLON_INCLUDE_DIRS ${PYLON_INCLUDE_DIR})
  endif()
  if(PYLON_BASE_LIBRARY AND PYLON_GCBASE_LIBRARY)
    list(APPEND PYLON_LIBRARIES ${PYLON_BASE_LIBRARY})
    list(APPEND PYLON_LIBRARIES ${PYLON_GCBASE_LIBRARY})
    list(APPEND PYLON_LIBRARIES ${PYLON_GENAPI_LIBRARY})
    list(APPEND PYLON_LIBRARIES ${PYLON_UTILITY_LIBRARY})
  endif()

  if(PYLON_INCLUDE_DIRS AND PYLON_LIBRARIES)
    vp_parse_header("${PYLON_INCLUDE_DIR}/pylon/PylonVersionNumber.h" PYLON_VERSION_LINES PYLON_VERSION_MAJOR PYLON_VERSION_MINOR PYLON_VERSION_SUBMINOR)
    set(PYLON_VERSION "${PYLON_VERSION_MAJOR}.${PYLON_VERSION_MINOR}.${PYLON_VERSION_SUBMINOR}")
    string(STRIP ${PYLON_VERSION} PYLON_VERSION)
    set(PYLON_FOUND TRUE)
  endif()

  mark_as_advanced(
    PYLON_BASE_LIBRARY
    PYLON_GCBASE_LIBRARY
    PYLON_GENAPI_LIBRARY
    PYLON_UTILITY_LIBRARY
  )

elseif(UNIX)
  set(PYLON_ROOT_SEARCH_PATH
    /opt/pylon5
    /opt/pylon
  )

  # For more possible versions, just add more paths below.
  # list(APPEND PYLON_ROOT_SEARCH_PATH "/somepath/include")

  find_program(PYLON_CONFIG pylon-config
               PATHS ${PYLON_ROOT}
               PATHS $ENV{PYLON_ROOT}
               PATHS ${PYLON_ROOT_SEARCH_PATH}
               PATH_SUFFIXES bin)

  if(PYLON_CONFIG)
    execute_process(COMMAND ${PYLON_CONFIG} "--version"
                    OUTPUT_VARIABLE PYLON_VERSION
                    OUTPUT_STRIP_TRAILING_WHITESPACE)
    string(STRIP ${PYLON_VERSION} PYLON_VERSION)
    execute_process(COMMAND ${PYLON_CONFIG} "--libs" "--libs-rpath"
                    OUTPUT_VARIABLE PYLON_LIBRARIES
                    OUTPUT_STRIP_TRAILING_WHITESPACE)
    execute_process(COMMAND ${PYLON_CONFIG} "--cflags-only-I"
                    OUTPUT_VARIABLE PYLON_INC_TMP
                    OUTPUT_STRIP_TRAILING_WHITESPACE)
    string(REPLACE "-I" "" PYLON_INCLUDE_DIRS ${PYLON_INC_TMP})

    set(PYLON_FOUND TRUE)
  endif()
endif()

mark_as_advanced(
  PYLON_INCLUDE_DIR
  PYLON_INCLUDE_DIRS
  PYLON_LIBRARIES
  PYLON_CONFIG
)