From fcb6419106b3c9a466cac6987b86ee13d1481956 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 13 Oct 2020 15:36:44 +0200 Subject: [PATCH] WIP CGAL_qt5 --- Installation/CMakeLists.txt | 31 +++++++++++++++++-- Installation/cmake/modules/CGAL_Common.cmake | 11 ------- Installation/cmake/modules/CGAL_Macros.cmake | 7 ++--- .../CGAL_SetupCGAL_Qt5Dependencies.cmake | 2 +- .../cmake/modules/CGAL_SetupFlags.cmake | 28 +++++------------ .../cmake/modules/CGAL_display_flags.cmake | 10 +----- Installation/demo/CMakeLists.txt | 6 ++-- Installation/examples/CMakeLists.txt | 6 ++-- Installation/lib/cmake/CGAL/CGALConfig.cmake | 19 ++++-------- Installation/src/CMakeLists.txt | 13 ++------ Installation/test/CMakeLists.txt | 6 ++-- Installation/test/Installation/CMakeLists.txt | 24 +++++--------- 12 files changed, 63 insertions(+), 100 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 6bc29ebd5d3..dc8f0c6a337 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -357,7 +357,6 @@ set( CGAL_Qt5_SOVERSION "14.0.0" ) message( STATUS "CGAL_SONAME_VERSION=${CGAL_SONAME_VERSION}" ) message( STATUS "CGAL_SOVERSION =${CGAL_SOVERSION}" ) -set( CGAL_BUILDING_LIBS TRUE ) set( CGAL_VERSION_DIR CGAL-${CGAL_VERSION} ) set( CGAL_MODULES_REL_DIR cmake/modules ) @@ -667,7 +666,35 @@ cache_get(CGAL_3RD_PARTY_INCLUDE_DIRS ) cache_get(CGAL_3RD_PARTY_LIBRARIES ) cache_get(CGAL_3RD_PARTY_LIBRARIES_DIRS) -add_subdirectory(src) +#add_subdirectory(src) +message("Configuring libCGAL_Qt5") + +if(NOT POLICY CMP0070 AND POLICY CMP0053) + # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. + cmake_policy(SET CMP0053 OLD) +endif() + +include(CGAL_SetupCGAL_Qt5Dependencies) + +if(CGAL_Qt5_MISSING_DEPS) + message(STATUS "libCGAL_Qt5 is missing the dependencies: ${CGAL_Qt5_MISSING_DEPS} cannot be configured.") +else() + + message( STATUS "USING Qt5_VERSION = '${Qt5Core_VERSION_STRING}'" ) + CGAL_setup_CGAL_Qt5_dependencies( CGAL_Qt5 ) + + if(COMMAND add_config_flag) + set( CGAL_HAS_QT5 TRUE ) + add_config_flag( CGAL_HAS_QT5 ) + endif() + + install(DIRECTORY " ${CGAL_GRAPHICSVIEW_PACKAGE_DIR}/include/CGAL/Qt/" DESTINATION "${CGAL_INSTALL_INC_DIR}/CGAL/Qt" COMPONENT CGAL_Qt5) + install(DIRECTORY " ${CGAL_GRAPHICSVIEW_PACKAGE_DIR}/demo/resources/" DESTINATION "${CGAL_INSTALL_CMAKE_DIR}/demo/resources" COMPONENT CGAL_Qt5) + install(DIRECTORY " ${CGAL_GRAPHICSVIEW_PACKAGE_DIR}/demo/icons/" DESTINATION "${CGAL_INSTALL_CMAKE_DIR}/demo/icons" COMPONENT CGAL_Qt5) + + message("libCGAL_Qt5 is configured") +endif() + # # Variables used when WITH_{demos|examples|tests} are TRUE diff --git a/Installation/cmake/modules/CGAL_Common.cmake b/Installation/cmake/modules/CGAL_Common.cmake index ed1fe54ad0c..c9c61644d23 100644 --- a/Installation/cmake/modules/CGAL_Common.cmake +++ b/Installation/cmake/modules/CGAL_Common.cmake @@ -24,17 +24,6 @@ if( NOT CGAL_COMMON_FILE_INCLUDED ) set( CMAKE_2_6_3_OR_ABOVE FALSE ) endif() - if ( CGAL_BUILDING_LIBS ) - option(BUILD_SHARED_LIBS "Build shared libraries" ON) - set(CGAL_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) - - if ( BUILD_SHARED_LIBS ) - message( STATUS "Building shared libraries" ) - else() - message( STATUS "Building static libraries" ) - endif() - endif() - if ( WIN32 ) find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin ) if(CMAKE_UNAME) diff --git a/Installation/cmake/modules/CGAL_Macros.cmake b/Installation/cmake/modules/CGAL_Macros.cmake index c1e16875dfd..1b1e42a09d7 100644 --- a/Installation/cmake/modules/CGAL_Macros.cmake +++ b/Installation/cmake/modules/CGAL_Macros.cmake @@ -290,10 +290,9 @@ if( NOT CGAL_MACROS_FILE_INCLUDED ) # To deal with imported targets of Qt5 and Boost, when CGAL # targets are themselves imported by another project. - if(NOT CGAL_BUILDING_LIBS) - if (${component} STREQUAL "Qt5") - find_package(Qt5 COMPONENTS OpenGL Gui Core Script ScriptTools QUIET) - endif() + + if (${component} STREQUAL "Qt5") + find_package(Qt5 COMPONENTS OpenGL Gui Core Script ScriptTools QUIET) endif() else(WITH_CGAL_${component}) diff --git a/Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake index 083efb0f5ec..1bd28be9865 100644 --- a/Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake @@ -54,7 +54,7 @@ if(NOT CGAL_Qt5_MISSING_DEPS) include(${CMAKE_CURRENT_LIST_DIR}/CGAL_Qt5_moc_and_resource_files.cmake) - if((WITH_demos OR WITH_examples OR WITH_tests OR NOT CGAL_BUILDING_LIBS) AND NOT TARGET CGAL_Qt5_moc_and_resources) + if(NOT TARGET CGAL_Qt5_moc_and_resources) add_library(CGAL_Qt5_moc_and_resources STATIC ${_CGAL_Qt5_MOC_FILES_private} ${CGAL_GRAPHICSVIEW_PACKAGE_DIR}/include/CGAL/Qt/GraphicsViewNavigation.h diff --git a/Installation/cmake/modules/CGAL_SetupFlags.cmake b/Installation/cmake/modules/CGAL_SetupFlags.cmake index 9037edc6a5e..514ad5c58c8 100644 --- a/Installation/cmake/modules/CGAL_SetupFlags.cmake +++ b/Installation/cmake/modules/CGAL_SetupFlags.cmake @@ -6,12 +6,12 @@ if ( NOT CGAL_SETUP_FLAGS_INCLUDED ) # override the flags used to build the libraries # set( CGAL_DONT_OVERRIDE_CMAKE_FLAGS_DESCRIPTION - "Set this to TRUE if you want to define or modify any of CMAKE_*_FLAGS. When this is FALSE, all the CMAKE_*_FLAGS flags are overriden with the values used when building the CGAL libs. For CGAL_*_flags (used for ADDITIONAL flags) , there is no need to set this to TRUE." + "Set this to TRUE if you want to define or modify any of CMAKE_*_FLAGS. When this is FALSE, all the CMAKE_*_FLAGS flags are overriden with the values used when building the CGAL libs. For CGAL_*_flags (used for ADDITIONAL flags) , there is no need to set this to TRUE." ) -option( CGAL_DONT_OVERRIDE_CMAKE_FLAGS +option( CGAL_DONT_OVERRIDE_CMAKE_FLAGS ${CGAL_DONT_OVERRIDE_CMAKE_FLAGS_DESCRIPTION} - FALSE + FALSE ) if ( CGAL_CONFIG_LOADED AND NOT CGAL_DONT_OVERRIDE_CMAKE_FLAGS ) @@ -19,18 +19,14 @@ if ( CGAL_CONFIG_LOADED AND NOT CGAL_DONT_OVERRIDE_CMAKE_FLAGS ) typed_cache_set ( STRING "Build type: Release, Debug, RelWithDebInfo or MinSizeRel" CMAKE_BUILD_TYPE "${CGAL_BUILD_TYPE_INIT}" ) string( TOUPPER "${CMAKE_BUILD_TYPE}" CGAL_BUILD_TYPE_UPPER ) - - if ( CGAL_BUILD_SHARED_LIBS ) - set( CGAL_LINKER_FLAGS_TYPE SHARED ) - else() - set( CGAL_LINKER_FLAGS_TYPE MODULE ) - endif() - + + set( CGAL_LINKER_FLAGS_TYPE MODULE ) + typed_cache_set ( STRING "C++ compiler flags for all build types" CMAKE_CXX_FLAGS "${CGAL_CXX_FLAGS_INIT}" ) typed_cache_set ( STRING "C++ compiler flags for ${CGAL_BUILD_TYPE_UPPER}" CMAKE_CXX_FLAGS_${CGAL_BUILD_TYPE_UPPER} "${CGAL_CXX_FLAGS_${CGAL_BUILD_TYPE_UPPER}_INIT}" ) typed_cache_set ( STRING "Linker flags for all build types" CMAKE_EXE_LINKER_FLAGS "${CGAL_${CGAL_LINKER_FLAGS_TYPE}_LINKER_FLAGS_INIT}" ) typed_cache_set ( STRING "Linker flags for ${CGAL_BUILD_TYPE_UPPER}" CMAKE_EXE_LINKER_FLAGS_${CGAL_BUILD_TYPE_UPPER} "${CGAL_${CGAL_LINKER_FLAGS_TYPE}_LINKER_FLAGS_${CGAL_BUILD_TYPE_UPPER}_INIT}" ) - + endif() typed_cache_set( BOOL ${CGAL_DONT_OVERRIDE_CMAKE_FLAGS_DESCRIPTION} CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE ) @@ -68,15 +64,7 @@ string( TOUPPER "${CMAKE_BUILD_TYPE}" CGAL_BUILD_TYPE_UPPER ) message( STATUS "USING CXXFLAGS = '${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CGAL_BUILD_TYPE_UPPER}}'" ) -if ( CGAL_BUILDING_LIBS ) - if ( BUILD_SHARED_LIBS ) - message( STATUS "USING LDFLAGS = '${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_${CGAL_BUILD_TYPE_UPPER}}'" ) - else() - message( STATUS "USING LDFLAGS = '${CMAKE_STATIC_LINKER_FLAGS} ${CMAKE_STATIC_LINKER_FLAGS_${CGAL_BUILD_TYPE_UPPER}}'" ) - endif() -else() - message( STATUS "USING EXEFLAGS = '${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CGAL_BUILD_TYPE_UPPER}}'" ) -endif() +message( STATUS "USING EXEFLAGS = '${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CGAL_BUILD_TYPE_UPPER}}'" ) endif() diff --git a/Installation/cmake/modules/CGAL_display_flags.cmake b/Installation/cmake/modules/CGAL_display_flags.cmake index 777d6402898..5367ac3c0e7 100644 --- a/Installation/cmake/modules/CGAL_display_flags.cmake +++ b/Installation/cmake/modules/CGAL_display_flags.cmake @@ -10,12 +10,4 @@ string( TOUPPER "${CMAKE_BUILD_TYPE}" CGAL_BUILD_TYPE_UPPER ) message( STATUS "USING CXXFLAGS = '${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CGAL_BUILD_TYPE_UPPER}}'" ) -if ( CGAL_BUILDING_LIBS ) - if ( BUILD_SHARED_LIBS ) - message( STATUS "USING LDFLAGS = '${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_${CGAL_BUILD_TYPE_UPPER}}'" ) - else() - message( STATUS "USING LDFLAGS = '${CMAKE_STATIC_LINKER_FLAGS} ${CMAKE_STATIC_LINKER_FLAGS_${CGAL_BUILD_TYPE_UPPER}}'" ) - endif() -else() - message( STATUS "USING EXEFLAGS = '${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CGAL_BUILD_TYPE_UPPER}}'" ) -endif() +message( STATUS "USING EXEFLAGS = '${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CGAL_BUILD_TYPE_UPPER}}'" ) diff --git a/Installation/demo/CMakeLists.txt b/Installation/demo/CMakeLists.txt index 0e3700ad729..32f0d522916 100644 --- a/Installation/demo/CMakeLists.txt +++ b/Installation/demo/CMakeLists.txt @@ -18,10 +18,8 @@ endif() list( SORT list ) -if(NOT CGAL_BUILDING_LIBS) - find_package(CGAL REQUIRED) - include(${CGAL_MODULES_DIR}/CGAL_Macros.cmake) -endif() +find_package(CGAL REQUIRED) +include(${CGAL_MODULES_DIR}/CGAL_Macros.cmake) message("== Generating build files for demos ==") foreach( entry ${list} ) diff --git a/Installation/examples/CMakeLists.txt b/Installation/examples/CMakeLists.txt index 4c415c99731..ae8af2e1062 100644 --- a/Installation/examples/CMakeLists.txt +++ b/Installation/examples/CMakeLists.txt @@ -18,10 +18,8 @@ endif() list( SORT list ) -if(NOT CGAL_BUILDING_LIBS) - find_package(CGAL REQUIRED) - include(${CGAL_MODULES_DIR}/CGAL_Macros.cmake) -endif() +find_package(CGAL REQUIRED) +include(${CGAL_MODULES_DIR}/CGAL_Macros.cmake) message("== Generating build files for examples ==") foreach( entry ${list} ) diff --git a/Installation/lib/cmake/CGAL/CGALConfig.cmake b/Installation/lib/cmake/CGAL/CGALConfig.cmake index a87e74451d9..e09f2d2c38f 100644 --- a/Installation/lib/cmake/CGAL/CGALConfig.cmake +++ b/Installation/lib/cmake/CGAL/CGALConfig.cmake @@ -80,14 +80,11 @@ include(${CGAL_MODULES_DIR}/CGAL_TweakFindBoost.cmake) set(CGAL_USE_FILE ${CGAL_MODULES_DIR}/UseCGAL.cmake) -if(CGAL_BUILDING_LIBS) - foreach(comp ${CGAL_FIND_COMPONENTS}) - if(CGAL_${comp}_FOUND) - list(APPEND CGAL_LIBRARIES CGAL_${comp}) - endif() - endforeach() - return() -endif() +foreach(comp ${CGAL_FIND_COMPONENTS}) + if(CGAL_${comp}_FOUND) + list(APPEND CGAL_LIBRARIES CGAL_${comp}) + endif() +endforeach() foreach(comp ${CGAL_FIND_COMPONENTS}) if(NOT comp MATCHES "Core|ImageIO|Qt5") @@ -136,11 +133,7 @@ include(CGAL_setup_target_dependencies) foreach(cgal_lib ${CGAL_LIBRARIES}) set(WITH_${cgal_lib} TRUE) if(${cgal_lib}_FOUND AND NOT TARGET ${cgal_lib}) - if(CGAL_BUILDING_LIBS OR CMAKE_VERSION VERSION_LESS "3.11") - add_library(${cgal_lib} INTERFACE) - else() - add_library(${cgal_lib} INTERFACE IMPORTED GLOBAL) - endif() + add_library(${cgal_lib} INTERFACE IMPORTED GLOBAL) if(NOT TARGET CGAL::${cgal_lib}) add_library(CGAL::${cgal_lib} ALIAS ${cgal_lib}) endif() diff --git a/Installation/src/CMakeLists.txt b/Installation/src/CMakeLists.txt index 1054aba4e5d..569402b1d59 100644 --- a/Installation/src/CMakeLists.txt +++ b/Installation/src/CMakeLists.txt @@ -1,19 +1,10 @@ function (collect_cgal_library LIBRARY_NAME ADDITIONAL_FILES) - if(CGAL_BUILD_SHARED_LIBS) - set(CGAL_LIB_PREFIX "") - else() - set(CGAL_LIB_PREFIX "lib") - endif() + set(CGAL_LIB_PREFIX "lib") set(RELEASE_MANGLED_NAME "${CGAL_LIB_PREFIX}${LIBRARY_NAME}-${CGAL_TOOLSET}-mt-${CGAL_FULL_VERSION}" ) set(DEBUG_MANGLED_NAME "${CGAL_LIB_PREFIX}${LIBRARY_NAME}-${CGAL_TOOLSET}-mt-gd-${CGAL_FULL_VERSION}" ) - if(CGAL_BUILD_SHARED_LIBS AND WIN32) - configure_file(${CGAL_INSTALLATION_PACKAGE_DIR}/src/CGAL_libs_verinfo.rc.in ${LIBRARY_NAME}_verinfo.rc @ONLY) - set(rc_file ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}_verinfo.rc) - else() - set(rc_file ) - endif() + set(rc_file ) add_library(${LIBRARY_NAME} INTERFACE) diff --git a/Installation/test/CMakeLists.txt b/Installation/test/CMakeLists.txt index df238f83028..3559145e988 100644 --- a/Installation/test/CMakeLists.txt +++ b/Installation/test/CMakeLists.txt @@ -18,10 +18,8 @@ endif() list( SORT list ) -if(NOT CGAL_BUILDING_LIBS) - find_package(CGAL REQUIRED) - include(${CGAL_MODULES_DIR}/CGAL_Macros.cmake) -endif() +find_package(CGAL REQUIRED) +include(${CGAL_MODULES_DIR}/CGAL_Macros.cmake) message("== Generating build files for tests ==") foreach( entry ${list} ) diff --git a/Installation/test/Installation/CMakeLists.txt b/Installation/test/Installation/CMakeLists.txt index 1cefac9ba03..01706321155 100644 --- a/Installation/test/Installation/CMakeLists.txt +++ b/Installation/test/Installation/CMakeLists.txt @@ -27,8 +27,8 @@ macro(create_link_to_program COMPONENT ) add_to_cached_list( CGAL_EXECUTABLE_TARGETS link_to_${COMPONENT} ) endmacro() - -find_package(CGAL QUIET COMPONENTS Core) +find_package(Qt5 QUIET) +find_package(CGAL QUIET COMPONENTS Core Qt5) if ( CGAL_FOUND ) @@ -56,27 +56,17 @@ if ( CGAL_FOUND ) create_link_to_program(CGAL) - if ( WITH_CGAL_Core ) + if ( TARGET CGAL::CGAL_Core ) create_link_to_program(CGAL_Core) endif() - if ( WITH_CGAL_ImageIO ) + if ( TARGET CGAL::CGAL_ImageIO ) create_link_to_program(CGAL_ImageIO) endif() - if ( WITH_CGAL_Qt4 ) - find_package(Qt4 QUIET) - if( QT4_FOUND ) - include(${QT_USE_FILE}) - create_link_to_program(CGAL_Qt4) - endif() - endif() - if ( WITH_CGAL_Qt5 ) - find_package(Qt5 QUIET) - if( Qt5_FOUND ) - create_link_to_program(CGAL_Qt5) - endif() + if ( TARGET CGAL::CGAL_Qt5 ) + create_link_to_program(CGAL_Qt5) endif() if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL Windows) @@ -235,7 +225,7 @@ list(APPEND test_config_lst "test_config_file_3") if(CGAL_Qt5_FOUND) #configure cgal for a non standard install with qt5 add_test(NAME config_non_standard_cgal_qt5 - COMMAND ${CMAKE_COMMAND} ${GENERATOR} ${INIT_FILE} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${NON_STANDARD_INSTALL_PREFIX}/non_standard_install_qt5 -DCGAL_INSTALL_LIB_DIR=lib -DWITH_CGAL_Qt5=ON + COMMAND ${CMAKE_COMMAND} ${GENERATOR} ${INIT_FILE} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${NON_STANDARD_INSTALL_PREFIX}/non_standard_install_qt5 -DCGAL_INSTALL_LIB_DIR=lib "${CGAL_SOURCE_DIR}" WORKING_DIRECTORY "${NON_STANDARD_INSTALL_PREFIX}/non_standard_build_qt5") #install cgal in the non standard place