1# Try to find OCC 2# Once done this will define 3# 4# OCC_FOUND - system has OCC - OpenCASCADE 5# OCC_INCLUDE_DIR - where the OCC include directory can be found 6# OCC_LIBRARY_DIR - where the OCC library directory can be found 7# OCC_LIBRARIES - Link this to use OCC 8 9############################################################################ 10# 11# Modifications Copyright (C) 2018 Seth Hillbrand 12# 13# Based on FindOpenCasCade.cmake by the FreeCAD CAx development team 14# 15# This library is free software; you can redistribute it and/or 16# modify it under the terms of the GNU Lesser General Public 17# License as published by the Free Software Foundation; either 18# version 2.1 of the License, or (at your option) any later version. 19# 20# This library is distributed in the hope that it will be useful, 21# but WITHOUT ANY WARRANTY; without even the implied warranty of 22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23# Lesser General Public License for more details. 24# 25# You should have received a copy of the GNU Lesser General Public 26# License along with this library; if not, write to the Free Software 27# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 29# Set the needed libraries 30set( OCC_LIBS 31 TKBinL 32 TKBin 33 TKBinTObj 34 TKBinXCAF 35 TKBool 36 TKBO 37 TKBRep 38 TKCAF 39 TKCDF 40 TKernel 41 TKFeat 42 TKFillet 43 TKG2d 44 TKG3d 45 TKGeomAlgo 46 TKGeomBase 47 TKHLR 48 TKIGES 49 TKLCAF 50 TKMath 51 TKMesh 52 TKMeshVS 53 TKOffset 54 TKOpenGl 55 TKPrim 56 TKService 57 TKShHealing 58 TKSTEP209 59 TKSTEPAttr 60 TKSTEPBase 61 TKSTEP 62 TKSTL 63 TKTObj 64 TKTopAlgo 65 TKV3d 66 TKVRML 67 TKXCAF 68 TKXDEIGES 69 TKXDESTEP 70 TKXMesh 71 TKXmlL 72 TKXml 73 TKXmlTObj 74 TKXmlXCAF 75 TKXSBase 76) 77 78set(OCC_TYPE "OpenCASCADE Standard Edition") 79if(WIN32) 80 if(CYGWIN OR MINGW) 81 FIND_PATH(OCC_INCLUDE_DIR Standard_Version.hxx 82 /usr/include/opencascade 83 /usr/local/include/opencascade 84 /opt/opencascade/include 85 /opt/opencascade/inc 86 ) 87 FIND_LIBRARY(OCC_LIBRARY TKernel 88 HINTS 89 ${OCC_LIBRARY_DIR} 90 /usr/lib 91 /usr/local/lib 92 /opt/opencascade/lib 93 ) 94 elseif(VCPKG_TOOLCHAIN) 95 FIND_PATH(OCC_INCLUDE_DIR 96 NAMES Standard_Version.hxx 97 PATH_SUFFIXES 98 include/opencascade 99 ) 100 FIND_LIBRARY(OCC_LIBRARY 101 NAMES TKernel 102 HINTS 103 ${OCC_LIBRARY_DIR} 104 PATH_SUFFIXES 105 lib 106 ) 107 else() 108 FIND_PATH(OCC_INCLUDE_DIR Standard_Version.hxx 109 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\SIM\\OCC\\2;Installation Path]/include" 110 ) 111 FIND_LIBRARY(OCC_LIBRARY TKernel 112 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\SIM\\OCC\\2;Installation Path]/lib" 113 ) 114 endif() 115else(WIN32) 116 FIND_PATH(OCC_INCLUDE_DIR Standard_Version.hxx 117 /usr/include/opencascade 118 /usr/local/include/opencascade 119 /opt/opencascade/include 120 /opt/opencascade/inc 121 ) 122 FIND_LIBRARY(OCC_LIBRARY TKernel 123 HINTS 124 ${OCC_LIBRARY_DIR} 125 /usr 126 /usr/local 127 /opt/opencascade 128 /opt/opencascade/lin64/gcc 129 PATH_SUFFIXES lib 130 ) 131endif(WIN32) 132 133 134if(OCC_LIBRARY) 135 GET_FILENAME_COMPONENT(OCC_LIBRARY_DIR ${OCC_LIBRARY} PATH) 136 IF(NOT OCC_INCLUDE_DIR) 137 FIND_PATH(OCC_INCLUDE_DIR Standard_Version.hxx 138 ${OCC_LIBRARY_DIR}/../inc 139 ) 140 ENDIF() 141else(OCC_LIBRARY) 142 message( "" ) 143 message( "*** OpenCascade library missing ***" ) 144 message( "Verify your OpenCascade installation or pass CMake" ) 145 message( " the library directory as '-DOCC_LIBRARY_DIR=<path>'" ) 146 message( "" ) 147 message( FATAL_ERROR "" ) 148endif(OCC_LIBRARY) 149 150if(OCC_INCLUDE_DIR AND NOT ${OCC_INCLUDE_DIR} STREQUAL "OCC_INCLUDE_DIR-NOTFOUND") 151 file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAJOR 152 REGEX "#define OCC_VERSION_MAJOR.*" 153 ) 154 string(REGEX MATCH "[0-9]+" OCC_MAJOR ${OCC_MAJOR}) 155 file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MINOR 156 REGEX "#define OCC_VERSION_MINOR.*" 157 ) 158 string(REGEX MATCH "[0-9]+" OCC_MINOR ${OCC_MINOR}) 159 file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAINT 160 REGEX "#define OCC_VERSION_MAINTENANCE.*" 161 ) 162 string(REGEX MATCH "[0-9]+" OCC_MAINT ${OCC_MAINT}) 163 164 set(OCC_VERSION_STRING "${OCC_MAJOR}.${OCC_MINOR}.${OCC_MAINT}") 165else(OCC_INCLUDE_DIR AND NOT ${OCC_INCLUDE_DIR} STREQUAL "OCC_INCLUDE_DIR-NOTFOUND") 166 message( "" ) 167 message( "*** OpenCascade header files missing ***" ) 168 message( "Verify your OpenCascade installation or pass CMake" ) 169 message( " the header directory as '-DOCC_INCLUDE_DIR=<path>'" ) 170 message( "" ) 171 message( FATAL_ERROR "" ) 172endif(OCC_INCLUDE_DIR AND NOT ${OCC_INCLUDE_DIR} STREQUAL "OCC_INCLUDE_DIR-NOTFOUND") 173 174# handle the QUIETLY and REQUIRED arguments and set OCC_FOUND to TRUE if 175# all listed variables are TRUE 176include(FindPackageHandleStandardArgs) 177FIND_PACKAGE_HANDLE_STANDARD_ARGS(OCC REQUIRED_VARS OCC_INCLUDE_DIR VERSION_VAR OCC_VERSION_STRING) 178 179if(OCC_FOUND) 180 foreach(lib IN LISTS OCC_LIBS) 181 182#Use the specified library location if given 183 find_library(OCC_TEMP_LIB ${lib} HINTS ${OCC_LIBRARY_DIR} NO_DEFAULT_PATH) 184 if(${OCC_TEMP_LIB} STREQUAL "OCC_TEMP_LIB-NOTFOUND") 185 message( "" ) 186 message( "*** OpenCascade library missing ***" ) 187 message( "Could not find a library for ${lib} at ${OCC_LIBRARY_DIR}" ) 188 message( "Verify your OpenCascade installation or pass CMake" ) 189 message( " the library directory as '-DOCC_LIBRARY_DIR=<path>'" ) 190 message( "" ) 191 message( FATAL_ERROR "" ) 192 else(${OCC_TEMP_LIB} STREQUAL "OCC_TEMP_LIB-NOTFOUND") 193 list(APPEND OCC_LIBRARIES ${OCC_TEMP_LIB}) 194 endif(${OCC_TEMP_LIB} STREQUAL "OCC_TEMP_LIB-NOTFOUND") 195 196 unset(OCC_TEMP_LIB CACHE) 197 endforeach(lib) 198 199 #Convert path names to absolute for cleaner display 200 get_filename_component(OCC_INCLUDE_DIR "${OCC_INCLUDE_DIR}" ABSOLUTE) 201 get_filename_component(OCC_LIBRARY_DIR "${OCC_LIBRARY_DIR}" ABSOLUTE) 202 message(STATUS "Found ${OCC_TYPE} version: ${OCC_VERSION_STRING}") 203 message(STATUS " ++ ${OCC_TYPE} include directory: ${OCC_INCLUDE_DIR}") 204 message(STATUS " ++ ${OCC_TYPE} shared libraries directory: ${OCC_LIBRARY_DIR}") 205endif(OCC_FOUND) 206