Issue
I am trying to use Cmake to build a program that uses CGAL. In my CMakeLists.txt file I have this:
find_package(CGAL REQUIRED QUIET COMPONENTS Core)
Running cmake produces this message:
CMake Warning at /usr/local/lib/cmake/CGAL/CGALConfig.cmake:92 (message):
CGAL_DATA_DIR cannot be deduced, set the variable CGAL_DATA_DIR to set the
default value of CGAL::data_file_path()
Call Stack (most recent call first):
CMakeLists.txt:30 (find_package)
I'm not sure what CGAL::data_file_path() is supposed to be and I can't locate it so far in the CGAL documentation. Does anyone know something about this?
Solution
If you open the CGAL documentation page and type the text "data_file_path"
into the search field in the upper right corner, you'll get:
std::string CGAL::data_file_path (const std::string & filename)
returns the full path of a data file from CGAL.
The data files are located in the data directory of a CGAL release or in the directory Data/data from a git branch checkout. That function uses as prefix the environment variable CGAL_DATA_DIR if set, and the value of the macro CGAL_DATA_DIR otherwise. When using cmake and a standard CGAL setup, linking the target using that function with the target CGAL::Data will automatically set the macro CGAL_DATA_DIR pointing to the data directory of the CGAL version used. The function will attempt to open the file at the returned location and will print a warning message via std::cerr if the file could not be opened.
Also you can find examples of using the data_file_path
function in the CGAL examples
directory (which is not installed by default AFAIK).
If you don't call this function in your code, then you can ignore the CMake warning you're asking about - that's what I do for a long time. Also you can get rid of this warning, if you set the CGAL_DATA_DIR
macro in the CMakeLists.txt
, for example:
set(CGAL_DATA_DIR ".")
There are other ways to set this directory prefix as well - via an environment variable CGAL_DATA_DIR
, or as an option in the CMake call etc.
Answered By - HEKTO Answer Checked By - Terry (WPSolving Volunteer)