PROJECT(newmat)


# Include directories

INCLUDE_DIRECTORIES(
  ${newmat_SOURCE_DIR}/include
  )


# Make the newmat library

FILE(GLOB_RECURSE newmat_SRCS src/*.cpp include/*.h)
ADD_LIBRARY(newmat ${newmat_SRCS})


# Apps, examples, tests, ...?

FILE(GLOB tmt_SRCS app/tmt.cpp app/tmt?.cpp)
ADD_EXECUTABLE(tmt ${tmt_SRCS})
TARGET_LINK_LIBRARIES(tmt newmat)

ADD_EXECUTABLE(example app/example.cpp)
TARGET_LINK_LIBRARIES(example newmat)

ADD_EXECUTABLE(garch app/garch.cpp)
TARGET_LINK_LIBRARIES(garch newmat)
ADD_CUSTOM_COMMAND(
  TARGET garch
  POST_BUILD
  COMMAND ${CMAKE_COMMAND}
  ARGS -E copy ${newmat_SOURCE_DIR}/data/garch.dat ${newmat_BINARY_DIR}
  )

ADD_EXECUTABLE(nl_ex app/nl_ex.cpp)
TARGET_LINK_LIBRARIES(nl_ex newmat)

ADD_EXECUTABLE(sl_ex app/sl_ex.cpp)
TARGET_LINK_LIBRARIES(sl_ex newmat)

ADD_EXECUTABLE(test_exc app/test_exc.cpp)
TARGET_LINK_LIBRARIES(test_exc newmat)


# Install newmat

IF(WIN32)
  # Windows
  SET(CMAKE_INSTALL_PREFIX CACHE INTERNAL "")
  SET(newmat_INSTALL_PREFIX "$ENV{PROGRAMFILES}/SINTEF/newmat"
    CACHE PATH "Path to install Newmat")
  INSTALL(TARGETS newmat DESTINATION ${newmat_INSTALL_PREFIX}/lib)
  INSTALL(DIRECTORY include/
    DESTINATION ${newmat_INSTALL_PREFIX}/include/newmat
    FILES_MATCHING PATTERN "*.h"
    PATTERN ".svn" EXCLUDE
    )
ELSE(WIN32)
  # Linux
  # lib
  INSTALL(TARGETS newmat DESTINATION lib)
  # include
  INSTALL(DIRECTORY include/
    DESTINATION include/newmat
    FILES_MATCHING PATTERN "*.h"
    PATTERN ".svn" EXCLUDE
    )
ENDIF(WIN32)

