Bug 266279 - devel/cmake: cmake fails to find *.cmake files in /usr/local/lib/cmake
Summary: devel/cmake: cmake fails to find *.cmake files in /usr/local/lib/cmake
Status: Closed Works As Intended
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-kde (group)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-07 18:25 UTC by Yuri Victorovich
Modified: 2022-09-17 21:39 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer freebsd_triage 2022-09-07 18:25:11 UTC
This CMakeLists.txt file:
> cmake_minimum_required(VERSION 3.12)
> find_package(OpenCASCADE REQUIRED)

fails to find OpenCASCADE:
> $ cmake -DCMAKE_MODULE_PATH=/usr/local .
> ...skipped...
> CMake Error at CMakeLists.txt:10 (find_package):
>   By not providing "FindOpenCASCADE.cmake" in CMAKE_MODULE_PATH this project
>   has asked CMake to find a package configuration file provided by
>   "OpenCASCADE", but CMake did not find one.
> 
>   Could not find a package configuration file provided by "OpenCASCADE" with
>   any of the following names:
> 
>     OpenCASCADEConfig.cmake
>     opencascade-config.cmake
> 
>   Add the installation prefix of "OpenCASCADE" to CMAKE_PREFIX_PATH or set
>   "OpenCASCADE_DIR" to a directory containing one of the above files.  If
>   "OpenCASCADE" provides a separate development package or SDK, be sure it
>   has been installed.

opencascade-7.6.0_6 does install the file /usr/local/lib/cmake/OpenCASCADEConfig.cmake,
I am not sure if -DCMAKE_MODULE_PATH=/usr/local is required, it probably isn't.

There are at least 2 other ports that suffer from the same problem: science/axom and science/serac - they also install *.cmake files into lib/cmake.

Why aren't these projects discovered by cmake? Is it wrong to place *.cmake files into lib/cmake?
Should cmake be altered to look in lib/cmake?
Comment 1 Tobias C. Berner freebsd_committer freebsd_triage 2022-09-07 19:42:48 UTC
(In reply to Yuri Victorovich from comment #0)
Moin moin

Given that the KDE ports also have their cmake files in lib/cmake, I'd say it is searched. :)

You could try and run the configure stage with 
CMAKE_ARGS+=--trace
to get some more details.


mfg Tobias
Comment 2 Yuri Victorovich freebsd_committer freebsd_triage 2022-09-07 22:57:53 UTC
(In reply to Tobias C. Berner from comment #1)

Hi Tobias,


The cmake's trace log doesn't say why did it fail to find opencascade. Log lines are mostly about cmake's initialization process.

https://people.freebsd.org/~yuri/cmake-fails-to-find-cascade.log


Best,
Yuri
Comment 3 Adriaan de Groot freebsd_committer freebsd_triage 2022-09-17 21:39:17 UTC
First off, OpenCASCADE (cad/opencascade) is installing its CMake Config files to the wrong place. Installing into ${LOCALBASE}/share/OpenCASCADE/ would make it "just work". Like rttr, ECM, and Eigen3.

The right flag for debugging problems with finding packages using CMake is `--debug-find`, not `--trace`. Trace tells you what is executed, but it can't execute what it can't find. On the other hand, debug-find tells you where it looked, and why.

There's a difference between *modules* (e.g. FindOpenCASCADE.cmake) and *config* (e.g. OpenCASCADEConfig.cmake). Different paths are used for searching. The error message you posted tells you that find *modules* are looked-for in the MODULE path, and that *configs* are looked-for in the PREFIX. It's not super-duper clear, not there and not in the help for `find_package()`, but if you follow the instructions:


$ rm CMakeCache.txt ; cmake --debug-find . -DCMAKE_PREFIX_PATH=/usr/local/lib
<snip lots of output>

  find_package considered the following locations for OpenCASCADE's Config
  module:

    /tmp/pr-266279/CMakeFiles/pkgRedirects/OpenCASCADEConfig.cmake
    /tmp/pr-266279/CMakeFiles/pkgRedirects/opencascade-config.cmake
    /usr/local/lib/OpenCASCADEConfig.cmake
    /usr/local/lib/opencascade-config.cmake
    /usr/local/lib/cmake/OpenCASCADEConfig.cmake

  The file was found at

    /usr/local/lib/cmake/OpenCASCADEConfig.cmake