I am trying to write a Find Module for a package that I have installed. But I am having trouble understanding the CMake functions.
Here is a snippet of my code.
find_package(PkgConfig)
pkg_check_modules(PC_zcm QUIET zcm)
find_path(zcm_INCLUDE_DIR
NAMES zcm.h
PATHS $ENV{PATH}
)
mark_as_advanced(zcm_FOUND zcm_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(zcm DEFAULT_MSG
REQUIRED_VARS zcm_INCLUDE_DIR
)
find_path()
is able to find my zcm_INCLUDE_DIR
just fine: /usr/bin/zcm/usr/local/include
But find_package_handle_standard_args() gives
-- Could NOT find zcm (missing: REQUIRED_VARS)
My directory tree looks like this:
└── zcm
├── eventlog.h
├── json
│ ├── json-forwards.h
│ └── json.h
├── message_tracker.hpp
├── tools
│ ├── IndexerPlugin.hpp
│ └── TranscoderPlugin.hpp
├── transport
│ └── generic_serial_transport.h
├── transport.h
├── transport_register.hpp
├── transport_registrar.h
├── url.h
├── util
│ └── Filter.hpp
├── zcm-cpp-impl.hpp
├── zcm-cpp.hpp
├── zcm.h
└── zcm_coretypes.h
My understanding is find_package_handle_standard_args()
attempts to find the package at the path, which sounds like it would be straightforward as the path is already determined.
As for REQUIRED_VARS
the docs just say "Specify the variables which are required for this package." Which doesn't tell much for a noobie like me.