CMakeLists and packaging files for automatic Edje file compilation in project - cmake

I'm very new to EFL. And now I'm trying to get used to it. There is library named Edje. This library allows theming and other sort of things. But files for it are created in plain text and have to be compiled using edje_cc.
How can I add this compilation to CMakeLists.txt file and to packaging.spec file for it to be properly compiled and installed on the machine?
Sorry for my broken English.

In your CMakeLists.txt, do:
ADD_CUSTOM_TARGET(your_edj_file.edj
COMMAND edje_cc your_edc_file.edc your_edj_file.edj
)
Notice that I simplified the COMMAND line - add the same arguments you use when you run edje_cc on a terminal (e.g. -id for images dir, -fd for fonts dir).
With this line added to CMakeLists.txt, a call to cmake in your packaging.spec file should be enough.

Related

CMake Error: include could not find load file: targets

I'm trying to run AmazonFreeRTOS on my ESP32 (at Windows). After creating build folder in my amazon-freertos main folder I've tried to build it from main folder with
cmake --build .\build
The Error I've got is
include could not find load file: targets
However, there is a idf_functions.cmake file that contains include(targets) command, and the targets.cmake file is in the same folder so I don't know why the error occured.
If you pay close attention to the error, you'd notice the full error says something like:
CMake Error at
your-amazon-freertos-directory/vendors/espressif/esp-idf/tools/cmake/idf_functions.cmake: 26 (include)
include could not find load file:
targets
This is because idf_functions.cmake sets the variable IDF_PATH to $ENV{IDF_PATH} which was configured in ~/.profile when the line export IDF_PATH=~/esp/esp-idf was added, as seen here.
If you navigate to ~/esp/esp-idf/tools/cmake/ you'd notice that files like target.cmake and ldgen.cmake, which are being included <your-amazon-freertos-directory>/vendors/espressif/esp-idf/tools/cmake/idf_functions.cmake, do not exist.
Solution 1 (somewhat hacky):
Copy the contents of <your-amazon-freertos-directory>/vendors/espressif/esp-idf/tools/cmake/ to ~/esp/esp-idf/tools/cmake/
Solution 2:
Modify the ~/.profile file to add the following lines instead of that suggested in the guide:
export IDF_PATH=~/<your-amazon-freertos-directory>/vendors/espressif/esp-idf/
export PATH="$PATH:$IDF_PATH/tools"
This should circumvent any CMake include errors during generation of build files and during build.
Since Amazon FreeRTOS supports many different platforms in addition to ESP32, you might need to supply additional commands to tell CMake that ESP32 is the target you want to build.
Try using
cmake -DVENDOR=espressif -DBOARD=esp32_wrover_kit -DCOMPILER=xtensa-esp32 -S . -B your-build-directory
from your top level folder to generate your makefiles into the build folder, and then switching to your build folder and calling
make all
(From the "Build, Flash, and Run the Amazon FreeRTOS Demo Project" section of
https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_espressif.html)

'Cannot determine link language for target...' issue in sub directory

In the main folder of my project, I have a CMakeLists.txt file. Inside this file, I include (using add_subdirectory) another CMakeLists.txt file located in my header file directory. The responsibility of this second file is to add all of my header files to the project:
file(GLOB gl_nbody_HEADERS "*.h")
add_executable(gl_nbody ${gl_nbody_HEADERS})
However, this files causes an error:
CMake Error: CMake can not determine linker language for target:gl_nbody
CMake Error: Cannot determine link language for target "gl_nbody".
What is strange is that when I include the two lines causing this error in my main CMakeLists.txt file (modified to work correctly for the change in directory), it works fine.
What is going wrong here?
add_executable causes the creation of an executable target, meaning the compilation of a list of source code files into an executable binary.
In order for this to work, and have CMake select a suitable compiler, the list of source files must contain at least one file with a "compilable" extension, ie. .c, or .cpp, or .cxx....
I don't see why you are trying to compile an executable here, since you only seem to try to list header files for inclusion into a project (which only makes sense for IDE-based generators, such as Visual Studio).
Also, it is not recommended to use globbing of files in CMake, because if you add more files to your project, CMake cannot detect them automatically, and will not regenerate build files. Please list all files explicitely.
The proper solution here is to list the header files in the proper add_executable command call where you list the actual source files that you want to compile.
You might also want to use the source_group() command, that allows you to group files into folders in the generated Visual Studio solution, for example:
source_group(header_files ${gl_nbody_HEADERS})

