You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
5.8 KiB

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