jll63 / yomm2

Fast, orthogonal, open multi-methods. Solve the Expression Problem in C++17.
Boost Software License 1.0
348 stars 18 forks source link

Boost always installs even though package exists on system #43

Closed FabienPean closed 5 months ago

FabienPean commented 5 months ago

https://github.com/jll63/yomm2/blob/179d1c3ac58d103c3f7defe2081de12aa368057d/cmake/find_or_download_package.cmake#L8-L12

The call to find_package in the script forces to the CONFIG mode due to HINTS manually inserted. It means it skips the FindBoost module, thus does not find any pre-installed Boost leading to always downloading the package.

Hence the vcpkg patch there https://github.com/microsoft/vcpkg/blob/b4a3d89125e45bc8f80fb94bef9761d4f4e14fb9/ports/yomm2/fix_install.patch#L9-L10 which could also be replaced by

diff --git a/cmake/find_or_download_package.cmake b/cmake/find_or_download_package.cmake
index 7e8a282..f550c2d 100644
--- a/cmake/find_or_download_package.cmake
+++ b/cmake/find_or_download_package.cmake
@@ -7,6 +7,5 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
   set(DEPENDENCY_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/dependencies/${PACKAGE})
   find_package(
     ${PACKAGE} QUIET
-     HINTS ${DEPENDENCY_INSTALL_PREFIX} ${CMAKE_INSTALL_PREFIX}
   )
  if(NOT ${${PACKAGE}_FOUND})

The best would be to clear out the CMake scripts related to Boost and rely on find_package + FetchContent https://github.com/boostorg/cmake