KDE/kdebindings

Maciej Mrozowski reavertm at gmail.com
Tue May 11 23:58:16 CEST 2010


SVN commit 1125668 by mmrozowski:

Unify CMake code related to enabling language bindings

- add macro  macro_optional_add_bindings(<component_found> <component_name> 
<subdir1> [<subdir2> ...])
# Conditionally enable bindings.
# Pass -DDISABLE_<component_name>=ON to disable certain binding even if its 
dependencies are found.
# CMake project needs to be set before using this macro.
# Macro sets following variables:
#     ${CMAKE_PROJECT_NAME}_ENABLED - list of enabled bindings
#     ${CMAKE_PROJECT_NAME}_DISABLED - list of disabled bindings
# Usage:
#     macro_optional_add_bindings(<component_found> <component_name> <subdir1> 
[<subdir2> ...])
project() needs to be set (preferably in the same scope as macro invocations)

- add macro macro_display_bindings_log()
# Show bindings summary
# Usage:
#     macro_display_bindings_log()
Simple bindings summary, feel free to extend it in a future if you like.

- use them in Smoke, Ruby, CSharp
Unified component names in all bindings as well, so that for instance -DDISABLE_QtWebkit=ON will 
disable WebKit bindings for all languages.

CCMAIL: kde-bindings at kde.org
CCMAIL: kde-buildsystem at kde.org

 M  +1 -0      CMakeLists.txt  
 A             cmake/modules/MacroOptionalAddBindings.cmake  
 M  +21 -36    csharp/CMakeLists.txt  
 M  +35 -53    ruby/CMakeLists.txt  
 M  +39 -56    smoke/CMakeLists.txt  


--- trunk/KDE/kdebindings/CMakeLists.txt #1125667:1125668
@@ -9,6 +9,7 @@
 find_package(KDE4 REQUIRED)
 include(KDE4Defaults)
 include(MacroLibrary)
+include(MacroOptionalAddBindings)
 
 add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS} -DQT3_SUPPORT)
 include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})
--- trunk/KDE/kdebindings/csharp/CMakeLists.txt #1125667:1125668
@@ -1,3 +1,5 @@
+project(CSharp)
+
 enable_language(CSharp OPTIONAL)
 
 macro_log_feature(CMAKE_CSharp_COMPILER_LOADED "C# compiler" "Mono or the .NET framework" "http://www.mono-project.com" FALSE "" "Required to compile the C# bindings")
@@ -10,49 +12,32 @@
 SET( UICS_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/qyoto/tools/uics/uics )
 SET( CSRCC_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/qyoto/tools/csrcc/csrcc )
     
-add_subdirectory( qyoto )
-ADD_SUBDIRECTORY(qtscript)
-ADD_SUBDIRECTORY( qttest )
-ADD_SUBDIRECTORY(qtuitools)
-ADD_SUBDIRECTORY(qtwebkit)
-set(ENABLED_QYOTO_MODULES "Qyoto, QtScript, QtTest, QtUiTools, QtWebKit")
+macro_optional_add_bindings(QT_QTCORE_FOUND "Qyoto" qyoto)
+macro_optional_add_bindings(QT_QTSCRIPT_FOUND "QtScript" qtscript)
+macro_optional_add_bindings(QT_QTTEST_FOUND "QtTest" qttest)
+macro_optional_add_bindings(QT_QTUITOOLS_FOUND "QtUiTools" qtuitools)
+macro_optional_add_bindings(QT_QTWEBKIT_FOUND "QtWebKit" qtwebkit)
 
-IF(PHONON_FOUND)
-    ADD_SUBDIRECTORY(phonon)
-    set(ENABLED_QYOTO_MODULES "${ENABLED_QYOTO_MODULES}, Phonon")
-ENDIF(PHONON_FOUND)
+macro_optional_add_bindings(PHONON_FOUND "Phonon" phonon)
 
