I'm creating a library (called fmi2) which I intend to install on my local machine (via a package manager) and then link to with a bunch of other libraries.
I'll be providing a Findfmi2.cmake file so that I can call find_package(fmi2)
from my other libraries, but where should this file be conventionally installed?
Here are some choices I've considered and their problems:
/usr/share/cmake-3.8/Modules/Findfmi2.cmake
- Advantage:
find_package(fmi2)
will just work - Disadvantage: Only works for one version of cmake
- Advantage:
/usr/share/cmake/Modules/Findfmi2.cmake
- Advantage: Should work for any version of cmake
- Disadvantage: This is not a default folder. We would need to add
set(CMAKE_MODULES_PATH /usr/share/cmake/Modules)
and this kills any portability.
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Findfmi2.cmake
- Advantage: Portable, just need to add
set(CMAKE_MODULES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
- Disadvantage: Not system-wide. Need to manually add this file to each library that uses it. This duplicates files in my framework.
- Advantage: Portable, just need to add