#
# Testing
#
ENABLE_TESTING()

INCLUDE_DIRECTORIES(${CUDA_INCLUDE})
INCLUDE_DIRECTORIES(${OPENMM_DIR}/platforms/cuda/include)
INCLUDE_DIRECTORIES(${OPENMM_DIR}/openmmapi/include/openmm)
INCLUDE_DIRECTORIES(${OPENMM_DIR}/platforms/cuda/src)
INCLUDE_DIRECTORIES(${OPENMM_DIR}/platforms/cuda/src/kernels)

SET(SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET   "AmoebaTinkerParameterFile" )
SET(AMOEBA_TINKER_PARAMETER_FILE_SOURCE_FILES    "AmoebaTinkerParameterFile.cpp" )
SET(AMOEBA_TINKER_PARAMETER_FILE_INCLUDE_FILES   "AmoebaTinkerParameterFile.h" )

Set( SHARED_OPENMM_AMOEBA_TARGET OpenMMAmoeba)
Set( SHARED_CUDA_TARGET OpenMMCuda )
Set( SHARED_AMOEBA_CUDA_TARGET OpenMMAmoebaCuda )

Set( STATIC_CUDA_TARGET OpenMMCuda_static OpenMMAmoebaCuda_static)
Set( STATIC_OPENMM_TARGET OpenMMAmoeba_static)

IF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
    SET(SHARED_OPENMM_AMOEBA_TARGET ${SHARED_OPENMM_AMOEBA_TARGET}_d)
    SET(SHARED_AMOEBA_CUDA_TARGET   ${SHARED_AMOEBA_CUDA_TARGET}_d)
    SET(SHARED_OPENMM__AMOEBA_TARGET ${SHARED_OPENMM__AMOEBA_TARGET}_d)
    SET(SHARED_CUDA_TARGET ${SHARED_CUDA_TARGET}_d)
ENDIF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)

ADD_LIBRARY(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} SHARED ${AMOEBA_TINKER_PARAMETER_FILE_SOURCE_FILES} ${AMOEBA_TINKER_PARAMETER_FILE_INCLUDE_FILES} )
SET_TARGET_PROPERTIES(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} PROPERTIES COMPILE_FLAGS "-DOPENMM_BUILDING_SHARED_LIBRARY -DLEPTON_BUILDING_SHARED_LIBRARY -DOPENMM_VALIDATE_BUILDING_SHARED_LIBRARY")
TARGET_LINK_LIBRARIES(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} debug ${OPENMM_LIBRARY_NAME}_d optimized ${OPENMM_LIBRARY_NAME})
#TARGET_LINK_LIBRARIES(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} ${OPENMM_LIBRARY_NAME} )
TARGET_LINK_LIBRARIES(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} ${SHARED_OPENMM_AMOEBA_TARGET})
TARGET_LINK_LIBRARIES(${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET} ${SHARED_AMOEBA_CUDA_TARGET} )

#LINK_DIRECTORIES

# Automatically create tests using files named "Test*.cpp"
FILE(GLOB TEST_PROGS "*Test*.cpp")
FOREACH(TEST_PROG ${TEST_PROGS})
    GET_FILENAME_COMPONENT(TEST_ROOT ${TEST_PROG} NAME_WE)

    # Link with shared library

    CUDA_ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG})
    TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_TARGET} ${SHARED_OPENMM_TARGET} ${SHARED_OPENMM_AMOEBA_TARGET} ${SHARED_CUDA_TARGET} ${SHARED_AMOEBA_CUDA_TARGET} ${SHARED_AMOEBA_TINKER_PARAMETER_FILE_TARGET})
    ADD_TEST(${TEST_ROOT} ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT})

    # Link with static library
#     SET(TEST_STATIC ${TEST_ROOT}Static)
#     CUDA_ADD_EXECUTABLE(${TEST_STATIC} ${TEST_PROG})
#     SET_TARGET_PROPERTIES(${TEST_STATIC}
#                 PROPERTIES
#                 COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES"
#                 )
#     TARGET_LINK_LIBRARIES(${TEST_STATIC} ${STATIC_TARGET} ${STATIC_OPENMM_TARGET} ${STATIC_CUDA_TARGET})
#     ADD_TEST(${TEST_STATIC} ${EXECUTABLE_OUTPUT_PATH}/${TEST_STATIC})

ENDFOREACH(TEST_PROG ${TEST_PROGS})
