include_directories("${AvogadroLibs_BINARY_DIR}/avogadro/core")

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

include(CheckIncludeFileCXX)
include(CheckCXXSymbolExists)
check_include_file_cxx("gtest/gtest.h" HAVE_GTEST_HPP)
if(HAVE_GTEST_HPP)
  check_cxx_symbol_exists(GTEST_HAS_PTHREAD "gtest/gtest.h" GTEST_HAS_PTHREAD)
  check_cxx_symbol_exists(GTEST_IS_THREADSAFE "gtest/gtest.h" GTEST_IS_THREADSAFE)
endif()

if(GTEST_HAS_PTHREAD)
  message(STATUS "GTest claims it has pthreads, we need to link to it.")
  find_package(Threads)
  set(EXTRA_LINK_LIB ${CMAKE_THREAD_LIBS_INIT})
else()
  set(EXTRA_LINK_LIB "")
endif()

find_path(AVOGADRO_DATA_ROOT .avogadro.data
  ${AvogadroLibs_SOURCE_DIR}/../avogadrodata
  $ENV{AVOGADRO_DATA_ROOT}
  DOC "The repository for data used for testing."
  )
mark_as_advanced(AVOGADRO_DATA_ROOT)

# Add the tests for each module.
add_subdirectory(core)
add_subdirectory(io)
if(USE_QT)
  add_subdirectory(qtgui)
endif()
if(USE_OPENGL)
  add_subdirectory(rendering)
  if(USE_QT AND USE_VTK)
    add_subdirectory(qtopengl)
  endif()
endif()

if(USE_PROTOCALL)
  add_subdirectory(protocall)
endif()
