From d67be721d45ab25be04ff6fb6c287cd50b768e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 21 Jun 2012 14:27:35 +0000 Subject: [PATCH] write prefix exception into config file and use default one otherwise for find_package --- Installation/CMakeLists.txt | 13 +++++++++---- Installation/cmake/modules/CGAL_Macros.cmake | 10 ++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 698c8a9163e..f8949c16589 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -492,10 +492,15 @@ list(REMOVE_DUPLICATES CGAL_SUPPORTING_3RD_PARTY_LIBRARIES) hide_variable(CGAL_SUPPORTING_3RD_PARTY_LIBRARIES) # set some to have special prefix -set(CGAL_EXT_LIB_Qt4_PREFIX "QT") # as FindQt4 sets QT_FOUND, etc .. -set(CGAL_EXT_LIB_Eigen3_PREFIX "EIGEN3") # as FindEigen3 sets EIGEN3_FOUND, etc -set(CGAL_EXT_LIB_QGLViewer_PREFIX "QGLVIEWER") # as FindQGLViewer sets QGLVIEWER_FOUND, etc -set(CGAL_EXT_LIB_Coin3D_PREFIX "COIN3D") # as FindCoin3D sets COIN3D_FOUND, COIN3D_INCLUDE_DIRS, COIN3D_LIBRARIES +macro( set_special_prefix library prefix) +set(SPECIAL_PREFIXES "${SPECIAL_PREFIXES}set(CGAL_EXT_LIB_${library}_PREFIX \"${prefix}\")\n") +set(CGAL_EXT_LIB_${library}_PREFIX $prefix) +endmacro() + +set_special_prefix(Qt4 QT) +set_special_prefix(Eigen3 EIGEN3) +set_special_prefix(QGLViewer QGLVIEWER) +set_special_prefix(Coin3D COIN3D) # some libraries are mandatory (stl and Boost.Thread are treated in another way) list (INSERT CGAL_MANDATORY_3RD_PARTY_LIBRARIES 0 GMP MPFR) diff --git a/Installation/cmake/modules/CGAL_Macros.cmake b/Installation/cmake/modules/CGAL_Macros.cmake index 85b786e21f5..84008af789c 100644 --- a/Installation/cmake/modules/CGAL_Macros.cmake +++ b/Installation/cmake/modules/CGAL_Macros.cmake @@ -314,6 +314,10 @@ if( NOT CGAL_MACROS_FILE_INCLUDED ) endif() else() + if (NOT DEFINED CGAL_EXT_LIB_${component}_PREFIX) + set(CGAL_EXT_LIB_${component}_PREFIX ${component}) + endif() + set( vlib "${CGAL_EXT_LIB_${component}_PREFIX}" ) if ( NOT CGAL_IGNORE_PRECONFIGURED_${component} AND ${vlib}_FOUND) @@ -379,6 +383,9 @@ if( NOT CGAL_MACROS_FILE_INCLUDED ) # There is also a version of CGALConfig.cmake that is prepared in case CGAL in installed in CMAKE_INSTALL_PREFIX. configure_file("${CGAL_MODULES_DIR}/CGALConfig_install.cmake.in" "${CMAKE_BINARY_DIR}/config/CGALConfig.cmake" @ONLY) + #write prefix exceptions + file( APPEND ${CMAKE_BINARY_DIR}/CGALConfig.cmake "${SPECIAL_PREFIXES}\n") + file( APPEND ${CMAKE_BINARY_DIR}/config/CGALConfig.cmake "${SPECIAL_PREFIXES}") if (CGAL_ENABLE_PRECONFIG) foreach( lib ${CGAL_SUPPORTING_3RD_PARTY_LIBRARIES} ) @@ -394,7 +401,7 @@ if( NOT CGAL_MACROS_FILE_INCLUDED ) file( APPEND ${CMAKE_BINARY_DIR}/CGALConfig.cmake " set( ${vlib}_LIBRARIES \"${${vlib}_LIBRARIES}\" )\n") file( APPEND ${CMAKE_BINARY_DIR}/CGALConfig.cmake " set( ${vlib}_DEFINITIONS \"${${vlib}_DEFINITIONS}\" )\n") file( APPEND ${CMAKE_BINARY_DIR}/CGALConfig.cmake "endif()\n\n") - file( APPEND ${CMAKE_BINARY_DIR}/CGALConfig.cmake " set( CGAL_EXT_LIB_${lib}_PREFIX \"${CGAL_EXT_LIB_${lib}_PREFIX}\" )\n") + #the next 'if' is needed to avoid ${vlib} config variables to be overidden in case of a local configuration change file( APPEND ${CMAKE_BINARY_DIR}/config/CGALConfig.cmake "if (NOT CGAL_IGNORE_PRECONFIGURED_${vlib})\n") @@ -404,7 +411,6 @@ if( NOT CGAL_MACROS_FILE_INCLUDED ) file( APPEND ${CMAKE_BINARY_DIR}/config/CGALConfig.cmake " set( ${vlib}_LIBRARIES \"${${vlib}_LIBRARIES}\" )\n") file( APPEND ${CMAKE_BINARY_DIR}/config/CGALConfig.cmake " set( ${vlib}_DEFINITIONS \"${${vlib}_DEFINITIONS}\" )\n") file( APPEND ${CMAKE_BINARY_DIR}/config/CGALConfig.cmake "endif()\n\n") - file( APPEND ${CMAKE_BINARY_DIR}/config/CGALConfig.cmake " set( CGAL_EXT_LIB_${lib}_PREFIX \"${CGAL_EXT_LIB_${lib}_PREFIX}\" )\n") endif ( WITH_${lib} ) endforeach()