[CMake] find_file unexpected finds
Nils Gladitz
nilsgladitz at gmail.com
Fri May 8 09:26:06 EDT 2015
On 05/08/2015 03:02 PM, Jörg Kreuzberger wrote:
> the project now includes the correct FinLibExternV2.cmake (using include( ../libexternv1/cmake/FindLibExternV2.cmake )
> in FindLibExternV2, the lib search with findfile
include() for find modules?
Find modules that are part of the package which they are meant to locate?
That sounds suspiciously like your find modules are trying to be package
configuration files.
Assuming the packages are under your control you might want to switch to
actual package configuration files [1].
>
> find_file( <VAR > alib.lib PATHS ${CMAKE_CURRENT_LIST_DIR}/../lib/win/alib.lib )
>
> My problem is: it always finds the lib from the libexternv1 directory, seems to ignore the PATHS hint. FindLibExternV1.cmake is never included.
For libraries you normally want find_library() rather than find_file().
PATHS and HINTS are expected to be directory paths not file paths.
Given that you already know location and name of the library why even
use find_*()?
Is it possible that <VAR> is already set in CMakeCache.txt?
find_file(<VAR>) is a noop if <VAR> has already been set to a path from
an earlier run.
Nils
[1]
http://www.cmake.org/cmake/help/v3.2/manual/cmake-packages.7.html#using-packages
More information about the CMake
mailing list