Reputation: 8313
I'm trying to write a FindQwt.cmake module. I've googled the existing modules and none of them work for my installation.
My module's find path call currently looks like this:
find_path ( QWT_INCLUDE_DIR
NAMES qwt_global.h
HINTS ${QT_INCLUDE_DIR}
PATHS
/opt
/usr/include
/usr/local
/usr/local/include
"$ENV{LIB_DIR}/include"
"$ENV{INCLUDE}"
PATH_SUFFIXES qwt
)
The actual qwt_global.h
file resides at the path: /opt/qwt-6.1.2/src/qwt_global.h
I can get this to work if I add the path suffix qwt-6.1.2/src
, but it seems to me like it's going to defeat the purpose of having a find module if I need to hard code every version into it (Assume I'm checking later in the module that the versions are compatible and don't care which version is used within the compatible set).
I've tried qwt*
and qwt*/src
in the PATH_SUFFIXES, but to no avail.
It seems like this would be a common problem. Does anyone know how to fix this find_path
call to be robust to having version numbers in the path?
EDIT: I'm using cmake 3.0.2
Upvotes: 1
Views: 1942
Reputation: 14947
You can use FILE(GLOB ...)
for this.
file(GLOB QWT_SEARCH_PATHS "/opt/qwt-*" "/usr/include/qwt-*")
find_path(QWT_INCLUDE_DIR
NAMES qwt_global.h
PATHS ${QWT_SEARCH_PATHS})
For a cleaner implementation, build a list of directories, then iterate the list to append the "qwt-*" glob.
Upvotes: 2