On Tuesday 04 January 2011, Shawn Rutledge wrote:
> I am building a KDE control panel plugin, and there is a requirement
> to use a different translation mechanism rather than the default Qt
> "tr" macros.  So I want to post-process my ui_*.h files to replace
> lines like this
>
>         ClearSiteDataDialog->setWindowTitle(tr2i18n("foo", 0));
>
>  with the replacement code like this
>
>        
> ClearSiteDataDialog->setWindowTitle(Translator::instance().lookupString(CSD
>_DIALOG_TITLE));
>
> I wrote a python script to do that, and I'm calling it like this from
> cmakelists.txt:
>
> cmake_minimum_required (VERSION 2.6.0)
> set (CMAKE_VERBOSE_MAKEFILE true)
> find_package(KDE4 REQUIRED)
> file(GLOB SRC_FILES *.cpp)
> set(kcm_my_plugin_PART_SRCS ${SRC_FILES})
> message(STATUS "build type ${CMAKE_BUILD_TYPE}")
> file(GLOB UI_FILES *.ui)
> message(STATUS "ui files ${UI_FILES}")
> kde4_add_ui_files(kcm_my_plugin_PART_SRCS ${UI_FILES})
> kde4_add_plugin(kcm_my_plugin ${kcm_my_plugin_PART_SRCS}
> ${LINUX_COMMON_SOURCE} ${COMMON_SOURCE} ${COMMON_SOURCE_IMPL})
> target_link_libraries(kcm_my_plugin  ${KDE4_KDEUI_LIBS}
> ${KDE4_KCMUTILS_LIBS} ${X11_LIBRARIES} kutils)
> # post-process the ui_*.h header files AFTER they have been generated
> but BEFORE compiling anything
> add_custom_target(ui_translate
>       COMMAND ${CMAKE_SOURCE_DIR}/tools/convert-tr2-all.py
>       WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
> ADD_DEPENDENCIES(kcm_my_plugin ui_translate)
> ADD_DEPENDENCIES(kcm_my_plugin_automoc ui_translate)


Have a look at the kde4_add_ui_files() macro.
It executes the kde4uic.cmake script. There some tools are called, the text of 
a generated file is read into a cmake variable, and there using cmake regexp 
some strings are replaced.
I think you can do it in a similar way for your problem.

Alex
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to