Registered Member
|
Hello.
In a KDE4 application, I want to use KConfigXT. So I've created a kcfg and a kcfgc file. And than, I've added "kde4_add_kcfg_files(kcfg_LIB_SRCS my_file.kcfgc)" to my CMakeLists.txt. The problem is that: CMake will call kconfig_compiler to generate my_file.h, and this header file is used by "#include" in some cpp files. But CMake calls kconfig_compiler quite late: after compiling the cpp files who wants to include the header. So how can be made sure the CMake will first create my_file.h and than compile? (I've yet tried to use kde4_add_kcfg_files as very first macro in the CMakeLists.txt, and the cpp files later - but this does not help.) CMakeLists.txt: set(radiostation_LIB_SRCS) kde4_add_kcfg_files(radiostation_LIB_SRCS settings_stream.kcfgc) # define source files which are part of the project and have to be compiled set(radiostation_LIB_SRCS ${radiostation_LIB_SRCS} streamripper_base.cpp ripping.cpp radiostation.cpp get_stream_info.cpp get_streamripper_version.cpp) # add also the files for the UI dialog set(radiostation_LIB_SRCS ${radiostation_LIB_SRCS} settings_stream_widget_connection.cpp settings_stream_widget_splitting.cpp settings_stream_widget_saving.cpp settings_stream_dialog.cpp propertyvalue.cpp) kde4_add_ui_files( radiostation_LIB_SRCS settings_stream_widget_connection.ui settings_stream_widget_saving.ui settings_stream_widget_splitting.ui) # compile and link qt4_automoc(${radiostation_LIB_SRCS}) kde4_add_library( radiostation STATIC ${radiostation_LIB_SRCS} )
Last edited by urwald on Thu Jan 22, 2009 10:43 am, edited 1 time in total.
urwald, proud to be a member of KDE forums since 2008-Oct.
|
Mentor
|
What version of cmake and KDE do you have. I am not sure, but perhaps it is the kde4_add_library which could be implemented wrong. Your CMakeLists.txt looks ok, but I never used KConfigXT together with building a library. That's just a guess, but could you write a small main.cpp and compile it as executable, just to test whether it is the kde4_add_library call?
[size=x-small]code | [url=cia.vc/stats/author/msoeken]cia.vc[/url] | [url=kde.org/support]donating KDE[/url] | [url=tinyurl.com/cto4ns]wishlist[/url][/size] |
Registered Member
|
Hm, I seems that I was wrong with my assumption that kconfig_compiler is called too late. It is called at the right time and works fine when doing in-source builds.
But when trying an out-of-source build, that the resulting settings_stream.h is just not found: /home/tim/Documents/KRadioRipper/kradioripper/src/radiostation/settings_stream_dialog.h:24:29: error: settings_stream.h: Datei oder Verzeichnis nicht gefunden In settings_stream_dialog.h, the include is done by the usual #include "settings_stream.h" So I don't understand why settings_stream.h isn't found. Okay, because it's an out-of-source build, settings_stream.h is not created in the directory itself, but in a subdirectory of the build directory. But isn't this handed automatically? How can I make sure that settings_stream.h is found (in a way that works out of the box for in-source and out-of-source builds)?
urwald, proud to be a member of KDE forums since 2008-Oct.
|
Mentor
|
You can set the build directory as include directory. I have often seen that. There is also a cmake variable for it.
[size=x-small]code | [url=cia.vc/stats/author/msoeken]cia.vc[/url] | [url=kde.org/support]donating KDE[/url] | [url=tinyurl.com/cto4ns]wishlist[/url][/size] |
Registered Member
|
Thank you. Now it works fine. The cmake variable is [font=Courier]CMAKE_CURRENT_BINARY_DIR[/font], which points to the directory in the build tree which corresponds to the actual directory in which CMakeLists.txt is stored. So the corresponding line is:
[font=Courier]include_directories(${QT_INCLUDE} ${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})[/font] Notice that it wasn't possible to call [font=Courier]include_directories[/font] more than one time. (I wanted to call [font=Courier]include_directories[/font] the first time in the CMakeLists.txt of the base source directory with general [font=Courier]QT_INCLUDE[/font] and so on, and than another time in a subdirectory with [font=Courier]CMAKE_CURRENT_BINARY_DIR[/font], but the second call is ignored for some reasons.) Gratitude. Tim
urwald, proud to be a member of KDE forums since 2008-Oct.
|
Mentor
|
Great! Could you please mark this thread as solved? There is a "It's solved!" button in the top of this page. Thanks in advance.
[size=x-small]code | [url=cia.vc/stats/author/msoeken]cia.vc[/url] | [url=kde.org/support]donating KDE[/url] | [url=tinyurl.com/cto4ns]wishlist[/url][/size] |
Registered Member
|
Hm. I've yet done this, but I got a page with a message about a database error. Now the button shows "Unsolve it" (but there is nothing changed). Should I unsolve it and than solve it again?
urwald, proud to be a member of KDE forums since 2008-Oct.
|
Mentor
|
I never used this button, but you can try it. If it does not work, you can just change your title to [SOLVED] CMake: ...
[size=x-small]code | [url=cia.vc/stats/author/msoeken]cia.vc[/url] | [url=kde.org/support]donating KDE[/url] | [url=tinyurl.com/cto4ns]wishlist[/url][/size] |
Administrator
|
@Urwald: If you encounter Database errors while browsing the board, please note down the message and post it in the Feedback forum so the error can be corrected and data loss avoided. Thanks in advance.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
@bcooksley: Next time I will do that. But for this time, I can't get the message back anymore and don't know exactly what was the content. But it was small and didn't explain much.
urwald, proud to be a member of KDE forums since 2008-Oct.
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]