find_file unexpected finds

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

find_file unexpected finds

Jörg Kreuzberger
Hi!

i have a problem with find_file, finding files in directory structures not part of the PATHS option and no other CMAKE VARIABLES relevant to find_file set.

I use find_file to find external libraries in different versions, they are located in different git repos.
each repo has its find script
E.g.

<base>/libexternv1/cmake/FindLibExternV1.cmake
<base>/libexternv1/lib/win/alib.lib
<base>/libexternv2/cmake/FindLibExternV2.cmake
<base>/libexternv2/lib/win/alib.lib
<base>/project/CMakeLists.txt -> the CMAKE_SOURCE_DIR

the project now includes the correct FinLibExternV2.cmake (using include( ../libexternv1/cmake/FindLibExternV2.cmake )
in FindLibExternV2, the lib search with findfile

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.

Environment: CMAKE 3.2.2 and Visual Studio Generator 2013 x64 on Win7

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: find_file unexpected finds

Nils Gladitz-2
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
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake