0
votes

I am a user at a CentOS 6 server, and the admin was kind enough to install CGAL on it. First I will describe the CMakeLists.txt on my local machine, for which everything works, and then my question would be why the same does not work on the server. On my laptop, I have a project that uses the EMST example https://doc.cgal.org/latest/BGL/BGL_triangulation_2_2emst_8cpp-example.html. The "outermost" CMakeLists.txt has find_package(CGAL) and the specific CMakeLists.txt has this:

add_executable(emst emst.cpp)
target_compile_options(emst BEFORE PUBLIC -mcmodel=large PRIVATE -pg -g -O2)
target_link_libraries(emst CGAL::CGAL)

The entire thing "works on my machine"(c). Usually, in the build directory of the project, I would issue cmake ../ and then in the emst-specific subdirectory make emst (of course, all this is done by an appropriate click inside CLion). Now, this very setup does not work on the server. I get the errors such as these:

/emst.cpp:99:44: error: no matching function for call to ‘source(edge_descriptor&, Triangulation&)’
         vertex_descriptor svd = source(ed,t);
                                            ^
In file included from /usr/include/CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h:25:0,

The Admin told me this:

libraries can be found in /usr/lib64 and the header files in /usr/include/CGAL.

At some point, during the cmake ../-phase on the server, I get a message such as this:

CMake Warning (dev) at utils/CMakeLists.txt:31 (add_executable):
Policy CMP0028 is not set: Double colon in target name means ALIAS or IMPORTED target. Run "cmake --help-policy CMP0028" for policy details. Use the cmake_policy command to set the policy and suppress this warning.

Target "emst" links to target "CGAL::CGAL" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? This warning is for project developers. Use -Wno-dev to suppress it.

I tried find_package(CGAL REQUIRED) in order for it to throw an error, if not found. It appears that the package is found. What could go wrong here?

1
What is the version of CGAL on the server ? before 4.12 you need to use the use_file as described by Developer Paul.mgimeno

1 Answers

0
votes

From my experience with CGAL, you need to include the use file: include(${CGAL_USE_FILE}) and then you can use the targets as needed. Based on the output message it seems that CGAL is not found since the target CGAL::CGAL doesn't exist.

So basically you need:


find_package(CGAL)

# .. other code

include(${CGAL_USE_FILE})

add_executable(myexe ...)

target_link_libraries(myexe 
    PUBLIC
        CGAL::CGAL
        CGAL::CGAL_Core # and so on...
)