-IF(QSCINTILLA_FOUND)
-    ADD_SUBDIRECTORY(qscintilla)
-    set(ENABLED_QYOTO_MODULES "${ENABLED_QYOTO_MODULES}, QScintilla")
-ENDIF(QSCINTILLA_FOUND)
+macro_optional_add_bindings(QSCINTILLA_FOUND "QScintilla" qsci)
 
-IF(KDE4_FOUND)
-    ADD_SUBDIRECTORY(kimono)
-    ADD_SUBDIRECTORY(khtml)
-    ADD_SUBDIRECTORY(ktexteditor)
-    ADD_SUBDIRECTORY(plasma)
-    set(ENABLED_QYOTO_MODULES "${ENABLED_QYOTO_MODULES}, Kimono, KHTML, KTextEditor, Plasma")
-ENDIF(KDE4_FOUND)
+macro_optional_add_bindings(KDE4_FOUND "Kimono" kimono)
+macro_optional_add_bindings(KDE4_FOUND "KHTML" khtml)
+macro_optional_add_bindings(KDE4_FOUND "KTextEditor" ktexteditor)
+macro_optional_add_bindings(KDE4_FOUND "Plasma" plasma)
 
-IF(SOPRANO_FOUND)
-    ADD_SUBDIRECTORY(soprano)
-    set(ENABLED_QYOTO_MODULES "${ENABLED_QYOTO_MODULES}, Soprano")
-ENDIF(SOPRANO_FOUND)
+macro_optional_add_bindings(Soprano_FOUND "Soprano" soprano)
 
-IF(Nepomuk_FOUND)
-    ADD_SUBDIRECTORY(nepomuk)
-    set(ENABLED_QYOTO_MODULES "${ENABLED_QYOTO_MODULES}, Nepomuk")
-ENDIF(Nepomuk_FOUND)
+macro_optional_add_bindings(Nepomuk_FOUND "Nepomuk" nepomuk)
 
-IF(QIMAGEBLITZ_FOUND)
-    ADD_SUBDIRECTORY(qimageblitz)
-    set(ENABLED_QYOTO_MODULES "${ENABLED_QYOTO_MODULES}, QImageBlitz")
-ENDIF(QIMAGEBLITZ_FOUND)
+macro_optional_add_bindings(QIMAGEBLITZ_FOUND "QImageBlitz" qimageblitz)
 
 if(KDEPIMLIBS_FOUND AND Akonadi_FOUND)
-    add_subdirectory( akonadi )
-    set(ENABLED_QYOTO_MODULES "${ENABLED_QYOTO_MODULES}, Akonadi")
+    set(BUILD_Akonadi TRUE)
+else(KDEPIMLIBS_FOUND AND Akonadi_FOUND)
+    set(BUILD_Akonadi FALSE)
 endif(KDEPIMLIBS_FOUND AND Akonadi_FOUND)
+macro_optional_add_bindings(BUILD_Akonadi "Akonadi" akonadi)
 
-message(STATUS "Building Qyoto modules ${ENABLED_QYOTO_MODULES}")
+macro_display_bindings_log()
--- trunk/KDE/kdebindings/ruby/CMakeLists.txt #1125667:1125668
@@ -1,3 +1,5 @@
+project(Ruby)
+
 set(COMPILE_RUBY FALSE CACHE INTERNAL "")
 
 macro_optional_find_package(Ruby)
@@ -18,74 +20,53 @@
 # compute an overall version number which can be compared at once
 MATH(EXPR RUBY_VERSION_NUMBER "${RUBY_VERSION_MAJOR}*10000 + ${RUBY_VERSION_MINOR}*100 + ${RUBY_VERSION_PATCH}")
 
