Wrong CMake config file used
I have mshr
compiled from source and when i try to find the library in a CMakeLists.txt file,CMake ends up choosing the wrong config file.
In more detail, my folder structure is as follows:
- /opt/fenics/source: all the source
- /opt/fenics/install: install destination
Now, at least two config files are present: /opt/fenics/source/mshr/build/mshr-config.cmake
and /opt/fenics/install/lib/CMake/mshr/mshr-config.cmake
In my CMakeLists.txt I do
find_package(mshr REQUIRED
PATHS /opt/fenics/install/lib/CMake/mshr/)
include(${MSHR_USE_FILE})
message("mshr found!")
message(" config file is " ${mshr_CONFIG})
message(" considered config file is " ${mshr_CONSIDERED_CONFIGS})
message(" libraries dir is " ${MSHR_LIBRARIES_DIRS})
message(" library is " ${MSHR_LIBRARIES})
message(" include dir is " ${MSHR_INCLUDE_DIRS})
which yields the output
mshr found!
config file is /opt/fenics/source/mshr/build/mshr-config.cmake
considered config file is /opt/fenics/source/mshr/build/mshr-config.cmake
libraries dir is /opt/fenics/source/mshr/build/lib
library is mshr
include dir is /opt/fenics/source/mshr/include
If I delete the file /opt/fenics/source/mshr/build/mshr-config.cmake
, then CMake finds the correct configuration file using the PATHS
directive, which earlier was ignored. If I now remove the PATHS
directive, CMake cannot find the correct configuration file.
Ideally, CMake should be able to find the installed [correct] config file without the PATHS
directive.
I am on a standard Debian testing OS.