Edit custom path with OpenCV framework using CMake to generate XCODE project in iOS - ios

I have a cross-platform build system using CMake, and I have OpenCV dependency for iOS.
Setting ${OpenCV_DIR} manually, my project compile and execute correctly if and only if I set manually every time I generate XCODE project variable Project > Build Settings > Framework Search Paths with ${OpenCV_DIR}.
How can I set this variable using CMake directly?

CMake has no full integration with XCode. You can generate a project using it but a lot of things fails. Just drag into your project OpenCV and it will be detected.

Related

Build Libraries for Distribution” into ”Yes” Swift

In my project I have enabled the Build Libraries for Distribution” into ”Yes” into my SDK build setting, to prevent swift upgrades from causing a problem for third party libraries. In this case, When I Build with the project for SDK, I have set legacy mode but I am facing issue like below:


The legacy does not support Build Libraries for Distribution” into ”Yes”.
How to fix this? I can able to build the project new build system instead of legacy mode
The reason for setting legacy mode is When I set a new build system and prepare to build I am getting this below error. To fix this I am using legacy mode
Multiple commands produce '/Path/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework':
1) Target 'GoogleUtilities-00567490' has create directory command with output '/Path//IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
2) Target 'GoogleUtilities-54e75ca4' has create directory command with output '/Path//IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
The workaround for this build system issue is to explicitly add all the needed GoogleUtilities subspecs to the Podfile. See the Podfile.lock file to get the list. Full details at https://github.com/firebase/firebase-ios-sdk/issues/4087

Qt application build for ios using cmake and xcode

I have a Qt application which I can build and run with 2 differents ways, the application works properly on my Mac.
I can run from QtCreator using qbs files.
I can run from Xcode using a .xcodeproject generated by cmake.
Now I want to run my application on an Ipad.
I try from QtCreator but the signing is not working properly (bundle id)
I think i need to use Xcode for the Info.plist generation and let him do the work for selecting the appropriate compiller but i don't know how to add a new "target device".
I open my XcodeProject but my Ipad is not showing on the device pannel next to the run Button.
When I go on the settings i need to tell him where to find the info.plist but when I hit the "find plist file" i got none. Should I create it in my application folder or use some cmake method ?
Last things my project is using different libraries, i compile them for ios using the appropriate CC and CXX flags.
Where should I specify the location folder for thoose libraries.
inside the CMakeList with something like this or create a new CMakeList file just for the ios build ?
if(WIN32)
elseif(APPLE) #ios flags ???
endif()

Yocto SDK with cmake toolchain file

I provide a Yocto SDK to cross-build an application for an embedded target. The application itself is built using CMake. The SDK setup script provides many necessary environment variables (like location of the cross-compiler, sysroot, etc.), which so far was enough to build the application.
However, since recently the application has a dependency to the Boost library (through the command find_package(Boost REQUIRED) in the CMakeLists.txt). Now CMake complains that it cannot find the library, even though it's installed in the SDK sysroot. But if I build the application directly in Yocto, it works fine.
After some research it turned out that Yocto generates a toolchain.cmake file which is added to the cmake call. In this file, the variable CMAKE_FIND_ROOT_PATH is set, which CMake needs to find libraries. Using such a toolchain file, I can also build using the SDK.
Now I'm wondering if Yocto provides any mechanism to export such a toolchain file with the SDK. Or alternatively if the SDK provides a script or something to automatically create a toolchain file directly on the SDK build host.
Or shall I just tell the users of the SDK to manually create a toolchain file and add it to their cmake call?
Assuming that you're using the image based SDK, i.e. building it with bitbake <image> -c populate_sdk, adding the following toimage.bb should fix it:
TOOLCHAIN_HOST_TASK += "nativesdk-cmake"
That should give you a OEToolchainConfig.cmake file in the SDK. After sourcing the SDK environment file, cmake will be an alias to cmake -DCMAKE_TOOLCHAIN_FILE=$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake to further help your developers.
I'd like to add to Anders answer that while it worked great for me to add nativesdk-cmake this way it did not work when I tried to add nativesdk-python3-numpy. After some googling I found this, suggesting that TOOLCHAIN_HOST_TASK has to be extended using _append instead of +=.

Build iOS app using Terminal

Is there a way to create a iOS without the Xcode IDE, and instead using Terminal and a Text Editor (like Atom)?
With Linux, i can accomplish this to build an Android app using Maven to create the minimum directory structure, compile the files after add them (in the Atom editor), create the APK and upload the package to the device.
Is there any command-line utility to accomplish some of this tasks in MacOSX?
You can use the xcodebuild command line tool to build, but there is no apple-provided tool to generate the project files other than Xcode. Google does have a tool called gyp which can generate the project files, though I'm not certain your use case is what it was designed for.
Other than that you pretty much have to hold your nose and use Xcode to setup your project, add files, change build settings, etc, and use whatever editor you want to actually edit the code.

how to build DLIB for iOS

I'm trying to build DLIB for an iOS project. Running the cmake results in a libdlib.a and a load of .o files.
When I add the library to an Xcode project I get warning that the library hasn't been built for arm64.
My question is two-part:
How can I build DLIB for iOS (I tried cmake **path_to_source** -DCMAKE_OSX_ARCHITECTURE="arm64" but it caused loads of errors e.g. unknown type name '__uint32_t'; did you mean '__uint128_t')?
What is the purpose of all the .o files that get built when you run cmake? Do I need to include them in an Xcode project?
I finally figured out how to do this:
Requirements
X11 (on a mac you can just open the X11 app and if X11 isn't installed it'll take you to the download).
Xcode
cmake (you can use home-brew for that)
Steps
In terminal make the lib-xx.xx/examples your root
Run:
mkdir build
cd build
cmake -G Xcode ..
cmake --build . --config Release
This will create a folder called dlib_build in which you can find an Xcode project that compiles the library. In the build settings of that Xcode project you can set the build architecture and SDK for any Xcode supported OS you like!
EDIT:
You have to include a lot of custom compiler flags and 3rd party libraries to get dlib to work in a project. Check out the examples.xcproject build settings.
To compliment RASS's answer, I am attaching screenshots showing how to change this to and from an iOS and OSX lib
After opening the project,
Select the project file from the project navigator
Select the dlib target all the way down the bottom
Select 'Build Settings'
Expand 'Base SDK' drop down
Select either iOS or macOS (OSX)
I hope this helps some people out! gl
Rob Sanders and mylogon already show how to build dlib for ios, here is how to use it:
add libdlib.a to project, and add path to library search paths
add all source to include directory(do not add to project), and add path to header search paths.
add accelerate framework, which contains blas symbols.
add preprocessor macros, from building settings, "custom compiler flag"/"other c flags". these macros make sure the header files match the lib.
-DDLIB_JPEG_SUPPORT
-DDLIB_NO_GUI_SUPPORT
-DNDEBUG
-DDLIB_USE_BLAS
-DDLIB_USE_LAPACK

Resources