@@ -91,6 +91,12 @@ list(APPEND CMAKE_PREFIX_PATH $ENV{PYLON_ROOT})
91
91
# for Windows system. All other OS PYLON_DEV_DIR will be empty
92
92
list (APPEND CMAKE_PREFIX_PATH $ENV{PYLON_DEV_DIR} )
93
93
94
+ # For macOS, handle framework location
95
+ if (APPLE AND DEFINED ENV{PYLON_FRAMEWORK_LOCATION} )
96
+ list (APPEND CMAKE_PREFIX_PATH "$ENV{PYLON_FRAMEWORK_LOCATION} " )
97
+ message (STATUS "Adding PYLON_FRAMEWORK_LOCATION to CMAKE_PREFIX_PATH: $ENV{PYLON_FRAMEWORK_LOCATION} " )
98
+ endif ()
99
+
94
100
# For Windows, set pylon_DIR directly to where the CMake config files are located
95
101
if (WIN32 AND DEFINED ENV{PYLON_DEV_DIR} )
96
102
set (pylon_DIR "$ENV{PYLON_DEV_DIR} /CMake/pylon" )
@@ -102,6 +108,20 @@ find_package(pylon REQUIRED)
102
108
103
109
message (STATUS "Found pylon: ${pylon_DIR} " )
104
110
111
+ # Debug pylon target properties
112
+ if (TARGET pylon::pylon )
113
+ get_target_property (PYLON_INCLUDE_DIRS pylon::pylon INTERFACE_INCLUDE_DIRECTORIES )
114
+ message (STATUS "pylon::pylon INTERFACE_INCLUDE_DIRECTORIES: ${PYLON_INCLUDE_DIRS} " )
115
+
116
+ get_target_property (PYLON_COMPILE_DEFINITIONS pylon::pylon INTERFACE_COMPILE_DEFINITIONS )
117
+ message (STATUS "pylon::pylon INTERFACE_COMPILE_DEFINITIONS: ${PYLON_COMPILE_DEFINITIONS} " )
118
+
119
+ get_target_property (PYLON_LINK_LIBRARIES pylon::pylon INTERFACE_LINK_LIBRARIES )
120
+ message (STATUS "pylon::pylon INTERFACE_LINK_LIBRARIES: ${PYLON_LINK_LIBRARIES} " )
121
+ else ()
122
+ message (WARNING "pylon::pylon target not found" )
123
+ endif ()
124
+
105
125
# Display pylon version info if available
106
126
if (DEFINED pylon_VERSION )
107
127
message (STATUS "pylon version: ${pylon_VERSION} " )
@@ -216,13 +236,15 @@ set(CMAKE_SWIG_FLAGS
216
236
)
217
237
218
238
# Platform-specific SWIG flags
219
- if (UNIX AND NOT APPLE )
239
+ if (UNIX )
220
240
if (CMAKE_SIZEOF_VOID_P EQUAL 8 )
221
241
list (APPEND CMAKE_SWIG_FLAGS -DSWIGWORDSIZE64 )
222
242
else ()
223
243
list (APPEND CMAKE_SWIG_FLAGS -DSWIGWORDSIZE32 )
224
244
endif ()
225
- elseif (WIN32 )
245
+ endif ()
246
+
247
+ if (WIN32 )
226
248
# Also define _WIN32 for the genicam.i file
227
249
list (APPEND CMAKE_SWIG_FLAGS -D_WIN32 )
228
250
endif ()
@@ -269,6 +291,17 @@ function(add_swig_python_module module_name swig_file)
269
291
# CRUCIAL: Tell SWIG to use target include directories (requires CMake 3.13+)
270
292
set_property (TARGET ${module_name} PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE )
271
293
294
+ # For macOS, explicitly add pylon framework include directories to SWIG
295
+ if (APPLE AND TARGET pylon::pylon )
296
+ get_target_property (PYLON_INCLUDE_DIRS pylon::pylon INTERFACE_INCLUDE_DIRECTORIES )
297
+ if (PYLON_INCLUDE_DIRS )
298
+ foreach (INCLUDE_DIR ${PYLON_INCLUDE_DIRS} )
299
+ set_property (SOURCE ${swig_file} APPEND_STRING PROPERTY SWIG_FLAGS " -I${INCLUDE_DIR} " )
300
+ endforeach ()
301
+ message (STATUS "Added pylon include directories to SWIG for ${module_name} : ${PYLON_INCLUDE_DIRS} " )
302
+ endif ()
303
+ endif ()
304
+
272
305
# Set rpath for the extension module to find bundled pylon libraries
273
306
if (UNIX AND NOT APPLE )
274
307
set_target_properties (${module_name} PROPERTIES
@@ -287,6 +320,9 @@ function(add_swig_python_module module_name swig_file)
287
320
${CMAKE_BINARY_DIR} /generated
288
321
)
289
322
323
+ # The pylon target should provide its own include directories
324
+ # No need to add them manually as they're handled by the pylon::pylon target
325
+
290
326
# Install the module
291
327
install (TARGETS ${module_name} DESTINATION pypylon )
292
328
0 commit comments