[Development] Qt's cmake Config.cmake and ConfigVersion.cmake files

Alexander Neundorf neundorf at kde.org
Mon May 13 21:19:27 CEST 2013


Hi,

I had a closer look at the installed cmake files.

The ConfigVersion.cmake files only check the version number. This is in many 
cases good enough.
Additionally they should check that the 32/64bit-ness of the installed libs 
and the searching project is the same, so that for a 64bit project only 64bit 
libraries are accepted.
The ConfigVersion.cmake files generated using 
WRITE_BASIC_PACKAGE_VERSION_FILE() coming with cmake contain the following 
code for that:

# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set,
# ignore it:
if("${CMAKE_SIZEOF_VOID_P}"  STREQUAL "")
   return()
endif()

# check that the installed version has the same 32/64bit-ness as the one
# which is currently searching:
if(NOT "${CMAKE_SIZEOF_VOID_P}"  STREQUAL  "4") # the 4 here is configured
              # into the ConfigVersion.cmake file at build time of the library
   math(EXPR installedBits "4 * 8")
   set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
   set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()




For the Config.cmake files:

* they don't contain any "API" documentation. I would expect documentation 
about the variables, macros etc. to be present at the top of each Config.cmake 
file.

* there are no checks that the stuff the Config.cmake reports is actually 
present on disk. So the Config.cmake file could report success and state that 
the include dir is some directory, but there is no guarantee that this 
directory actually exists.

* they fail with FATAL_ERROR if the cmake version is less than 2.8.3
In general, a find_package() must only fail if it was called with the REQUIRED 
keyword, or, I would argue, if a broken system state was detected (like 
something which the Config.cmake states is present on disk, is actually not 
present on disk, since this means something in the installation of the system 
is messed up).


Alex



More information about the Development mailing list