diff --git a/.gitattributes b/.gitattributes index a9e8c1e23dd..4d5cab8d650 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1591,6 +1591,7 @@ Installation/cmake/modules/CGAL_UseLAPACK.cmake -text Installation/cmake/modules/CGAL_UseLEDA.cmake -text Installation/cmake/modules/CGAL_UseMPFI.cmake -text Installation/cmake/modules/CGAL_UseRS.cmake -text +Installation/cmake/modules/CGAL_UseRS3.cmake -text Installation/cmake/modules/CGAL_UseTAUCS.cmake -text Installation/cmake/modules/CGAL_VersionUtils.cmake -text Installation/cmake/modules/FindBLAS.cmake -text @@ -1614,6 +1615,7 @@ Installation/cmake/modules/FindPackageMessage.cmake -text Installation/cmake/modules/FindQGLViewer.cmake -text Installation/cmake/modules/FindQt3-patched.cmake -text Installation/cmake/modules/FindRS.cmake -text +Installation/cmake/modules/FindRS3.cmake -text Installation/cmake/modules/FindTAUCS.cmake -text Installation/cmake/modules/Qt3Macros-patched.cmake -text Installation/cmake/modules/UseCGAL.cmake -text diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index e4c22bd0067..ee1624b23b2 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -417,7 +417,7 @@ endmacro() # Coin is used in KDS, but no FindCoin or FindCOIN exists # There exists FindF2C, FindIPE, FindMKL, but they are only used to support supporting libs # For some weird reason zlib does not work in spelling ZLIB (TODO EBEB? unify?) -list (INSERT CGAL_SUPPORTING_3RD_PARTY_LIRARIES 0 GMP GMPXX MPFR LEDA MPFI RS OpenNL TAUCS BLAS LAPACK QGLViewer zlib ESTBL NTL OpenGL) +list (INSERT CGAL_SUPPORTING_3RD_PARTY_LIRARIES 0 GMP GMPXX MPFR LEDA MPFI RS RS3 OpenNL TAUCS BLAS LAPACK QGLViewer zlib ESTBL NTL OpenGL) hide_variable(CGAL_SUPPORTING_3RD_PARTY_LIRARIES) # set some to have special prefix diff --git a/Installation/cmake/modules/CGAL_UseRS.cmake b/Installation/cmake/modules/CGAL_UseRS.cmake index 36ecd0b873c..9de7aafa22a 100644 --- a/Installation/cmake/modules/CGAL_UseRS.cmake +++ b/Installation/cmake/modules/CGAL_UseRS.cmake @@ -24,44 +24,6 @@ if( RS_FOUND AND NOT RS_SETUP ) add_definitions( ${RS_DEFINITIONS} "-DCGAL_USE_RS" ) link_libraries( ${RS_LIBRARIES} ) - # add rs3 parameters, if necessary (rs3 must be always after rsexport) - if( RS3_FOUND ) - - message( STATUS "RS3 include: ${RS3_INCLUDE_DIR}" ) - message( STATUS "RS3 definitions: ${RS3_DEFINITIONS}" ) - message( STATUS "RS3 libraries: ${RS3_LIBRARIES}" ) - - include_directories ( ${RS3_INCLUDE_DIR} ) - add_definitions( ${RS_DEFINITIONS} "-DCGAL_USE_RS3" ) - link_libraries( ${RS3_LIBRARIES} ) - - # extract RS3 version from the file rsversion.h (based on Fernando - # Cacciola's code for FindBoost.cmake) - if( EXISTS "${RS3_INCLUDE_DIR}/rsversion.h" ) - FILE(READ "${RS3_INCLUDE_DIR}/rsversion.h" _rsversion_h_CONTENTS) - STRING(REGEX REPLACE ".*#define[ \t]+rs_major[ \t]+([0-9]+).*" - "\\1" RS3_MAJOR "${_rsversion_h_CONTENTS}") - STRING(REGEX REPLACE ".*#define[ \t]+rs_middle[ \t]+([0-9]+).*" - "\\1" RS3_MIDDLE "${_rsversion_h_CONTENTS}") - STRING(REGEX REPLACE ".*#define[ \t]+rs_minor[ \t]+([0-9]+).*" - "\\1" RS3_MINOR "${_rsversion_h_CONTENTS}") - SET( RS3_LIB_VERSION "${RS3_MAJOR}.${RS3_MIDDLE}.${RS3_MINOR}" ) - IS_VERSION_LESS( "${RS3_MAJOR}.${RS3_MIDDLE}" "3.1" RS_OLD_INCLUDES ) - else( EXISTS "${RS3_INCLUDE_DIR}/rsversion.h" ) - # rsversion.h did not exist in old versions - SET( RS3_LIB_VERSION "unknown" ) - SET( RS_OLD_INCLUDES TRUE ) - endif( EXISTS "${RS3_INCLUDE_DIR}/rsversion.h" ) - - message( STATUS "RS version is ${RS3_LIB_VERSION}" ) - - if( RS_OLD_INCLUDES ) - add_definitions( "-DCGAL_RS_OLD_INCLUDES" ) - message( STATUS "Using old RS signatures" ) - endif( RS_OLD_INCLUDES ) - - endif( RS3_FOUND ) - set (RS_SETUP TRUE) endif( RS_FOUND AND NOT RS_SETUP ) diff --git a/Installation/cmake/modules/CGAL_UseRS3.cmake b/Installation/cmake/modules/CGAL_UseRS3.cmake new file mode 100644 index 00000000000..101b95bfdf2 --- /dev/null +++ b/Installation/cmake/modules/CGAL_UseRS3.cmake @@ -0,0 +1,44 @@ +# This module setups the compiler for the RS3 library. +# It assumes that find_package(RS3) was already called. + +if( RS3_FOUND AND NOT RS3_SETUP ) + + include( CGAL_UseRS ) + + # add rs3 parameters, if necessary (rs3 must be always after rsexport) + message( STATUS "RS3 include: ${RS3_INCLUDE_DIR}" ) + message( STATUS "RS3 definitions: ${RS3_DEFINITIONS}" ) + message( STATUS "RS3 libraries: ${RS3_LIBRARIES}" ) + + include_directories ( ${RS3_INCLUDE_DIR} ) + add_definitions( ${RS3_DEFINITIONS} "-DCGAL_USE_RS3" ) + link_libraries( ${RS3_LIBRARIES} ) + + # extract RS3 version from the file rsversion.h (based on Fernando + # Cacciola's code for FindBoost.cmake) + if( EXISTS "${RS3_INCLUDE_DIR}/rsversion.h" ) + FILE(READ "${RS3_INCLUDE_DIR}/rsversion.h" _rsversion_h_CONTENTS) + STRING(REGEX REPLACE ".*#define[ \t]+rs_major[ \t]+([0-9]+).*" + "\\1" RS3_MAJOR "${_rsversion_h_CONTENTS}") + STRING(REGEX REPLACE ".*#define[ \t]+rs_middle[ \t]+([0-9]+).*" + "\\1" RS3_MIDDLE "${_rsversion_h_CONTENTS}") + STRING(REGEX REPLACE ".*#define[ \t]+rs_minor[ \t]+([0-9]+).*" + "\\1" RS3_MINOR "${_rsversion_h_CONTENTS}") + SET( RS3_LIB_VERSION "${RS3_MAJOR}.${RS3_MIDDLE}.${RS3_MINOR}" ) + IS_VERSION_LESS( "${RS3_MAJOR}.${RS3_MIDDLE}" "3.1" RS3_OLD_INCLUDES ) + else( EXISTS "${RS3_INCLUDE_DIR}/rsversion.h" ) + # rsversion.h did not exist in old versions + SET( RS3_LIB_VERSION "unknown" ) + SET( RS3_OLD_INCLUDES TRUE ) + endif( EXISTS "${RS3_INCLUDE_DIR}/rsversion.h" ) + + message( STATUS "RS3 version is ${RS3_LIB_VERSION}" ) + + if( RS3_OLD_INCLUDES ) + add_definitions( "-DCGAL_RS_OLD_INCLUDES" ) + message( STATUS "Using old RS signatures" ) + endif( RS3_OLD_INCLUDES ) + + set (RS3_SETUP TRUE) + + endif( RS3_FOUND AND NOT RS3_SETUP ) diff --git a/Installation/cmake/modules/FindRS.cmake b/Installation/cmake/modules/FindRS.cmake index e8055051264..949194779ed 100644 --- a/Installation/cmake/modules/FindRS.cmake +++ b/Installation/cmake/modules/FindRS.cmake @@ -15,24 +15,12 @@ if( MPFI_FOUND ) DOC "The directory containing the RS include files" ) - find_path(RS3_INCLUDE_DIR - NAMES rs3_fncts.h - PATHS ENV RS_INC_DIR - DOC "The directory containing the RS3 include files" - ) - find_library(RS_LIBRARIES NAMES rsexport_rs PATHS ENV RS_LIB_DIR DOC "Path to the RS library" ) - find_library(RS3_LIBRARIES - NAMES rs3 - PATHS ENV RS_LIB_DIR - DOC "Path to the RS3 library" - ) - IS_VERSION_LESS("$GMP_VERSION}" "4.2.0" _IS_GMP_VERSION_TO_LOW) if(_IS_GMP_VERSION_TO_LOW) @@ -46,10 +34,6 @@ if( MPFI_FOUND ) set(RS_FOUND TRUE) endif( RS_INCLUDE_DIR AND RS_LIBRARIES ) - if( RS3_INCLUDE_DIR AND RS3_LIBRARIES ) - set(RS3_FOUND TRUE) - endif( RS3_INCLUDE_DIR AND RS3_LIBRARIES ) - if( RS_LIBRARIES ) get_filename_component(RS_LIBRARIES_DIR ${RS_LIBRARIES} PATH CACHE ) endif( RS_LIBRARIES ) diff --git a/Installation/cmake/modules/FindRS3.cmake b/Installation/cmake/modules/FindRS3.cmake new file mode 100644 index 00000000000..fc0585d70eb --- /dev/null +++ b/Installation/cmake/modules/FindRS3.cmake @@ -0,0 +1,76 @@ +# RS needs GMP 4.2 or newer, this script will fail if an old version is +# detected + +find_package( GMP ) +find_package( MPFI ) +find_package( RS ) + +if ( RS_FOUND ) + +if( MPFI_FOUND ) + + include( ${MPFI_USE_FILE} ) + include( ${RS_USE_FILE} ) + include( CGAL_VersionUtils ) + + find_path(RS3_INCLUDE_DIR + NAMES rs3_fncts.h + PATHS ENV RS_INC_DIR +# TODO uses the same environment variable + DOC "The directory containing the RS3 include files" + ) + + find_library(RS3_LIBRARIES + NAMES rs3 + PATHS ENV RS_LIB_DIR +# TODO uses the same environment variable + DOC "Path to the RS3 library" + ) + + IS_VERSION_LESS("$GMP_VERSION}" "4.2.0" _IS_GMP_VERSION_TO_LOW) + + if(_IS_GMP_VERSION_TO_LOW) + + message( STATUS + "RS3 needs GMP>=4.2. Your GMP version is ${GMP_VERSION}." ) + + else(_IS_GMP_VERSION_TO_LOW) + + if( RS3_INCLUDE_DIR AND RS3_LIBRARIES ) + set(RS3_FOUND TRUE) + endif( RS3_INCLUDE_DIR AND RS3_LIBRARIES ) + + if( RS3_LIBRARIES ) + get_filename_component(RS3_LIBRARIES_DIR ${RS3_LIBRARIES} PATH CACHE ) + endif( RS3_LIBRARIES ) + + if( NOT RS3_INCLUDE_DIR OR NOT RS3_LIBRARIES_DIR ) + include( RS3Config OPTIONAL ) + endif( NOT RS3_INCLUDE_DIR OR NOT RS3_LIBRARIES_DIR ) + + include(CGAL_FindPackageHandleStandardArgs) + + find_package_handle_standard_args( RS3 + "DEFAULT_MSG" + RS3_LIBRARIES + RS3_INCLUDE_DIR ) + + endif(_IS_GMP_VERSION_TO_LOW) + +else( MPFI_FOUND ) + + message( STATUS "RS3 requires MPFI" ) + set( RS3_FOUND FALSE ) + +endif( MPFI_FOUND ) + +else( RS3_FOUND ) + + message( STATUS "RS3 requires MPFI" ) + set( RS3_FOUND FALSE ) + +endif( RS_FOUND ) + +if(RS3_FOUND) + set(RS3_USE_FILE "CGAL_UseRS3") +endif(RS3_FOUND)