-add_subdirectory( qtruby )
-add_subdirectory( qtwebkit )
-add_subdirectory( qtuitools )
-add_subdirectory( qtscript )
-add_subdirectory( qttest )
-set (ENABLED_RUBY_MODULES "Qt, QtWebKit, QtUiTools, QtScript, QtTest")
+macro_optional_add_bindings(QT_QTCORE_FOUND "QtRuby" qtruby)
+macro_optional_add_bindings(QT_QTWEBKIT_FOUND "QtWebKit" qtwebkit)
+macro_optional_add_bindings(QT_QTUITOOLS_FOUND "QtUiTools" qtuitools)
+macro_optional_add_bindings(QT_QTSCRIPT_FOUND "QtScript" qtscript)
+macro_optional_add_bindings(QT_QTTEST_FOUND "QtTest" qttest)
 
-if(PHONON_FOUND)
-    add_subdirectory( phonon )
-    set(ENABLED_RUBY_MODULES "${ENABLED_RUBY_MODULES}, Phonon")
-endif(PHONON_FOUND)
+macro_optional_add_bindings(PHONON_FOUND "Phonon" phonon)
 
-if(QSCINTILLA_FOUND)
-    add_subdirectory( qscintilla )
-    set(ENABLED_RUBY_MODULES "${ENABLED_RUBY_MODULES}, QScintilla")
-endif(QSCINTILLA_FOUND)
+macro_optional_add_bindings(QSCINTILLA_FOUND "QScintilla" qscintilla)
 
-if(Qwt5_Qt4_FOUND)
-    add_subdirectory( qwt )
-    set(ENABLED_RUBY_MODULES "${ENABLED_RUBY_MODULES}, Qwt5")
-endif(Qwt5_Qt4_FOUND)
+macro_optional_add_bindings(Qwt5_Qt4_FOUND "Qwt" qwt)
 
-if(Soprano_FOUND)
-    add_subdirectory( soprano )
-    set(ENABLED_RUBY_MODULES "${ENABLED_RUBY_MODULES}, Soprano")
-endif(Soprano_FOUND)
+macro_optional_add_bindings(Soprano_FOUND "Soprano" soprano)
 
 if(KDEPIMLIBS_FOUND AND Akonadi_FOUND)
-    add_subdirectory( akonadi )
-    set(ENABLED_RUBY_MODULES "${ENABLED_RUBY_MODULES}, Akonadi")
+    set(BUILD_Akonadi TRUE)
+else(KDEPIMLIBS_FOUND AND Akonadi_FOUND)
+    set(BUILD_Akonadi FALSE)
 endif(KDEPIMLIBS_FOUND AND Akonadi_FOUND)
+macro_optional_add_bindings(BUILD_Akonadi "Akonadi" akonadi)
 
-if(KDE4_FOUND)
-    add_subdirectory( korundum )
-    add_subdirectory( kio )
-    add_subdirectory( khtml )
-    add_subdirectory( ktexteditor )
-    add_subdirectory( solid )
-    add_subdirectory( plasma )
-    set(ENABLED_RUBY_MODULES "${ENABLED_RUBY_MODULES}, KDE4, KIO, KHTML, KTextEditor, Solid, Plasma")
-endif(KDE4_FOUND)
+macro_optional_add_bindings(KDE4_FOUND "Korundum" korundum)
+macro_optional_add_bindings(KDE4_FOUND "KIO" kio)
+macro_optional_add_bindings(KDE4_FOUND "KHTML" khtml)
+macro_optional_add_bindings(KDE4_FOUND "KTextEditor" ktexteditor)
+macro_optional_add_bindings(KDE4_FOUND "Solid" solid)
+macro_optional_add_bindings(KDE4_FOUND "Plasma" plasma)
     
-if(KDEVPLATFORM_FOUND)
-    add_subdirectory( kdevplatform )
-    set(ENABLED_RUBY_MODULES "${ENABLED_RUBY_MODULES}, KDevPlatform")
-endif(KDEVPLATFORM_FOUND)
+macro_optional_add_bindings(KDEVPLATFORM_FOUND "KDevPlatform" kdevplatform)
 
 # For nepomuk, we also must have found soprano, since soprano headers are used:
