How to prepend CMAKE_INSTALL_PREFIX when its provided at build-time? - path

I have a few libraries that I build in succession. Some depend on others. For example:
libfoo.so depends on libbar.so
And, I don't want to have to deploy these things system-wide on the build machine. In my cmake file I have something like the following:
find_library(FOO_LIB foo /usr/lib64 /usr/lib /usr/local/lib)
On the build machine I normally give it a CMAKE_INSTALL_PREFIX flag at compile-time. Is there a way to do something like this:
find_library(FOO_LIB foo ${CMAKE_INSTALL_PREFIX}/lib /usr/lib64 /usr/lib /usr/local/lib)
if the flag is provided, but use the first version if it isn't provided?
please forgive my noobish-ness with respect to cmake
[clarification] Each library is built by a separate CMakeLists.txt file.

If you have one cmake-project which include other cmake-projects (with your libraries and applications), you can use target names to link libraries: target_link_libraries(app foo bar)
If you build your libraries cmake project separately - it's not good way, I think, but you still have two options:
deploy your libraries before build app;
put already built libraries to third_party catalog and find it them (e.g. writing specific FindXXXX.cmake file which try to locate your libraries in third_party catalog first).

Related

Cyclic dependency error J2OBJC archive build?

I am having cyclic dependency issues with my Ionic/iOS project using J2OBJC as a internal Xcode settings built in.
I've set my build rules and settings in my ionic project as stated in the J2OBJC documentations. I have added the Library, User Header and framework search paths as required (firstly only app target, and also tried it with both app target and workspace) and created user defined $J2OBJC_HOME and (this probably isn't part of the requirements) I added a $PROJECT_DIR too. I also added the java build rule as such
"if [ ! -f "${J2OBJC_HOME}/j2objc" ]; then echo "J2OBJC_HOME not
correctly defined in Settings.xcconfig, currently set to
'${J2OBJC_HOME}'"; exit 1; fi; "${J2OBJC_HOME}/j2objc" -d
${DERIVED_FILE_DIR} -sourcepath "${PROJECT_DIR}/App"
--no-package-directories -use-arc --prefix Flowers=JOE -g ${INPUT_FILE_PATH};"
I have build both simulator and iPhone and ran them on both and they seem to be working. However, when I go to archive (so I can create the .ipa) for the project. I get a cyclic dependency error. I have tried numerous things, such as, fresh start of project, using different URLs for the search paths, using recursive and non-recursive, checked the documentations a few times, looked at forums and still have no solution. Any ideas would be greatly appreciated!
Xcode can no longer handle the same header search path in Header Search Paths and User Header Search Paths. You probably have "$(J2OBJC_HOME)/include" in both of these. So remove it from Header Search Paths and leave it in User Header Search Paths.
I've had this cyclic dependency issue for a good month and a half. I've tried almost everything.
I've looked everywhere.. and got 2 replies from Tom Ball. When it comes to a big project converted from java to Objc using the tool, xcode won't recognize the sub-directories made. I figured out the best fix is to create your own script using bash. I did some research and figured out how to recursively find all java files and apply the j2objc script to them and it will output all of your Objc files in the same directory layout. (Keeping a nice layout for you instead of the messy-everything-in-one folder like j2objc script rule on Xcode works).
My build.sh file is as follows, feel free to copy it-
!/bin/bash
Clean out Objective C folder
rm -rf /ObjC_Output
Move into Java Folder
cd Java
Run j2objc and output everything into ObjC
j2objc -d ../ObjC_Output $(find . -name "*.java")
Jump out of Java folder
cd ..
Delete previous org
rm -rf /Users/me/Projects/project-name/mobile-app-front-end/app/ios/app/app/org
cd to ObjC_Output
Copy new ObjC Project files over to the XCode project..
cp -R ./ObjC_Output/* /Users/me/Projects/project-name/mobile-app-front-end/app/ios/app/app/org
I automatically copy all my files back to my Xcode project.. feel free to do it anyway you want. Also don't forget to add j2objc to your path. and run your script as such ./builder.sh in terminal..
Also for Xcode to recognize your objC project folder you must add the top directory of your Xcode project and make it recursive.
In this case, you don't need to include the j2objc script in Xcode.. Just make sure you include all the default Linker paths, Library search paths and User Header search path as usual (shown in the j2objc documentation).
I've had to pull my hair out for this solution.. So feel free to ask for help if needed.

change macports installation makefile

how can I change the cmake file provided with the package? I am having troubles with OpenCV and found one possible solution:
So you can edit cmake/OpenCVDetectionVTK.cmake.
At line 6, change "vtkRenderingOpenGL" to "vtkRenderingOpenGL2".
But where do I change that if I am using port install?
If you look on directory up (out of directory build whether you create it) you will see the "cmake/"
Mine is look like this:
3rdparty CONTRIBUTING.md README.md build data include platforms
CMakeLists.txt LICENSE apps cmake doc modules samples
Open cmake then you will find it.
I hope this help you.

How to include a own libary into the toolchain(SDK) for an embeeded Linux generated by Yocto?

I am looking for an example where is shown how to include an own library into the toolchain.
Let's call the library "myLib". For it I created an recipe "myLib.bb" and added:
BBCLASSEXTEND = "native nativesdk"
In my "local.conf" I added:
IMAGE_INSTALL_append = " myLib"
When building the SDK by:
$ bitbake myTarget -c populate_sdk
It produces a installer for the SDK and two manifest files. "myLib" is only included at the target manifest and not on the host. How can I include myLib on the host system?
The idea is, that a other person can build software on his system without the Yocto system. Only by using the toolchain he can generate binaries, which can be transferred and executed at the evalboard.
As long as your library myLib is installed into the image, it's supposed to be part of your generated SDK. Which you also say that it is, at least as part of the target manifest.
Ensure that you install the required header files for your library, then you should be able to cross-compile against your library.
Do you need to use myLib on the developers build machine? Otherwise, why do you want to have it added to the nativeskd part? (I.e. the host manifest). This is for applications that needs to run on the host machine, i.e. the cross-compiler, code generators etc.

How do I compile libffi for iOS & macOS?

I'm trying to use libffi in one of my projects, but I can't seem to compile for iOS (or macOS, for that matter). Here is one of the various errors I've encountered while building for the iOS Simulator:
bash: src/arm/gentramp.sh: No such file or directory
Update 1: Since the question remains unanswered, I've decided to open an issue at the official repository as well.
Update 2: Question has been answered and the issue has been closed!
If you check the repository you will see that the file you require was deleted in this commit. You can find the last version of this file here.
generate-darwin-source-and-headers.py and the libffi.xcodeproj need to be updated to include all currently relevant source files.
The gentramp.sh script is not needed anymore and the current upstream xcodeproj is not up to date either with compilation settings and to be included source files for 64-bit on iOS. A patched fork can be found at https://github.com/ksjogo/libffi
sh autogen.sh
python generate-darwin-source-and-headers.py --only-ios
open libffi.xcodeproj
select scheme libffi-iOS and device Generic iOS Device
click "Product - Build"
If success, you would see a "Product/libffi.a" in the side bar, you can right click it to get the lib in the finder.
Please make sure you are following the installing libffi instructions released on the TBD or git project: https://github.com/libffi/libffi
Here some of the main Highlights:
First you must configure the distribution for your particular
system. Go to the directory you wish to build libffi in and run the
"configure" program found in the root directory of the libffi source
distribution.
If you're building libffi directly from version control, configure won't
exist yet; run ./autogen.sh first.
You may want to tell configure where to install the libffi library and
header files. To do that, use the --prefix configure switch. Libffi
will install under /usr/local by default.
If you want to enable extra run-time debugging checks use the the
--enable-debug configure switch. This is useful when your program dies
mysteriously while using libffi.
Another useful configure switch is --enable-purify-safety. Using this
will add some extra code which will suppress certain warnings when you
are using Purify with libffi. Only use this switch when using
Purify, as it will slow down the library.
For iOS builds, the 'libffi.xcodeproj' Xcode project is available.
Configure has many other options. Use "configure --help" to see them all.
Once configure has finished, type "make". Note that you must be using
GNU make. You can ftp GNU make from ftp.gnu.org:/pub/gnu/make .
To ensure that libffi is working as advertised, type "make check".
This will require that you have DejaGNU installed.
To install the library and header files, type "make install".
Alternatively, try merging one of the following git projects to your project in order to include the missing files. Please make sure the files are not outdated before merging.
1 https://github.com/pandamonia/libffi-iOS
2 https://github.com/influitive/libffi-iOS
3 https://github.com/landonf/libffi-ios

run configure to generate shared libraries [Ubuntu]

I'm running a ./configure script and make to build a library. However, only .a libraries are generated. Is there an option to generate shared libs?
It's going to depend on the project you're trying to build. Run
./configure --help
to get a list of all options you can pass to ./configure, there may be a --shared option or something similar.

Resources