Problem with the "Importing and Exporting Guide"

I’ve spent the past three days trying to figure out what’s wrong with me since I was unable to find my installed project using the find_package() command but ultimately I think I was misled by tutorial in the official documentation.

Unless I’m missing something, installing the config file to ${CMAKE_INSTALL_PREFIX}/lib/cmake makes it impossible for the aforementioned command to find the config file, at least on Windows. Changing DESTINATION and INSTALL_DESTINATION to cmake solves the issue.

This is the doc I’m referring to.

I think that probably wants to be lib/cmake/MathFunctions rather than just lib/cmake.

Cc: @betsy.mcphail

1 Like

MR filed here:

1 Like

@ben.boeckel I found a Problem too within this Importing and Exporting Guide:

Claus-iMac:MathFunctionsComponents$ git diff
diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt
index e3cf711f7e..17ad95210b 100644
--- a/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt
+++ b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt
@@ -26,5 +26,5 @@ install(FILES Addition.h DESTINATION include)
 install(EXPORT AdditionTargets
         FILE MathFunctionsAdditionTargets.cmake
         NAMESPACE MathFunctions::
-        DESTINATION lib/cmake
+        DESTINATION lib/cmake/MathFunctions
diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt
index 4e3496dcca..5a98603eca 100644
--- a/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt
+++ b/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt
@@ -32,5 +32,5 @@ configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/
-        DESTINATION lib/cmake
+        DESTINATION lib/cmake/MathFunctions
diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt
index ffa1e3def3..be5ae65d1c 100644
--- a/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt
+++ b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt
@@ -26,5 +26,5 @@ install(FILES SquareRoot.h DESTINATION include)
 install(EXPORT SquareRootTargets
         FILE MathFunctionsSquareRootTargets.cmake
         NAMESPACE MathFunctions::
-        DESTINATION lib/cmake
+        DESTINATION lib/cmake/MathFunctions

Thanks. Do you want to file the MR or should I?

@ben.boeckel If you can do it, that would be nice.

Thank you

1 Like

Hello, Ben, I think that the addition of GNUInstallDirs in install() instead of old lib will guide better new CMake users, as it could be installed on systems which has another LIBNAME directory (e.g. lib64), thanks for attention.

That sounds like a useful addition as well. I’ll make an MR today.

1 Like