find_package(Eigen3 REQUIRED)
# Add as "system headers" to avoid warnings generated by them with
# compilers that support that notion.
include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR})

find_package(Qt5 COMPONENTS Widgets REQUIRED)

# Provide some simple API to find the plugins, scripts, etc.
if(APPLE)
  # It is a special case, the app bundle logic breaks the relative pathing.
  add_definitions(-DAvogadroLibs_LIB_DIR=\"lib\")
else()
  add_definitions(-DAvogadroLibs_LIB_DIR=\"${INSTALL_LIBRARY_DIR}\")
endif()

if(USE_SPGLIB)
  add_definitions(-DUSE_SPGLIB)
endif()

# Find python2 for input generator scripts:
find_package(PythonInterp 2)
if(PYTHON_EXECUTABLE)
  set(PYTHON2_EXECUTABLE "${PYTHON_EXECUTABLE}")
endif()

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/avogadropython.h.in"
"namespace Avogadro {
static const char *pythonInterpreterPath = \"${PYTHON2_EXECUTABLE}\";
}
")
configure_file("${CMAKE_CURRENT_BINARY_DIR}/avogadropython.h.in"
  "${CMAKE_CURRENT_BINARY_DIR}/avogadropython.h")

set(HEADERS
  containerwidget.h
  customelementdialog.h
  elementtranslator.h
  extensionplugin.h
  filebrowsewidget.h
  fileformatdialog.h
  generichighlighter.h
  hydrogentools.h
  interfacescript.h
  interfacewidget.h
  meshgenerator.h
  molecule.h
  moleculemodel.h
  multiviewwidget.h
  periodictableview.h
  persistentatom.h
  persistentbond.h
  pythonscript.h
  rwmolecule.h
  sceneplugin.h
  scenepluginmodel.h
  scriptloader.h
  toolplugin.h
  utilities.h
  viewfactory.h
)

set(SOURCES
  containerwidget.cpp
  customelementdialog.cpp
  elementdetail_p.cpp
  elementitem_p.cpp
  elementtranslator.cpp
  extensionplugin.cpp
  filebrowsewidget.cpp
  fileformatdialog.cpp
  generichighlighter.cpp
  hydrogentools.cpp
  interfacescript.cpp
  interfacewidget.cpp
  meshgenerator.cpp
  molecule.cpp
  moleculemodel.cpp
  multiviewwidget.cpp
  periodictablescene_p.cpp
  periodictableview.cpp
  pythonscript.cpp
  rwmolecule.cpp
  sceneplugin.cpp
  scenepluginmodel.cpp
  scriptloader.cpp
  toolplugin.cpp
  utilities.cpp
  viewfactory.cpp
)

set(UIS
  customelementdialog.ui
)
qt5_wrap_ui(UI_SOURCES ${UIS})
list(APPEND SOURCES ${UI_SOURCES})

set(RCS
  qtgui.qrc
)
qt5_add_resources(RC_SOURCES ${RCS})
list(APPEND SOURCES ${RC_SOURCES})

avogadro_add_library(AvogadroQtGui ${HEADERS} ${SOURCES})
target_link_libraries(AvogadroQtGui AvogadroIO Qt5::Widgets)
