Skip to content

Commit fe45772

Browse files
committed
tryfix macos
1 parent 6909a85 commit fe45772

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

CMakeLists.txt

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ list(APPEND CMAKE_PREFIX_PATH $ENV{PYLON_ROOT})
9191
# for Windows system. All other OS PYLON_DEV_DIR will be empty
9292
list(APPEND CMAKE_PREFIX_PATH $ENV{PYLON_DEV_DIR})
9393

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+
94100
# For Windows, set pylon_DIR directly to where the CMake config files are located
95101
if(WIN32 AND DEFINED ENV{PYLON_DEV_DIR})
96102
set(pylon_DIR "$ENV{PYLON_DEV_DIR}/CMake/pylon")
@@ -102,6 +108,20 @@ find_package(pylon REQUIRED)
102108

103109
message(STATUS "Found pylon: ${pylon_DIR}")
104110

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+
105125
# Display pylon version info if available
106126
if(DEFINED pylon_VERSION)
107127
message(STATUS "pylon version: ${pylon_VERSION}")
@@ -216,13 +236,15 @@ set(CMAKE_SWIG_FLAGS
216236
)
217237

218238
# Platform-specific SWIG flags
219-
if(UNIX AND NOT APPLE)
239+
if(UNIX)
220240
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
221241
list(APPEND CMAKE_SWIG_FLAGS -DSWIGWORDSIZE64)
222242
else()
223243
list(APPEND CMAKE_SWIG_FLAGS -DSWIGWORDSIZE32)
224244
endif()
225-
elseif(WIN32)
245+
endif()
246+
247+
if(WIN32)
226248
# Also define _WIN32 for the genicam.i file
227249
list(APPEND CMAKE_SWIG_FLAGS -D_WIN32)
228250
endif()
@@ -269,6 +291,17 @@ function(add_swig_python_module module_name swig_file)
269291
# CRUCIAL: Tell SWIG to use target include directories (requires CMake 3.13+)
270292
set_property(TARGET ${module_name} PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)
271293

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+
272305
# Set rpath for the extension module to find bundled pylon libraries
273306
if(UNIX AND NOT APPLE)
274307
set_target_properties(${module_name} PROPERTIES
@@ -287,6 +320,9 @@ function(add_swig_python_module module_name swig_file)
287320
${CMAKE_BINARY_DIR}/generated
288321
)
289322

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+
290326
# Install the module
291327
install(TARGETS ${module_name} DESTINATION pypylon)
292328

src/genicam/genicam.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ typedef unsigned long long uintmax_t;
193193
/* Exact integral types. */
194194

195195
#if !defined(SWIGWORDSIZE64) && !defined(SWIGWORDSIZE32)
196-
#error "On linux either SWIGWORDSIZE64 or SWIGWORDSIZE32 must be defined on the command line."
196+
#error "On Unix systems (Linux/macOS) either SWIGWORDSIZE64 or SWIGWORDSIZE32 must be defined on the command line."
197197
#endif
198198

199199
/* Signed. */

0 commit comments

Comments
 (0)