project(PML)

cmake_minimum_required(VERSION 2.6)

# Is this tool is compiled inside or outside CAMITK (as a standalone)?
if (NOT CAMITK_SOURCE_DIR)
  # if this tool is compiled independantly from CamiTK
  set(PML_STANDALONE ON CACHE BOOL "ON only if PML compiled outside CAMITK")
  message(SEND_ERROR "Compilation of PML outside CamiTK not implemented yet. Please contact authors")
endif()

set(VERSION_STRING "pml - ${CAMITK_VERSION_STRING} (c) UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525")
configure_file(${PML_SOURCE_DIR}/PhysicalModelVersion.h.in ${PML_BINARY_DIR}/PhysicalModelVersion.h)

# Sets the variables for required include subdirectories :
set (PhysicalModelProperties_DIR ${PML_SOURCE_DIR}/PhysicalProperties)

set ( HEADERS
      Atom.h
      BasicAtomProperties.h
      Cell.h
      BasicCellProperties.h
      Component.h
      MultiComponent.h
      PhysicalModel.h
      ${PML_BINARY_DIR}/PhysicalModelVersion.h
      PhysicalModelIO.h
      Properties.h
      StructuralComponent.h
      BasicSCProperties.h
      Structure.h
      StructureProperties.h
      AbortException.h
      PMLTransform.h
      RenderingMode.h
      ${PhysicalModelProperties_DIR}/AtomProperties.h
      ${PhysicalModelProperties_DIR}/CellProperties.h
      ${PhysicalModelProperties_DIR}/StructuralComponentProperties.h
)

set (SRCS Atom.cpp
    BasicAtomProperties.cpp
	  Cell.cpp
	  Component.cpp
	  BasicCellProperties.cpp
	  MultiComponent.cpp
	  PhysicalModel.cpp
	  StructuralComponent.cpp
	  BasicSCProperties.cpp
	  Structure.cpp
	  StructureProperties.cpp
	  PMLTransform.cpp
	  ${PhysicalModelProperties_DIR}/AtomProperties.cpp
	  ${PhysicalModelProperties_DIR}/CellProperties.cpp
	  ${PhysicalModelProperties_DIR}/StructuralComponentProperties.cpp
	  Properties.cpp
	  ${HEADERS}
)


camitk_tool(STATIC
            SOURCES ${SRCS}
            INCLUDE_DIRECTORIES ${PhysicalModelProperties_DIR}
            NEEDS_LIBXML2
)

#-----------
# testing
#-----------
add_subdirectory(test)

#-----------
# tools
#-----------
add_subdirectory(tools)

#--------------
# installation
#--------------
export_headers(${HEADERS} COMPONENT pml)

# lib installation
install(TARGETS pml
        ARCHIVE DESTINATION lib/${CAMITK_SHORT_VERSION_STRING}
        COMPONENT pml
)

#-------------------
# api documentation
#-------------------

option(APIDOC_GENERATE_FOR_PML "Build API documentation for PML" OFF)

if(APIDOC_GENERATE_FOR_PML)
  find_package(Doxygen REQUIRED)
  if (DOXYGEN)
      add_subdirectory(api-doc)
  else ()
      message(STATUS "WARNING: Doxygen not found - PML API documentation and reference manual will not be created")
  endif ()
endif()
