Fix building the iOS framework after I dropped the VERSION macro.
authorRoman Donchenko <roman.donchenko@itseez.com>
Tue, 6 Aug 2013 14:56:36 +0000 (18:56 +0400)
committerRoman Donchenko <roman.donchenko@itseez.com>
Tue, 6 Aug 2013 14:56:36 +0000 (18:56 +0400)
This version uses CMake to generate Info.plist, which should be more
reliable than the old approach.

CMakeLists.txt
cmake/OpenCVGenInfoPlist.cmake [new file with mode: 0644]
platforms/ios/Info.plist.in
platforms/ios/build_framework.py

index 46881c4..2ddbd84 100644 (file)
@@ -497,6 +497,8 @@ include(cmake/OpenCVGenAndroidMK.cmake)
 # Generate OpenCVŠ”onfig.cmake and OpenCVConfig-version.cmake for cmake projects
 include(cmake/OpenCVGenConfig.cmake)
 
+# Generate Info.plist for the IOS framework
+include(cmake/OpenCVGenInfoPlist.cmake)
 
 # ----------------------------------------------------------------------------
 # Summary:
@@ -891,4 +893,3 @@ ocv_finalize_status()
 if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
   message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree")
 endif()
-
diff --git a/cmake/OpenCVGenInfoPlist.cmake b/cmake/OpenCVGenInfoPlist.cmake
new file mode 100644 (file)
index 0000000..97c674c
--- /dev/null
@@ -0,0 +1,4 @@
+if(IOS)
+  configure_file("${OpenCV_SOURCE_DIR}/platforms/ios/Info.plist.in"
+                 "${CMAKE_BINARY_DIR}/ios/Info.plist")
+endif()
index 6bcfe86..b2a3baf 100644 (file)
@@ -7,9 +7,9 @@
     <key>CFBundleIdentifier</key>
     <string>org.opencv</string>
     <key>CFBundleVersion</key>
-    <string>${VERSION}</string>
+    <string>${OPENCV_LIBVERSION}</string>
     <key>CFBundleShortVersionString</key>
-    <string>${VERSION}</string>
+    <string>${OPENCV_LIBVERSION}</string>
     <key>CFBundleSignature</key>
     <string>????</string>
     <key>CFBundlePackageType</key>
index bc385bb..23da296 100755 (executable)
@@ -71,15 +71,6 @@ def put_framework_together(srcroot, dstroot):
     os.makedirs(framework_dir)
     os.chdir(framework_dir)
 
-    # determine OpenCV version (without subminor part)
-    tdir0 = "../build/" + targetlist[0]
-    cfg = open(tdir0 + "/cvconfig.h", "rt")
-    for l in cfg.readlines():
-        if l.startswith("#define  VERSION"):
-            opencv_version = l[l.find("\"")+1:l.rfind(".")]
-            break
-    cfg.close()
-
     # form the directory tree
     dstdir = "Versions/A"
     os.makedirs(dstdir + "/Resources")
@@ -91,13 +82,8 @@ def put_framework_together(srcroot, dstroot):
     wlist = " ".join(["../build/" + t + "/lib/Release/libopencv_world.a" for t in targetlist])
     os.system("lipo -create " + wlist + " -o " + dstdir + "/opencv2")
 
-    # form Info.plist
-    srcfile = open(srcroot + "/platforms/ios/Info.plist.in", "rt")
-    dstfile = open(dstdir + "/Resources/Info.plist", "wt")
-    for l in srcfile.readlines():
-        dstfile.write(l.replace("${VERSION}", opencv_version))
-    srcfile.close()
-    dstfile.close()
+    # copy Info.plist
+    shutil.copyfile("../build/ios/Info.plist", dstdir + "/Resources/Info.plist")
 
     # make symbolic links
     os.symlink("A", "Versions/Current")