From 1f40288aa3d04f1d20e5786405bb5edb171be01c Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Tue, 21 Jun 2016 11:20:28 +0200 Subject: [PATCH] Update cmakes in order to deal with install version of CGAL in header only mode. --- GraphicsView/src/CGAL_Qt5/CMakeLists.txt | 9 +++- .../cmake/modules/CGALConfig_install.cmake.in | 48 +++++++++++++++++++ Installation/src/CMakeLists.txt | 9 +++- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/GraphicsView/src/CGAL_Qt5/CMakeLists.txt b/GraphicsView/src/CGAL_Qt5/CMakeLists.txt index db5a66028bd..5a5517ae805 100644 --- a/GraphicsView/src/CGAL_Qt5/CMakeLists.txt +++ b/GraphicsView/src/CGAL_Qt5/CMakeLists.txt @@ -84,7 +84,14 @@ endif(CGAL_HEADER_ONLY) collect_cgal_library( CGAL_Qt5 "${additional_files}") if(CGAL_HEADER_ONLY) - set(CGAL_QT5_QTMOCCMAKE_FILES ${QTMOCCMAKE_FILES} CACHE INTERNAL "CGAL qt5 qtmoc cmake files") + FILE(GLOB files "../../include/CGAL/Qt/*") + install(FILES ${files} DESTINATION "${CGAL_INSTALL_CMAKE_DIR}/include/CGAL/Qt/") + + FILE(GLOB files "../../demo/resources/*") + install(FILES ${files} DESTINATION "${CGAL_INSTALL_CMAKE_DIR}/demo/resources") + + FILE(GLOB files "../../demo/icons/*") + install(FILES ${files} DESTINATION "${CGAL_INSTALL_CMAKE_DIR}/demo/icons") else() qt5_use_modules(CGAL_Qt5 OpenGL Svg) diff --git a/Installation/cmake/modules/CGALConfig_install.cmake.in b/Installation/cmake/modules/CGALConfig_install.cmake.in index 53fa4cb05ab..c3bb1c2e9d5 100644 --- a/Installation/cmake/modules/CGALConfig_install.cmake.in +++ b/Installation/cmake/modules/CGALConfig_install.cmake.in @@ -45,6 +45,7 @@ set(CGAL_ImageIO_USE_ZLIB "@CGAL_ImageIO_USE_ZLIB@" ) set(CGAL_VERSION "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}.${CGAL_BUILD_VERSION}") set(CGAL_USE_FILE "${CGAL_MODULES_DIR}/UseCGAL.cmake" ) +set(CGAL_GRAPHICSVIEW_PACKAGE_DIR "${CGAL_DIR}" CACHE INTERNAL "Directory containing the GraphicsView package") if ( CGAL_FIND_REQUIRED ) set( CHECK_CGAL_COMPONENT_MSG_ON_ERROR TRUE ) @@ -85,6 +86,53 @@ macro(check_cgal_component COMPONENT) if ( WITH_${CGAL_LIB} ) if(TARGET CGAL::${CGAL_LIB} OR CGAL_HEADER_ONLY ) set( ${CGAL_LIB}_FOUND TRUE ) + if ("${CGAL_LIB}" STREQUAL "CGAL_Qt5") + find_package(OpenGL QUIET) + find_package(Qt5 COMPONENTS OpenGL Svg QUIET) + + set(CGAL_Qt5_MISSING_DEPS "") + if(NOT Qt5OpenGL_FOUND) + set(CGAL_Qt5_MISSING_DEPS "Qt5OpenGL") + endif() + if(NOT Qt5Svg_FOUND) + set(CGAL_Qt5_MISSING_DEPS "${CGAL_Qt5_MISSING_DEPS} Qt5Svg") + endif() + if(NOT Qt5_FOUND) + set(CGAL_Qt5_MISSING_DEPS "${CGAL_Qt5_MISSING_DEPS} Qt5") + endif() + if(NOT OPENGL_FOUND) + set(CGAL_Qt5_MISSING_DEPS "${CGAL_Qt5_MISSING_DEPS} OpenGL") + endif() + + if(CGAL_Qt5_MISSING_DEPS) + set( ${CGAL_LIB}_FOUND FALSE ) + message(STATUS "Missing the dependencies: ${CGAL_Qt5_MISSING_DEPS} cannot be configured.") + else() + set( ${CGAL_LIB}_FOUND TRUE ) + if (CGAL_HEADER_ONLY) + message("**************************** ${CGAL_GRAPHICSVIEW_PACKAGE_DIR}") + include("${CGAL_MODULES_DIR}/Use_CGAL_Qt5_headers.cmake") + endif() + endif() + else() + if ("${CGAL_LIB}" STREQUAL "CGAL_ImageIO") + find_package( OpenGL QUIET ) + find_package( ZLIB QUIET ) + + if(OPENGL_FOUND) + set( ${CGAL_LIB}_FOUND TRUE ) + else(OPENGL_FOUND) + set( ${CGAL_LIB}_FOUND FALSE ) + message(STATUS "Notice: ImageIO disabled because it requires OpenGL.") + endif(OPENGL_FOUND) + else() + # Librairies that have no dependencies + set( ${CGAL_LIB}_FOUND TRUE ) + endif() + else() + # Librairies that have no dependencies + set( ${CGAL_LIB}_FOUND TRUE ) + endif() else() set( ${CGAL_LIB}_FOUND FALSE ) set( CHECK_${CGAL_LIB}_ERROR_TAIL " CGAL was configured with WITH_${CGAL_LIB}=ON, but one of the dependencies of ${CGAL_LIB} was not configured properly." ) diff --git a/Installation/src/CMakeLists.txt b/Installation/src/CMakeLists.txt index 0808a914de1..9d50d60d304 100644 --- a/Installation/src/CMakeLists.txt +++ b/Installation/src/CMakeLists.txt @@ -80,6 +80,9 @@ function (collect_cgal_library LIBRARY_NAME ADDITIONAL_FILES) install(EXPORT ${LIBRARY_NAME}Exports DESTINATION "${CGAL_INSTALL_CMAKE_DIR}" NAMESPACE CGAL::) + else() + # Create an empty file (install mode) in order to be able to load it later + file(WRITE "${CMAKE_BINARY_DIR}/${LIBRARY_NAME}Exports.cmake" "") endif() # We have to call configure_file twice to force double expansion of variables. @@ -200,9 +203,11 @@ CGAL_add_if_target(CGAL_Core) CGAL_add_if_target(CGAL_ImageIO) CGAL_add_if_target(CGAL_Qt5) -#if (NOT CGAL_HEADER_ONLY) # TODO Check on windows these exports +if (NOT CGAL_HEADER_ONLY) export(TARGETS ${CGAL_ACTUAL_CONFIGURED_LIBRARIES} NAMESPACE CGAL:: FILE "${CMAKE_BINARY_DIR}/CGALExports.cmake") -#endif() +else() + install(FILES "${CMAKE_BINARY_DIR}/CGALExports.cmake" DESTINATION ${CGAL_INSTALL_CMAKE_DIR}) +endif() message(STATUS "Sources for CGAL component libraries '${CGAL_CONFIGURED_LIBRARIES}' detected")