write prefix exception into config file and use default one otherwise for find_package

This commit is contained in:
Sébastien Loriot 2012-06-21 14:27:35 +00:00
parent 3efc565b71
commit d67be721d4
2 changed files with 17 additions and 6 deletions

View File

@ -492,10 +492,15 @@ list(REMOVE_DUPLICATES CGAL_SUPPORTING_3RD_PARTY_LIBRARIES)
hide_variable(CGAL_SUPPORTING_3RD_PARTY_LIBRARIES) hide_variable(CGAL_SUPPORTING_3RD_PARTY_LIBRARIES)
# set some to have special prefix # set some to have special prefix
set(CGAL_EXT_LIB_Qt4_PREFIX "QT") # as FindQt4 sets QT_FOUND, etc .. macro( set_special_prefix library prefix)
set(CGAL_EXT_LIB_Eigen3_PREFIX "EIGEN3") # as FindEigen3 sets EIGEN3_FOUND, etc set(SPECIAL_PREFIXES "${SPECIAL_PREFIXES}set(CGAL_EXT_LIB_${library}_PREFIX \"${prefix}\")\n")
set(CGAL_EXT_LIB_QGLViewer_PREFIX "QGLVIEWER") # as FindQGLViewer sets QGLVIEWER_FOUND, etc set(CGAL_EXT_LIB_${library}_PREFIX $prefix)
set(CGAL_EXT_LIB_Coin3D_PREFIX "COIN3D") # as FindCoin3D sets COIN3D_FOUND, COIN3D_INCLUDE_DIRS, COIN3D_LIBRARIES 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) # some libraries are mandatory (stl and Boost.Thread are treated in another way)
list (INSERT CGAL_MANDATORY_3RD_PARTY_LIBRARIES 0 GMP MPFR) list (INSERT CGAL_MANDATORY_3RD_PARTY_LIBRARIES 0 GMP MPFR)

View File

@ -314,6 +314,10 @@ if( NOT CGAL_MACROS_FILE_INCLUDED )
endif() endif()
else() else()
if (NOT DEFINED CGAL_EXT_LIB_${component}_PREFIX)
set(CGAL_EXT_LIB_${component}_PREFIX ${component})
endif()
set( vlib "${CGAL_EXT_LIB_${component}_PREFIX}" ) set( vlib "${CGAL_EXT_LIB_${component}_PREFIX}" )
if ( NOT CGAL_IGNORE_PRECONFIGURED_${component} AND ${vlib}_FOUND) 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. # 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) 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) if (CGAL_ENABLE_PRECONFIG)
foreach( lib ${CGAL_SUPPORTING_3RD_PARTY_LIBRARIES} ) 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}_LIBRARIES \"${${vlib}_LIBRARIES}\" )\n")
file( APPEND ${CMAKE_BINARY_DIR}/CGALConfig.cmake " set( ${vlib}_DEFINITIONS \"${${vlib}_DEFINITIONS}\" )\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 "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 #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") 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}_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 " 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 "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} ) endif ( WITH_${lib} )
endforeach() endforeach()