[CMake] Canonical use of FindPackageHandleStandardArgs

Mateusz Loskot mateusz at loskot.net
Wed Mar 3 18:06:42 EST 2010


Hi,

I'm writing some FindXXX.cmake macros [1] and I'd like to master some
best practices I use and I'm having troubles with picturing what should
canonical use of FindPackageHandleStandardArgs look like.
I'm aware I've used it incorrectly in many places.

I'm looking for confirmation if it should be something along
these

1) Set lookup mode to quiet if user explicitly asked to find MYLIB
quietly or if it's already found:

if(MYLIB_FIND_QUIETLY OR MYLIB_FOUND)
  set(FIND_MYLIB_QUIET_ARG QUIET)
endif()

2) Call find passing selected lookup mode

find_package(MYLIB ${FIND_MYLIB_QUIET_ARG})

3) Perform other checks, but do not call message() if
MYLIB_FIND_QUIETLY is requested, otherwise lookup will not be really quiet

4) Check and report results

find_package_handle_standard_args(MYLIB
  DEFAULT_MSG MYLIB_LIBRARY MY_INCLUDE_DIR)


Have I missed anything?

[1] http://github.com/mloskot/workshop/blob/master/cmake/modules/

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org


More information about the CMake mailing list