From kde-core-devel Mon Nov 29 00:11:07 2010 From: David Faure Date: Mon, 29 Nov 2010 00:11:07 +0000 To: kde-core-devel Subject: headers installation and compilation tests Message-Id: <201011290111.08101.faure () kde ! org> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=129103567430280 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_c+u8MhV8QOaCQAv" --Boundary-00=_c+u8MhV8QOaCQAv Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit On Monday 09 August 2010, Volker Krause wrote: > On Saturday 07 August 2010 02:24:16 Aaron J. Seigo wrote: > > On August 6, 2010, Thiago Macieira wrote: > > > Side comment: shouldn't all of this (the includes and the installation > > > rules) be auto-generated? > > > > they should, but as you pointe out they aren't. the result is exctly what > > one would expect from a manual process: frequent ommissions, occassional > > > > breakage. > > > > would be a nice little project for someone to work on :) > > Indeed. At least the install part is done automatically in > kdepimlibs/includes already, with the downside that it only picks up new > headers after a CMake re-run, but still much nicer than the explicit list > IMHO. I had a look at this, and it doesn't allow to have headers that are conditionnally installed -- unless they are in a separate subdir. So it creates a problem for things like if(QT_QTOPENGL_FOUND AND OPENGL_FOUND) install(FILES Plasma/GLApplet DESTINATION ${INCLUDE_INSTALL_DIR}/KDE/Plasma COMPONENT Devel) endif(QT_QTOPENGL_FOUND AND OPENGL_FOUND) if(NOT KDE_NO_DEPRECATED) install( FILES Plasma/AnimationDriver DESTINATION ${INCLUDE_INSTALL_DIR}/KDE/Plasma COMPONENT Devel) endif(NOT KDE_NO_DEPRECATED) and other "if not deprecated" and "if UNIX" tests. Moving such headers to separate subdirs sounds hackish, and totally breaks any hopes of autogenerating the forwarding headers. I think we should keep the current list of headers in kdelibs, or move to a completely automated system where we gather the public headers from each lib and generate forwarding headers, which would also make it possible to use in kdelibs, but I'm not sure it's worth the trouble. > It also has a test that makes sure all headers compile with strict > flags (QT_NO_CAST_FROM_ASCII, etc), might be interesting for kdelibs as > well. Yep, very interesting, I just wrote the attached patch in order to check this in kdelibs - without using the forwarding headers though, since they don't compile in kdelibs before being installed. Instead I'm doing this per-library, using its already set up include directories and their list of installed headers. Attaching, for review on kde- buildsystem. Tested on kdeui and kio, works fine, needs to be applied to all other libs as well. -- David Faure, faure@kde.org, http://www.davidfaure.fr Sponsored by Nokia to work on KDE, incl. Konqueror (http://www.konqueror.org). --Boundary-00=_c+u8MhV8QOaCQAv Content-Type: text/x-patch; charset="UTF-8"; name="MacroHeaderCompilationTest.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="MacroHeaderCompilationTest.diff" Index: cmake/modules/MacroHeaderCompilationTest.cmake =================================================================== --- cmake/modules/MacroHeaderCompilationTest.cmake (revision 0) +++ cmake/modules/MacroHeaderCompilationTest.cmake (revision 0) @@ -0,0 +1,38 @@ + +macro(macro_header_compilation_test) + + # Clear the file initially + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/all_includes.h "/* all forwarding includes */\n" ) + + # Insert all #include lines + foreach( file ${ARGN} ) + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/all_includes.h "#include <${file}>\n" ) + endforeach(file) + + # Prepare a "main", in a generated file + # Make sure to delete the generated files if you change the contents below. + if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/header_compile.cpp) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/header_compile.cpp + "#ifndef QT_NO_CAST_FROM_ASCII\n" + " #define QT_NO_CAST_FROM_ASCII\n" + "#endif\n" + "#ifndef QT_NO_CAST_TO_ASCII\n" + " #define QT_NO_CAST_TO_ASCII\n" + "#endif\n" + "#ifndef QT_NO_CAST_FROM_BYTEARRAY\n" + " #define QT_NO_CAST_FROM_BYTEARRAY\n" + "#endif\n" + "#ifndef QT_NO_KEYWORDS\n" + " #define QT_NO_KEYWORDS\n" + "#endif\n" + "#ifndef QT_STRICT_ITERATORS\n" + " #define QT_STRICT_ITERATORS\n" + "#endif\n" + ) + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/header_compile.cpp "#include \"all_includes.h\"\nint main( int , char** ) { return 0; }\n" ) + endif() + + kde4_add_executable( header_compilation_test ${CMAKE_CURRENT_BINARY_DIR}/header_compile.cpp ) + target_link_libraries( header_compilation_test ${QT_QTCORE_LIBRARY} ) +endmacro(macro_header_compilation_test) + Index: kdeui/CMakeLists.txt =================================================================== --- kdeui/CMakeLists.txt (revision 1201251) +++ kdeui/CMakeLists.txt (working copy) @@ -47,7 +47,6 @@ ) add_subdirectory( about ) -add_subdirectory( tests ) add_subdirectory( sonnet/tests ) ########### next target ############### @@ -462,7 +461,7 @@ install( FILES xmlgui/ui_standards.rc DESTINATION ${CONFIG_INSTALL_DIR}/ui ) -install( FILES +set (KDEUI_INSTALL_HEADERS kdeui_export.h actions/kactioncollection.h actions/kactioncategory.h @@ -662,8 +661,10 @@ xmlgui/kxmlguiclient.h xmlgui/kxmlguibuilder.h xmlgui/kxmlguifactory.h - DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel ) +) +install( FILES ${KDEUI_INSTALL_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel ) + if(NOT KDE_NO_DEPRECATED) install(FILES widgets/karrowbutton.h @@ -710,3 +711,6 @@ # install our copy of the rgb.txt named colors list on systems without X11 install(FILES colors/rgb.txt DESTINATION ${DATA_INSTALL_DIR}/kdeui) endif (NOT Q_WS_X11) + +add_subdirectory( tests ) + Index: kdeui/tests/CMakeLists.txt =================================================================== --- kdeui/tests/CMakeLists.txt (revision 1201251) +++ kdeui/tests/CMakeLists.txt (working copy) @@ -178,3 +178,10 @@ add_subdirectory(proxymodeltestapp) +## Test for compiling all headers ## + +if (KDE4_BUILD_TESTS) + include(MacroHeaderCompilationTest) + macro_header_compilation_test(${KDEUI_INSTALL_HEADERS}) +endif (KDE4_BUILD_TESTS) + Index: kio/CMakeLists.txt =================================================================== --- kio/CMakeLists.txt (revision 1201251) +++ kio/CMakeLists.txt (working copy) @@ -58,7 +58,6 @@ add_subdirectory( kssl/kssl ) add_subdirectory( kssl/kcm ) add_subdirectory( misc ) -add_subdirectory( tests ) add_subdirectory( kio/dummyanalyzers ) set(kiocore_STAT_SRCS @@ -343,7 +342,9 @@ DESTINATION ${SERVICETYPES_INSTALL_DIR} ) install( FILES kioslave.upd DESTINATION ${DATA_INSTALL_DIR}/kconf_update ) -install( FILES + +# Headers in the "kio" subdir +set (KIO_KIO_INSTALL_HEADERS kio/kio_export.h kio/accessmanager.h kio/connection.h @@ -380,15 +381,10 @@ kio/skipdialog.h kio/udsentry.h kssl/sslui.h - DESTINATION ${INCLUDE_INSTALL_DIR}/kio COMPONENT Devel) +) -if( NOT WIN32 ) - install( FILES - kfile/kfilesharedialog.h - DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel) -endif( NOT WIN32 ) -install( FILES +set (KIO_INSTALL_HEADERS kio/kacl.h kio/kautomount.h kio/kbuildsycocaprogressdialog.h @@ -450,31 +446,40 @@ bookmarks/kbookmarkdombuilder.h bookmarks/konqbookmarkmenu.h bookmarks/kbookmarkdialog.h - DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel) +) +if( NOT WIN32 ) + set(KIO_INSTALL_HEADERS ${KIO_INSTALL_HEADERS} + kfile/kfilesharedialog.h + ) +endif( NOT WIN32 ) + if(NOT KDE_NO_DEPRECATED) -install( FILES - bookmarks/kbookmarkimporter_crash.h - kfile/kdiskfreespace.h - kio/kmimetyperesolver.h - DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel) - -install( FILES - kio/passworddialog.h - DESTINATION ${INCLUDE_INSTALL_DIR}/kio COMPONENT Devel) + set(KIO_INSTALL_HEADERS ${KIO_INSTALL_HEADERS} + bookmarks/kbookmarkimporter_crash.h + kfile/kdiskfreespace.h + kio/kmimetyperesolver.h + ) + set(KIO_KIO_INSTALL_HEADERS ${KIO_KIO_INSTALL_HEADERS} + kio/passworddialog.h + ) endif(NOT KDE_NO_DEPRECATED) if(NOT KIO_NO_SOLID) -install( FILES - kfile/kdevicelistmodel.h - kio/kstatusbarofflineindicator.h - DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel) + set(KIO_INSTALL_HEADERS ${KIO_INSTALL_HEADERS} + kfile/kdevicelistmodel.h + kio/kstatusbarofflineindicator.h + ) endif(NOT KIO_NO_SOLID) +install(FILES ${KIO_KIO_INSTALL_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/kio COMPONENT Devel) +install(FILES ${KIO_INSTALL_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel) + install(FILES kio/org.kde.KDirNotify.xml kio/org.kde.kio.FileUndoManager.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR}) +install(FILES kio/accept-languages.codes DESTINATION ${CONFIG_INSTALL_DIR}) -install(FILES kio/accept-languages.codes DESTINATION ${CONFIG_INSTALL_DIR}) +add_subdirectory( tests ) Index: kio/tests/CMakeLists.txt =================================================================== --- kio/tests/CMakeLists.txt (revision 1201251) +++ kio/tests/CMakeLists.txt (working copy) @@ -69,3 +69,11 @@ kde4_add_executable(kfstest TEST ${kfstest_SRCS}) target_link_libraries(kfstest ${KDE4_KIO_LIBS} ) +## Test for compiling all headers ## + +if (KDE4_BUILD_TESTS) + include(MacroHeaderCompilationTest) + macro_header_compilation_test(${KIO_INSTALL_HEADERS} ${KIO_KIO_INSTALL_HEADERS}) +endif (KDE4_BUILD_TESTS) + + --Boundary-00=_c+u8MhV8QOaCQAv--