[cmake-developers] module merge mania
Brad King
brad.king at kitware.com
Mon Sep 18 10:16:04 EDT 2006
Alexander Neundorf wrote:
> I'd like to add the following cmake modules we have in KDE svn to CMake cvs:
>
> http://websvn.kde.org/trunk/KDE/kdelibs/cmake/modules/CheckCXXCompilerFlag.cmake?view=auto
> CHECK_CXX_COMPILER_FLAG(FLAG VARIABLE)
> - Check whether the compiler supports a given flag.
>
> (if you want to I add a C compiler version too)
Yes, please.
> http://websvn.kde.org/trunk/KDE/kdelibs/cmake/modules/CheckPointerMember.cmake?view=auto
> CHECK_POINTER_MEMBER (POINTER MEMBER HEADER VARIABLE)
> - Check if the given struct or class has the specified member variable
>
> http://websvn.kde.org/trunk/KDE/kdelibs/cmake/modules/CheckStructMember.cmake?view=auto
> CHECK_STRUCT_MEMBER (STRUCT MEMBER HEADER VARIABLE)
> - Check if the given struct or class has the specified member variable
>
> http://websvn.kde.org/trunk/KDE/kdelibs/cmake/modules/CheckPrototypeExists.cmake?view=auto
> CHECK_PROTOTYPE_EXISTS (FUNCTION HEADER VARIABLE)
> - Check if the prototype for a function exists.
Sure, but the prototype check may need a separate C and CXX version too.
> And the following Find*.cmake modules:
>
> FindBZip2.cmake
> FindGIF.cmake
> FindJasper.cmake
> FindLibXml2.cmake
> FindLibXslt.cmake
> FindOpenSSL.cmake
> FindASPELL.cmake
> FindHSPELL.cmake
>
> They all follow this scheme:
>
> IF (GIF_INCLUDE_DIR AND GIF_LIBRARIES)
> # Already in cache, be silent
> SET(GIF_FIND_QUIETLY TRUE)
> ENDIF (GIF_INCLUDE_DIR AND GIF_LIBRARIES)
Good idea.
> FIND_PATH(GIF_INCLUDE_DIR gif_lib.h
> /usr/include
> /usr/local/include
> )
>
> set(POTENTIAL_GIF_LIBS gif libgif ungif libungif giflib)
> FIND_LIBRARY(GIF_LIBRARIES NAMES ${POTENTIAL_GIF_LIBS}
> PATHS
> /usr/lib
> /usr/local/lib
> )
You can leave out the /usr/* paths because these are already searched by
the CMake 2.4 FIND_PATH and FIND_LIBRARY commands.
However, you should not use GIF_LIBRARIES as the name of the variable.
It should be
FIND_LIBRARY(GIF_LIBRARY ...)
SET(GIF_LIBRARIES ${GIF_LIBRARY})
If more than one library is needed by a package it needs a separate
FIND_* result variable for each one so the user can adjust the cache,
but the project should have to reference only the XXX_LIBRARIES variable
to get the results.
> if (GIF_INCLUDE_DIR AND GIF_LIBRARIES)
> set(CMAKE_REQUIRED_INCLUDES "${GIF_INCLUDE_DIR}"
> "${CMAKE_REQUIRED_INCLUDES}")
> CHECK_STRUCT_MEMBER(GifFileType UserData gif_lib.h GIF_FOUND)
This should probably restore the original value of CMAKE_REQUIRED_INCLUDES.
> Ok to commit ?
> Especially note the part at the beginning where QUIETLY is set explicitely if
> it has already been found before.
Sure.
Thanks,
-Brad
More information about the cmake-developers
mailing list