-if(Nepomuk_FOUND  AND  Soprano_FOUND)
-    add_subdirectory( nepomuk )
-    set(ENABLED_RUBY_MODULES "${ENABLED_RUBY_MODULES}, Nepomuk")
-endif(Nepomuk_FOUND  AND  Soprano_FOUND)
+if(Soprano_FOUND AND Nepomuk_FOUND)
+    set(BUILD_Nepomuk TRUE)
+else(Soprano_FOUND AND Nepomuk_FOUND)
+    set(BUILD_Nepomuk FALSE)
+endif(Soprano_FOUND AND Nepomuk_FOUND)
+macro_optional_add_bindings(BUILD_Nepomuk "Nepomuk" nepomuk)
 
-if(OKULAR_FOUND)
-    add_subdirectory( okular )
-    set(ENABLED_RUBY_MODULES "${ENABLED_RUBY_MODULES}, Okular")
-endif(OKULAR_FOUND)
+macro_optional_add_bindings(OKULAR_FOUND "Okular" okular)
 
-message(STATUS "Building Ruby bindings for ${ENABLED_RUBY_MODULES}")
-
 #####################################################################
 # Kross Ruby
 
 OPTION(ENABLE_KROSSRUBY "build Kross Ruby scripting library" ON)
 #OPTION(ENABLE_KROSSRUBY "build Kross Ruby scripting library" OFF)
 
-set(KROSSRUBY_ENABLED "no")
-if(ENABLE_KROSSRUBY)
+set(BUILD_KrossRuby FALSE)
     if (RUBY_EXECUTABLE AND RUBY_LIBRARY AND RUBY_INCLUDE_DIRS)
         EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r mkmf -e "exit(have_func('rb_hash_foreach') ? 0 : 1)" RESULT_VARIABLE RUBY_HASH_FOREACH OUTPUT_QUIET)
         if (RUBY_HASH_FOREACH EQUAL 0)
@@ -96,8 +77,7 @@
                 #include <ruby.h>
                 int main() { ruby_init(); return 0; }" RubyCompiles)
             if(RubyCompiles)
-                add_subdirectory(krossruby)
-                set(KROSSRUBY_ENABLED "yes")
+            set(BUILD_KrossRuby TRUE)
             else(RubyCompiles)
                 message(STATUS "Failed to compile a C++ program that embeds ruby.")
             endif(RubyCompiles)
@@ -118,5 +98,7 @@
     message(STATUS "Ruby Executable: " ${RUBY_EXECUTABLE})
     message(STATUS "Ruby Libraries: " ${RUBY_LIBRARY})
     message(STATUS "Ruby Include Directories: " ${RUBY_INCLUDE_DIRS})
-endif(ENABLE_KROSSRUBY)
-message(STATUS "Build Kross Ruby... " ${KROSSRUBY_ENABLED})
+
+macro_optional_add_bindings(BUILD_KrossRuby "KrossRuby" krossruby)
+
+macro_display_bindings_log()
--- trunk/KDE/kdebindings/smoke/CMakeLists.txt #1125667:1125668
@@ -1,78 +1,62 @@
-# Conditionally enable SMOKE bindings.
-# Pass -DDISABLE_<component_name>=OFF to disable certain binding even if
-# its dependencies are found.
-# Usage:
-#     SMOKE_ADD_BINDINGS(<component_found> <component_name> <subdir1> [<subdir2> ...])
-macro(SMOKE_ADD_BINDINGS _component_found _component_name)
-    if(${_component_found} AND NOT DISABLE_${_component_name})
-        foreach(_subdir ${ARGN})
-            add_subdirectory(${_subdir})
-        endforeach(_subdir ${ARGN})
-        set(SMOKE_ENABLED "${SMOKE_ENABLED} ${_component_name}")
-    else(${_component_found} AND NOT DISABLE_${_component_name})
-        set(SMOKE_DISABLED "${SMOKE_DISABLED} ${_component_name}")
-    endif(${_component_found} AND NOT DISABLE_${_component_name})
-endmacro(SMOKE_ADD_BINDINGS)
+project(SMOKE)
 
 add_definitions(-DSMOKE_BUILDING)
