I was recently working with Intel OpenCL for the intel Atom E3940. One of the thing I found was the lack of and in some cases inconsistency of documentation on how to build and cross compile OpenCL. One of thing which we had to end up with is to compile the OpenCL source on the target itself as the cross compilation was giving much more trouble due to lack of instructions on how to do it. Unfortunately, the time it takes build the OpenCL software is humongous. So once you have finished building the source code on the target, you do not want to go through that cycle again. What you really want is to keep the build folder save in a local PC and upload it to the target machine, and just be able to install it on the target. But with cmake 2.1 and above if you just upload the build folder and just do “make install” again, the make systems starts building the source file once again unless you specify the right flag in the cmake prompt. Here is how to do it:
I will write a separate blog on how to compile the OpenCL. So I am not going to explain it here. My only emphasis here is the cmake flag which save the recompilation of the whole source code again, it might sound little thing but it is extremely useful.
Let’s say on the target, you have build the IGC (Intel Graphics Compiler) as below:
mkdir build_igc (build folder for the IGC source code)
make -j `nproc` package
Now, that is the usual way of building the IGC source and installing it. However, one I have achieved it, I would not like to build the source again (as mentioned earlier due to the amount of time it takes to build). What I want is to preserve this build_igc folder in a backup storage and whenever I need the IGC to be installed on the target, copy the previously preserved build_igc folder and just install it (as my source code didn’t change, I do not want to build it all over again). With the above cmake configuration, if you try to do a “make install” it will start building it again. To avoid the building we have two cmake flags,
CMAKE_SKIP_RULE_DEPENDENCY and CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.
If you use the CMAKE_SKIP_RULE_DEPENDENCY flag, the make command will not build the already built binaries whereas, CMAKE_SKIP_INSTALL_ALL_DEPENDENCY will restrict the “make install” command (cmake 2.1 and above) to rebuild the binaries once again.
So, ideally you should configure your cmake as below,
cmake -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=true -DCMAKE_SKIP_RULE_DEPENDENCY=true ../igc/IGC/
make -j `nproc` package
Hope this helps.