In Cmake how to update the makefiles with new source files without cleaning the object files

I'm using cmake, and I just added new source files and I want to include that new source files in the cmake generated makefiles to include in the building. I tried rebuild_cache but nothing happens.
Thanks!
It depends how your cmake file was built. If you use GLOB, you must run cmake manually any time you add or remove a source file. If you explicitly list your source files, just run make again. CMake will detect the changed CMakeLists.text.
CMake suggests the latter for this reason:
We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate.
CMake documentation

Add file dependencies to a custom target

I would like to set up CMake to build qresource files when the contents of files referenced in the .qrc file change. For example I have some qml files that are packaged into a qrc file and the qrc needs to be recompiled if the qml files are changed.
I have the following macro to run the resource compiler but it will only rebuild it if the resource file itself changes.
MACRO(PYQT5_WRAP_RC outfiles)
FOREACH(it ${ARGN})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_SOURCE_DIR}/${outfile}_rc.py)
ADD_CUSTOM_TARGET(${it} ALL
DEPENDS ${outfile}
)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${PYRCC5BINARY} ${infile} -o ${outfile}
MAIN_DEPENDENCY ${infile}
)
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH(it)
ENDMACRO (PYQT5_WRAP_RC)
The macro is used like this:
PYQT5_WRAP_RC(rc_gen file1.qrc file2.qrc ...)
How can I make it so the qrc file gets recompiled if one of files that it refers to changes?
Do I need to do something convoluted like this?
It seems to me that the command you are looking for is add_custom_command:
This defines a command to generate specified OUTPUT file(s). A target
created in the same directory (CMakeLists.txt file) that specifies any
output of the custom command as a source file is given a rule to
generate the file using the command at build time.
Configuring the dependencies correctly you should be able to get the file recompiled only when it is really needed.
If I understand correctly your situation, the problem is that CMake does not know anything about what qrc file is and it does not know, that qrc file references some other files. This dependency is implicit for CMake (compare with C++ includes; but for those cmake have special mechanisms to detect dependencies).
So, as I understand, what you can do is to use add_custom_target (which is executed always) but not only add qrc file to its depends, but also write some script, which whould check that files referenced in qrc are also up to date and if they are not, then touch qrc file).
Of course you can use methods from the other answer, which you reference above, to touch qrc file, but you have to develop your own script to extract paths of files referenced in qrc files. Then you can use CMake scripting facilities to check if they are up to date and to touch qrc file.

Can't find CMake created executable file

I am new to Cmake, I was trying to build an executble program from a Fortran code using Cmake-GUI. As per the program instruction I created the Cmakelists.txt. I then launched the Cmake-GUI and nominated the source directory and binaries directory and then used the configure and generate options to create my executable file. Everything seemed to have ran ok. Howover, when I checked my bin folder the .exe file that i was hoping to find is nowhere to be seen, instead I have cmake_Install.cmake and Makefile in the binaries folder. I opened these file with a text editor and they seem to be script file. Can somebody please tell me what I should do with these files to create the executale file. or if this is a sign of the cmake build process failing.
I don't know CMake for fortran, but cmake in general will create the makefiles / visual studio projects etc. We cmake into a bin directory, then go in there and run make. It doesn't build the source, it builds the make files.
Did you build the source?
CMake just create the makefiles and projects structures to compile using a make tool. I don't know how to compile it for Fortran, but in Linux for a C++ project, I just have to open a terminal, go to the build folder (your bin folder) and run make or make all and it compile the whole project.
I think that your problem is that your project is not compiled, so there is not any binary files.