The previous installed version of `CGALConfig.cmake`, when
`CGAL_HEADER_ONLY` is true, was hard-coding a path `../../../`,
relative to the location of itself. It might be that the CMake modules
are not installed in a sub-directory with three components, relatively
to the prefix.
That way of doing it buggy. And that triggered issue with the cgal
port in vcpkg:
https://github.com/Microsoft/vcpkg/pull/5734
This patch is just another hack: it hardcodes that the relative path
can be any of:
- `../`,
- `../../`, or
- `../../../`.
In header-only, `CGALConfig.cmake` constructs the path to the root of
the CGAL installation. It used to use `../` a lot, to go back in
parent directories, but:
- that was... ugly,
- and Ninja saw a problem with that (a warning about the path to
`print_GMP_version.cpp`).
`CGALConfig.cmake` Now uses the CMake command `get_filename_component`.
The pull-request https://github.com/CGAL/cgal/pull/3413 has introduced
a side-effect: CTest was broken when `CGAL_HEADER_ONLY=OFF`, for all
tests using a `.cin` or `.cmd` file. That is due to the variable
`CGAL_CURRENT_SOURCE_DIR` that was only filled by `UseCGAL.cmake`.
Now that we forbid CGAL directories without `CMakeLists.txt`, that
variable `CGAL_CURRENT_SOURCE_DIR` is now useless, and can be removed:
`CMAKE_CURRENT_SOURCE_DIR` is sufficient. That fixes the bug with
CTest, and also makes the CMake code a bit simpler.
When `CGAL_HEADER_ONLY` and `WITH_{examples|tests|demos}`, then only
the first call to `find_package(CGAL)` does the job. The subsequent
calls return very fast, by caching the results in global properties.
That is the step 2 of the header-only effort.
Still to do:
- make it work with `make install`
- ensure that `CGAL_Core` is correctly handled with `CGAL_DISABLE_GMP`