How to build frameworks going forward.
Stephen Kelly
steveire at gmail.com
Sat Aug 27 08:31:17 UTC 2011
Hi,
I've just pushed some stuff to the frameworks branch for building Qt
frameworks with CMake. It is not KDE specific. It's just some generalized
stuff from Grantlee.
If I then use this patch to the itemmodels framework:
diff --git a/tier1/itemmodels/CMakeLists.txt
b/tier1/itemmodels/CMakeLists.txt
index 0c30f77..206a745 100644
--- a/tier1/itemmodels/CMakeLists.txt
+++ b/tier1/itemmodels/CMakeLists.txt
@@ -1,9 +1,22 @@
+cmake_minimum_required(VERSION 2.8)
+
project(itemmodels)
-include_directories(
- ${QT_INCLUDES}
- ${CMAKE_CURRENT_BINARY_DIR}
-)
+find_package(extra-cmake-modules REQUIRED)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${EXTRA_CMAKE_MODULES_MODULE_PATH})
+
+include(ECMVersion)
+
+# -- Maintained by scripty
+ecm_version(5 0 0)
+# --
+
+include(ECMQtFramework)
+
+find_package(Qt4 REQUIRED QtCore QtGui)
+
+include(${QT_USE_FILE})
include(FeatureSummary)
diff --git a/tier1/itemmodels/src/CMakeLists.txt
b/tier1/itemmodels/src/CMakeLists.txt
index 32366d2..7b2e8a1 100644
--- a/tier1/itemmodels/src/CMakeLists.txt
+++ b/tier1/itemmodels/src/CMakeLists.txt
@@ -11,17 +11,18 @@ set(itemmodels_SRCS
kviewstatemaintainerbase.cpp
)
-kf5_add_library(itemmodels ${LIBRARY_TYPE} ${itemmodels_SRCS})
+add_library(itemmodels ${LIBRARY_TYPE} ${itemmodels_SRCS})
+generate_export_header(itemmodels)
target_link_libraries(itemmodels ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
-set_target_properties(itemmodels PROPERTIES VERSION
${GENERIC_LIB_VERSION}
- SOVERSION
${GENERIC_LIB_SOVERSION}
+set_target_properties(itemmodels PROPERTIES VERSION ${ECM_VERSION_STRING}
+ SOVERSION ${ECM_SOVERSION}
)
-install(TARGETS itemmodels EXPORT kdelibsLibraryTargets
${INSTALL_TARGETS_DEFAULT_ARGS})
+install(TARGETS itemmodels ${ECM_TARGET_DEFAULT_ARGS})
-install( FILES
+install(FILES
kbreadcrumbselectionmodel.h
kcheckableproxymodel.h
klinkitemselectionmodel.h
@@ -35,4 +36,3 @@ install( FILES
${CMAKE_CURRENT_BINARY_DIR}/itemmodels_export.h
DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel
)
-
And then when I install I get this:
-- Install configuration: "debug"
-- Installing: /home/kde-
devel/dev/qt47/kde46/lib/cmake/itemmodels/itemmodelsConfig.cmake
-- Installing: /home/kde-
devel/dev/qt47/kde46/lib/cmake/itemmodels/itemmodelsConfigVersion.cmake
-- Old export file "/home/kde-
devel/dev/qt47/kde46/lib/cmake/itemmodels/itemmodelsTargets.cmake" will be
replaced. Removing files [/home/kde-
devel/dev/qt47/kde46/lib/cmake/itemmodels/itemmodelsTargets-debug.cmake].
-- Installing: /home/kde-
devel/dev/qt47/kde46/lib/cmake/itemmodels/itemmodelsTargets.cmake
-- Installing: /home/kde-
devel/dev/qt47/kde46/lib/cmake/itemmodels/itemmodelsTargets-debug.cmake
-- Installing: /home/kde-
devel/dev/qt47/kde46/lib/cmake/itemmodels/itemmodelsUse.cmake
-- Installing: /home/kde-devel/dev/qt47/kde46/lib/libitemmodels.so.5.0.0
-- Up-to-date: /home/kde-devel/dev/qt47/kde46/lib/libitemmodels.so.5
-- Up-to-date: /home/kde-devel/dev/qt47/kde46/lib/libitemmodels.so
-- Set runtime path of "/home/kde-
devel/dev/qt47/kde46/lib/libitemmodels.so.5.0.0" to "/home/kde-
devel/dev/qt47/lib"
-- Up-to-date: /home/kde-
devel/dev/qt47/kde46/include/kbreadcrumbselectionmodel.h
-- Up-to-date: /home/kde-devel/dev/qt47/kde46/include/kcheckableproxymodel.h
-- Up-to-date: /home/kde-
devel/dev/qt47/kde46/include/klinkitemselectionmodel.h
-- Up-to-date: /home/kde-
devel/dev/qt47/kde46/include/krecursivefilterproxymodel.h
-- Up-to-date: /home/kde-
devel/dev/qt47/kde46/include/kdescendantsproxymodel.h
-- Up-to-date: /home/kde-devel/dev/qt47/kde46/include/kidentityproxymodel.h
-- Up-to-date: /home/kde-devel/dev/qt47/kde46/include/kviewstateserializer.h
-- Up-to-date: /home/kde-
devel/dev/qt47/kde46/include/kviewstatemaintainerbase.h
-- Up-to-date: /home/kde-
devel/dev/qt47/kde46/include/kmodelindexproxymapper.h
-- Up-to-date: /home/kde-devel/dev/qt47/kde46/include/kselectionproxymodel.h
-- Installing: /home/kde-devel/dev/qt47/kde46/include/itemmodels_export.h
Note that:
* I don't need to include CMAKE_CURRENT_BINARY_DIR. The ECMQtFramework file
sets CMAKE_INCLUDE_CURRENT_DIR so we don't have to.
* I'm not using kf5_add_library, but just add_library. That means that I
don't have ENABLE_FINAL anymore and the LINK_INTERFACE list is not cleared.
If those things are important ECM or CMake should get support for them in
some form.
* I didn't have to do anything to get Config, ConfigVersion, Targets and USE
files. The ECMQtFramework file takes care of that.
I can then use itemmodels like this:
cmake_minimum_required(VERSION 2.8)
project(radiobuttonlistmodel)
find_package(itemmodels REQUIRED)
include(${itemmodels_USE_FILE})
add_executable(radiobuttonlistmodel main.cpp rbm.cpp)
target_link_libraries(radiobuttonlistmodel ${itemmodels_LIBRARY})
Easy?
What do you think? Is this something we should make standard in frameworks?
Note to try this out you need this patch:
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7bf2c1aa3ecd4921a19391cd9b37d78045a6e65d
Thanks,
Steve.
More information about the Kde-buildsystem
mailing list