-set(SMOKE_ENABLED "")
-set(SMOKE_DISABLED "")
 
-smoke_add_bindings(QT_QTCORE_FOUND "QtCore" qtcore)
+add_subdirectory(qtcore)
 add_subdirectory(deptool)
 add_subdirectory(smokeapi)
 
-smoke_add_bindings(QT_QTNETWORK_FOUND "QtNetwork" qtnetwork)
-smoke_add_bindings(QT_QTDBUS_FOUND "QtDBus" qtdbus)
-smoke_add_bindings(QT_QTGUI_FOUND "QtGui" qtgui)
-smoke_add_bindings(QT_QTSVG_FOUND "QtSvg" qtsvg)
-smoke_add_bindings(QT_QTSQL_FOUND "QtSql" qtsql)
-smoke_add_bindings(QT_QTXML_FOUND "QtXml" qtxml)
-smoke_add_bindings(QT_QTXMLPATTERNS_FOUND "QtXmlPatterns" qtxmlpatterns)
-smoke_add_bindings(QT_QTOPENGL_FOUND "QtOpenGL" qtopengl)
-smoke_add_bindings(QT_QTWEBKIT_FOUND "QtWebKit" qtwebkit)
-smoke_add_bindings(QT_QTSCRIPT_FOUND "QtScript" qtscript)
-smoke_add_bindings(QT_QTUITOOLS_FOUND "QtUiTools" qtuitools)
-smoke_add_bindings(QT_QTTEST_FOUND "QtTest" qttest)
-smoke_add_bindings(QT_QTMULTIMEDIA_FOUND "QtMultimedia" qtmultimedia)
+macro_optional_add_bindings(QT_QTNETWORK_FOUND "QtNetwork" qtnetwork)
+macro_optional_add_bindings(QT_QTDBUS_FOUND "QtDBus" qtdbus)
+macro_optional_add_bindings(QT_QTGUI_FOUND "QtGui" qtgui)
+macro_optional_add_bindings(QT_QTSVG_FOUND "QtSvg" qtsvg)
+macro_optional_add_bindings(QT_QTSQL_FOUND "QtSql" qtsql)
+macro_optional_add_bindings(QT_QTXML_FOUND "QtXml" qtxml)
+macro_optional_add_bindings(QT_QTXMLPATTERNS_FOUND "QtXmlPatterns" qtxmlpatterns)
+macro_optional_add_bindings(QT_QTOPENGL_FOUND "QtOpenGL" qtopengl)
+macro_optional_add_bindings(QT_QTWEBKIT_FOUND "QtWebKit" qtwebkit)
+macro_optional_add_bindings(QT_QTSCRIPT_FOUND "QtScript" qtscript)
+macro_optional_add_bindings(QT_QTUITOOLS_FOUND "QtUiTools" qtuitools)
+macro_optional_add_bindings(QT_QTTEST_FOUND "QtTest" qttest)
+macro_optional_add_bindings(QT_QTMULTIMEDIA_FOUND "QtMultimedia" qtmultimedia)
 
-smoke_add_bindings(PHONON_FOUND "Phonon" phonon)
+macro_optional_add_bindings(PHONON_FOUND "Phonon" phonon)
 
-smoke_add_bindings(QSCINTILLA_FOUND "QScintilla2" qsci)
+macro_optional_add_bindings(QSCINTILLA_FOUND "QScintilla" qsci)
 
-smoke_add_bindings(Qwt5_Qt4_FOUND "Qwt" qwt)
+macro_optional_add_bindings(Qwt5_Qt4_FOUND "Qwt" qwt)
 
-smoke_add_bindings(QIMAGEBLITZ_FOUND "QImageBlitz" qimageblitz)
+macro_optional_add_bindings(QIMAGEBLITZ_FOUND "QImageBlitz" qimageblitz)
 
