FindOCC.cmake 2.45 KB
Newer Older
mt4313's avatar
mt4313 committed
1 2 3 4
SET(TEST_ENV $ENV{OCE_ROOT})
IF(NOT DEFINED OCE_DIR AND DEFINED TEST_ENV)
    FILE(GLOB OCE_DIR $ENV{OCE_ROOT}/lib/oce-*)
ENDIF()
5

mt4313's avatar
mt4313 committed
6 7 8 9
SET(TEST_ENV $ENV{OCE_DIR})
IF(NOT DEFINED OCE_DIR AND DEFINED TEST_ENV)
    SET(OCE_DIR $ENV{OCE_DIR})
ENDIF()
10

mt4313's avatar
mt4313 committed
11
SET(OCE_FIND_COMPONENTS ${OCC_LIB_LIST})
12

mt4313's avatar
mt4313 committed
13 14 15 16 17 18 19 20 21 22 23
#First try to find OpenCASCADE Community Edition
IF(NOT DEFINED OCE_DIR)
#Check for OSX needs to come first because UNIX evaluates to true on OSX
    IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
        IF(DEFINED MACPORTS_PREFIX)
            FIND_PACKAGE(OCE 0.17 QUIET HINTS ${MACPORTS_PREFIX}/Library/Frameworks)
        ELSEIF(DEFINED HOMEBREW_PREFIX)
            FIND_PACKAGE(OCE 0.17 QUIET HINTS ${HOMEBREW_PREFIX}/Cellar/oce/*)
        ENDIF()
    ENDIF()
ENDIF()
24

mt4313's avatar
mt4313 committed
25 26
FIND_PACKAGE(OCE 0.17 QUIET)

Michael Turner's avatar
fix  
Michael Turner committed
27
SET(OCC_FOUND FALSE)
's avatar
committed
28

mt4313's avatar
mt4313 committed
29 30 31 32 33 34 35
IF(OCE_FOUND AND OCE_ALL_FOUND)
    MESSAGE(STATUS "OpenCASCADE Community Edition has been found with all required components.")
    SET(OCC_INCLUDE_DIR ${OCE_INCLUDE_DIRS})
    SET(OCC_FOUND TRUE)
ELSE(OCE_FOUND AND OCE_ALL_FOUND) #look for OpenCASCADE
    MESSAGE(STATUS "OpenCASCADE Community Edition could not be found or has missing components.")
    SET(OpenCASCADE_FIND_COMPONENTS ${OCE_FIND_COMPONENTS})
36
    FIND_PACKAGE(OpenCASCADE)
's avatar
committed
37

mt4313's avatar
mt4313 committed
38 39 40
    IF(OpenCASCADE_FOUND)
        MESSAGE(STATUS "OpenCASCADE has been found with all required components.")
        SET(OCC_INCLUDE_DIR ${OpenCASCADE_INCLUDE_DIR})
Michael Turner's avatar
Michael Turner committed
41
        SET(OCC_FOUND TRUE)
mt4313's avatar
mt4313 committed
42 43
    ELSE()
        MESSAGE(STATUS "OpenCASCADE could not be found or has missing components.")
44 45
    ENDIF()

mt4313's avatar
mt4313 committed
46
ENDIF(OCE_FOUND AND OCE_ALL_FOUND)
47

mt4313's avatar
mt4313 committed
48 49 50 51 52 53 54 55 56 57
IF(OCC_FOUND)
    FILE(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAJOR
        REGEX "#define OCC_VERSION_MAJOR.*")
    STRING(REGEX MATCH "[0-9]+" OCC_MAJOR ${OCC_MAJOR})
    FILE(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MINOR
        REGEX "#define OCC_VERSION_MINOR.*")
    STRING(REGEX MATCH "[0-9]+" OCC_MINOR ${OCC_MINOR})
    FILE(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAINT
        REGEX "#define OCC_VERSION_MAINTENANCE.*")
    STRING(REGEX MATCH "[0-9]+" OCC_MAINT ${OCC_MAINT})
58

mt4313's avatar
mt4313 committed
59 60 61 62 63 64 65 66 67 68
    SET(OCC_VERSION_STRING "${OCC_MAJOR}.${OCC_MINOR}.${OCC_MAINT}")

    IF(OCC_VERSION_STRING VERSION_LESS 6.8)
        MESSAGE(STATUS "OCC version too low, will build from source")
        SET(OCC_FOUND FALSE)
    ELSE()
        MESSAGE(STATUS "-- Found OCE/OpenCASCADE with OCC version: ${OCC_VERSION_STRING}")
        SET(OCC_LIBRARIES ${OCE_FIND_COMPONENTS})
    ENDIF()
ENDIF(OCC_FOUND)