I recently ran into many annoying issues with the way that CGAL has setup its default use with CMake. One issue is that its use of CMAKE_SOURCE_DIR
instead of PROJECT_SOURCE_DIR
makes it impossible to add CGAL via add_subdirectory
. As far as I can tell CGAL must always be "installed" and then found using find_package
. This makes it difficult to package up source code that will install and build all dependencies via cmake.
The second issue is that cmake suggests:
find_package(CGAL REQUIRE)
include(${CGAL_USE_FILE})
But the include(${CGAL_USE_FILE})
line is like dropping a bomb all over your cmake settings. I tried to prevent this by adding above it:
set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE)
But this has no effect due to cmake nonsense. Instead adding CACHE
seems to work:
set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "Force CGAL to maintain CMAKE flags")
So, I guess, the cmake entry for cgal should be:
find_package(CGAL REQUIRE)
include(${CGAL_USE_FILE})
set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "Force CGAL to maintain CMAKE flags")