-smoke_add_bindings(KDE4_FOUND "KDECore" kdecore)
-smoke_add_bindings(KDE4_FOUND "KDEUi" kdeui)
-smoke_add_bindings(KDE4_FOUND "KIO" kio)
-smoke_add_bindings(KDE4_FOUND "KParts" kparts)
-smoke_add_bindings(KDE4_FOUND "KFile" kfile)
-smoke_add_bindings(KDE4_FOUND "KNewStuff2" knewstuff2)
-smoke_add_bindings(KDE4_FOUND "KNewStuff3" knewstuff3)
-smoke_add_bindings(KDE4_FOUND "KUtils" kutils)
-smoke_add_bindings(KDE4_FOUND "KHTML" khtml)
-smoke_add_bindings(KDE4_FOUND "KTextEditor" ktexteditor)
-smoke_add_bindings(KDE4_FOUND "Solid" solid)
-smoke_add_bindings(KDE4_FOUND "Plasma" plasma)
+macro_optional_add_bindings(KDE4_FOUND "KDECore" kdecore)
+macro_optional_add_bindings(KDE4_FOUND "KDEUi" kdeui)
+macro_optional_add_bindings(KDE4_FOUND "KIO" kio)
+macro_optional_add_bindings(KDE4_FOUND "KParts" kparts)
+macro_optional_add_bindings(KDE4_FOUND "KFile" kfile)
+macro_optional_add_bindings(KDE4_FOUND "KNewStuff2" knewstuff2)
+macro_optional_add_bindings(KDE4_FOUND "KNewStuff3" knewstuff3)
+macro_optional_add_bindings(KDE4_FOUND "KUtils" kutils)
+macro_optional_add_bindings(KDE4_FOUND "KHTML" khtml)
+macro_optional_add_bindings(KDE4_FOUND "KTextEditor" ktexteditor)
+macro_optional_add_bindings(KDE4_FOUND "Solid" solid)
+macro_optional_add_bindings(KDE4_FOUND "Plasma" plasma)
 
-smoke_add_bindings(Soprano_FOUND "Soprano" soprano sopranoclient sopranoserver)
+macro_optional_add_bindings(Soprano_FOUND "Soprano" soprano sopranoclient sopranoserver)
 
 if(KDEPIMLIBS_FOUND AND Akonadi_FOUND)
     set(BUILD_Akonadi TRUE)
-elseif(KDEPIMLIBS_FOUND AND Akonadi_FOUND)
+else(KDEPIMLIBS_FOUND AND Akonadi_FOUND)
     set(BUILD_Akonadi FALSE)
 endif(KDEPIMLIBS_FOUND AND Akonadi_FOUND)
-smoke_add_bindings(BUILD_Akonadi "Akonadi" akonadi)
+macro_optional_add_bindings(BUILD_Akonadi "Akonadi" akonadi)
 
-smoke_add_bindings(KDEVPLATFORM_FOUND "KDevPlatform" kdevplatform)
+macro_optional_add_bindings(KDEVPLATFORM_FOUND "KDevPlatform" kdevplatform)
 
-smoke_add_bindings(LIBATTICA_FOUND "Attica" attica)
+macro_optional_add_bindings(LIBATTICA_FOUND "Attica" attica)
 
-smoke_add_bindings(Nepomuk_FOUND "Nepomuk" nepomuk nepomukquery)
+macro_optional_add_bindings(Nepomuk_FOUND "Nepomuk" nepomuk nepomukquery)
 
-smoke_add_bindings(OKULAR_FOUND "Okular" okular)
+macro_optional_add_bindings(OKULAR_FOUND "Okular" okular)
 
 # for qtguess.pl
 if (APPLE)
@@ -81,8 +65,7 @@
 set(qt_test_threshold 10)
 endif (APPLE)
 
-message(STATUS "Build SMOKE bindings:" ${SMOKE_ENABLED})
-message(STATUS "Skip SMOKE bindings:" ${SMOKE_DISABLED})
+macro_display_bindings_log()
 
 ########### install files ###############
 


More information about the Kde-buildsystem mailing list