cmake_minimum_required(VERSION 3.1)
project(Anatomy)

add_subdirectory(extlibs/tinyspline)

set(ANATOMY_MAJOR_VERSION 0)
set(ANATOMY_MINOR_VERSION 1)
set(ANATOMY_VERSION ${ANATOMY_MAJOR_VERSION}.${ANATOMY_MINOR_VERSION})

set(HEADER_FILES
    initAnatomy.h
    engine/SplineEngine.h
    engine/MergeParticlePartition.h
    engine/VTKNidROI.h
    engine/VTKNidROI.inl
    engine/ProgressiveTarget.h
    engine/ProgressiveTarget.inl
#    engine/JointBiasImage.h
    engine/ComputeMaskedPosition.h
)

set(SOURCE_FILES
    initAnatomy.cpp
    engine/SplineEngine.cpp
    engine/MergeParticlePartition.cpp
    engine/VTKNidROI.cpp
    engine/ProgressiveTarget.cpp
#    engine/JointBiasImage.cpp
    engine/ComputeMaskedPosition.cpp
)

set(PYTHON_FILES
    python/Anatomy/__init__.py
    python/Anatomy/AnatomyModelReader.py
    python/Anatomy/Joints.py
    python/Anatomy/boneFrameISB.py
    python/Anatomy/Landmark.py
    python/Anatomy/Constraint.py
    python/Anatomy/Tools.py
    python/Anatomy/API.py
    python/Anatomy/material.json
    python/Anatomy/sml/tools.py
    python/Anatomy/sml/rigidAffine.py
    python/Anatomy/sml/affineRegistration.py
    python/Anatomy/sml/rigidFem.py
    python/Anatomy/sml/femRegistration.py
    python/Anatomy/sml/rigidAffineFem.py
    python/Anatomy/sml/rigidScale.py
    python/Anatomy/sml/rigidScaleAffine.py
    python/Anatomy/sml/display.py
    python/Anatomy/sml/joint.py
    python/Anatomy/sml/check.py
)

set(README_FILES
    Anatomy.txt
)

include_directories(extlibs)

find_package(SofaMisc REQUIRED)
find_package(image REQUIRED)
#find_package(BranchingImage REQUIRED)

# Config files and install rules for pythons scripts
sofa_set_python_directory(${PROJECT_NAME} "python")

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${README_FILES} ${PYTHON_FILES})

target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}../>")
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}extlibs/>")
target_include_directories(${PROJECT_NAME} PUBLIC "$<INSTALL_INTERFACE:include>")
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${ANATOMY_VERSION})

add_definitions("-DSOFA_BUILD_Anatomy")
target_link_libraries(${PROJECT_NAME} tinyspline)
target_link_libraries(${PROJECT_NAME} SofaBaseVisual SofaOpenglVisual SofaBaseTopology )
target_link_libraries(${PROJECT_NAME} image)
#target_link_libraries(${PROJECT_NAME} BranchingImage)


## Install rules for the library; CMake package configurations files
sofa_create_package(${PROJECT_NAME} ${ANATOMY_VERSION} ${PROJECT_NAME} ${PROJECT_NAME})

## Install rules for the resources
install(DIRECTORY examples/ DESTINATION share/sofa/plugins/${PROJECT_NAME})


