Opened 9 years ago

Last modified 3 years ago

#48288 assigned defect

CMake generating broken Xcode projects when using OpenCV — at Initial Version

Reported by: christian.richardt@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 2.3.3
Keywords: Cc:
Port: opencv cmake

Description

I use OpenCV in projects for which I create Xcode projects using CMake. I found some issues in OpenCV configuration files that cause CMake to create invalid Xcode projects (error: "Project … cannot be opened because the project file cannot be parsed.")

I'm using

  • opencv @3.0.0_0+eigen+opencl+openni+python27+qt4+tbb+vtk
  • cmake @3.2.3_0+docs+gui+python27+qt4

I think that one or more of these OpenCV variants might trigger this bug, but it could also be a bug in OpenCV rather than its MacPort. However, as I've not found anyone else complaining about it online, I assume it's a MacPort-specific issue.

Essentially, the string "/ /System/Library/Frameworks" (two leading slashes without space) somehow ends up in /opt/local/lib/pkgconfig/opencv.pc:

[...]
Libs.private: -l-framework OpenCL -L/opt/local/lib [...] -ltbb -ltbbmalloc -L//System/Library/Frameworks -lAGL -lOpenGL
[...]

and in /opt/local/share/OpenCV/OpenCVModules-release.cmake:

[...]
set_target_properties(opencv_hal PROPERTIES
  IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
  IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "-ltbb -ltbbmalloc;//System/Library/Frameworks/AGL.framework;//System/Library/Frameworks/OpenGL.framework"
  IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libopencv_hal.a"
  )
[...]
set_target_properties(opencv_ts PROPERTIES
  IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
  IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "opencv_hal;opencv_core;opencv_imgproc;opencv_imgcodecs;opencv_videoio;opencv_highgui;-ltbb -ltbbmalloc;//System/Library/Frameworks/AGL.framework;//System/Library/Frameworks/OpenGL.framework"
  IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libopencv_ts.a"
  )
[...]

In a CMake project that uses OpenCV, any Xcode project created for it will contain the following line in "Project.xcodeproj/project.pbxproj":

FRAMEWORK_SEARCH_PATHS = (//System/Library/Frameworks, );

which prevents Xcode from opening the generated project as it cannot be parsed.

Removing the "FRAMEWORK_SEARCH_PATHS" lines manually from "project.pbxproj" fixes the parsing error and the Xcode project can be opened as expected.

Replacing the double leading slash in the two files mentioned above with a single slash, and re-running CMake, prevents the FRAMEWORK_SEARCH_PATHS lines from appearing in the first place, and Xcode projects work fine.

This leads me to believe that the double slash should be replaced with a single slash, when /opt/local/lib/pkgconfig/opencv.pc and /opt/local/share/OpenCV/OpenCVModules-release.cmake are generated.

Change History (0)

Note: See TracTickets for help on using tickets.