cmake_minimum_required( VERSION 3.16 )
project( {{ name }}
         LANGUAGES CXX )


find_package( Python REQUIRED COMPONENTS Development Interpreter)
find_package( VTK REQUIRED
  COMPONENTS
    WrappingPythonCore
    RenderingCore
    RenderingOpenGL2
    CommonDataModel
    CommonExecutionModel
    freetype
)
find_package( pybind11 REQUIRED )
find_package( OpenCASCADE REQUIRED )

include_directories( ${PROJECT_SOURCE_DIR} )
file( GLOB CPP_FILES ${PROJECT_SOURCE_DIR}/*.cpp )

add_library( {{ name }} MODULE ${CPP_FILES} )
target_link_libraries( {{ name }} PRIVATE 
  ${OpenCASCADE_LIBRARIES}
  Python::Module
  pybind11::pybind11 
  VTK::WrappingPythonCore
  VTK::RenderingCore
  VTK::CommonDataModel
  VTK::CommonExecutionModel
  )
set_target_properties( {{ name }}
                       PROPERTIES
                       CXX_STANDARD 17
                       INTERPROCEDURAL_OPTIMIZATION FALSE
                       PREFIX "${PYTHON_MODULE_PREFIX}"
                       SUFFIX "${PYTHON_MODULE_EXTENSION}" )

if(WIN32)
  target_compile_options( {{ name }} PRIVATE /bigobj )
  target_compile_definitions( {{ name }} PRIVATE 
                              "Standard_EXPORT="
                              "Standard_EXPORTEXTERN="
                              "Standard_EXPORTEXTERNC=extern \"C\""
                              "Standard_IMPORT=extern"
                              "Standard_IMPORTC=extern \"C\""
                              "_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING")
  target_link_libraries( {{ name }} PRIVATE opengl32 )
else()
  set_target_properties( {{ name }}
                         PROPERTIES
                         CMAKE_CXX_FLAGS_RELEASE "-O3 "
                         COMPILE_FLAGS "-fpermissive -fvisibility=hidden -fvisibility-inlines-hidden" )
endif()

if(UNIX AND NOT APPLE)
  target_link_options( {{ name }} PRIVATE "LINKER:--allow-multiple-definition")
endif()

if(APPLE)
  target_link_libraries( {{ name }} PRIVATE "-undefined dynamic_lookup")
endif()
