# Don't forget to include output directory, otherwise
# the UI file won't be wrapped!
include_directories(
  ${CMAKE_CURRENT_BINARY_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}/action
  ${CMAKE_CURRENT_SOURCE_DIR}/application
  ${CMAKE_CURRENT_SOURCE_DIR}/component
  ${CMAKE_CURRENT_SOURCE_DIR}/component/mesh
  ${CMAKE_CURRENT_SOURCE_DIR}/component/image
  ${CMAKE_CURRENT_SOURCE_DIR}/operators
  ${CMAKE_CURRENT_SOURCE_DIR}/utils
  ${CMAKE_CURRENT_SOURCE_DIR}/viewer
  ${CAMITK_INCLUDE_DIRECTORIES}
)

# find all sources files, set rules for qt files...
gather_headers_and_sources(${CAMITK_CORE_LIB}) 

# Needed for a correct CamiTK core plugin management (decl export/import) on WIN32
add_definitions(-DCOMPILE_CAMITK_API)

# prepare the library specific info (SONAME...)
set(CAMITKCORE_LIBRARY_PROPERTIES ${CAMITKCORE_LIBRARY_PROPERTIES}
    VERSION   "${CAMITK_VER_MAJ}.${CAMITK_VER_MIN}.${CAMITK_VER_PAT}"
    SOVERSION "${CAMITK_VER_MAJ}.${CAMITK_VER_MIN}"
)

# CAMITK_CORE_LIB needs to be SHARED and loaded only ONCE otherwise the extensions
# can have their own copy of CAMITK_CORE_LIB, which will generates loads of problems
# because of the Singleton design pattern and various factory bits in CAMITK_CORE_LIB.
add_library(${CAMITK_CORE_LIB} SHARED ${${CAMITK_CORE_LIB}_SOURCES})

# set the library specific info (SONAME...)
set_target_properties(${CAMITK_CORE_LIB} PROPERTIES ${CAMITKCORE_LIBRARY_PROPERTIES} LINK_INTERFACE_LIBRARIES "")

target_link_libraries(${CAMITK_CORE_LIB} ${CAMITK_LIBRARIES})

add_dependencies(${CAMITK_CORE_LIB} qtpropertybrowser)

# -- headers to install 
# TODO create a manually selected list (some headers are just needed internally)
# TODO create few specific include files like: CamiTKCore and CamiTKComponent that
# include most of the needed headers and that can be used simply e.g.
# #include <CamiTKComponent>
# i.e. without the trailing .h
file(GLOB_RECURSE ${CAMITK_CORE_LIB}_INSTALL_H *.h *.txx)

#--------------
# installation
#--------------
export_headers(${${CAMITK_CORE_LIB}_INSTALL_H} 
               COMPONENT ${CAMITK_CORE_LIB}
)

# lib installation
install(TARGETS ${CAMITK_CORE_LIB}
        RUNTIME DESTINATION bin
        LIBRARY DESTINATION lib
        ARCHIVE DESTINATION lib/${CAMITK_SHORT_VERSION_STRING}
        COMPONENT           ${CAMITK_CORE_LIB}
)