# --- dependencies ---

# --- variables ---

# --- normal modules ---
IF( X11_FOUND )
  SET( OY_MODULE oyX1 )
  SET( OY_MODULE_LIB ${PACKAGE_NAME}_${OY_MODULE}${OY_MODULE_NAME} )
  ADD_LIBRARY( ${OY_MODULE_LIB} SHARED
               ${PACKAGE_NAME}_cmm_disp.c
               ${PACKAGE_NAME}_monitor.c
               ${PACKAGE_NAME}_monitor_x11.c
               ${PACKAGE_NAME}_monitor_x11_extend.c
             )
  SET_TARGET_PROPERTIES( ${OY_MODULE_LIB} PROPERTIES COMPILE_DEFINITIONS "${OY_MODULE}=${OY_MODULE}")
  SET( BASE_DEFS "CMM_NICK=\"${OY_MODULE}\"")
  IF(HAVE_XFIXES)
    SET( BASE_DEFS ${BASE_DEFS} "HAVE_XFIXES=1")
  ENDIF()
  IF(HAVE_XCM)
    SET( BASE_DEFS ${BASE_DEFS} "HAVE_XCM=1")
  ENDIF()
  IF(HAVE_XRANDR)
    SET( BASE_DEFS ${BASE_DEFS} "HAVE_XRANDR=1")
  ENDIF()
  IF(HAVE_XINERAMA)
    SET( BASE_DEFS ${BASE_DEFS} "HAVE_XINERAMA=1")
  ENDIF()
  IF(HAVE_XXF86VM)
    SET( BASE_DEFS ${BASE_DEFS} "HAVE_XXF86VM=1")
  ENDIF()
  IF(HAVE_XEXT)
    SET( BASE_DEFS ${BASE_DEFS} "HAVE_XEXT=1")
  ENDIF()
  IF(HAVE_X11)
    SET( BASE_DEFS ${BASE_DEFS} "HAVE_X11=1")
  ENDIF()
  SET_SOURCE_FILES_PROPERTIES( ${PACKAGE_NAME}_monitor_x11.c PROPERTIES COMPILE_DEFINITIONS "${BASE_DEFS}" )
  TARGET_LINK_LIBRARIES ( ${OY_MODULE_LIB} ${PROJECT_NAME} ${EXTRA_LIBS}
               ${XINERAMA_LIBRARIES} ${XRANDR_LIBRARIES} ${XCM_LIBRARIES}
               ${XFIXES_LIBRARIES} ${XXF86VM_LIBRARIES} ${X11_LIBRARIES} )
  INSTALL (TARGETS ${OY_MODULE_LIB} DESTINATION lib${LIB_SUFFIX}/${OY_CMMSUBPATH})
  INSTALL( FILES       ${CMAKE_SOURCE_DIR}/color/rank-map/config.icc_profile.monitor.oyX1.qarz.json
           DESTINATION ${CMAKE_INSTALL_PREFIX}/share/color/rank-map/
         )
ENDIF()

IF( ${PLATFORM} STREQUAL "OSX" )
  SET( OY_MODULE qarz )
  SET( OY_MODULE_LIB ${PACKAGE_NAME}_${OY_MODULE}${OY_MODULE_NAME} )
  ADD_LIBRARY( ${OY_MODULE_LIB} SHARED
               ${PACKAGE_NAME}_cmm_disp.c
               ${PACKAGE_NAME}_monitor.c
               ${PACKAGE_NAME}_monitor_cs.c
             )
  SET_TARGET_PROPERTIES( ${OY_MODULE_LIB} PROPERTIES COMPILE_DEFINITIONS "${OY_MODULE}=${OY_MODULE}")
  INCLUDE_DIRECTORIES ( /Developer/Headers/FlatCarbon )
  FIND_LIBRARY(CARBON_LIBRARY Carbon)
  MARK_AS_ADVANCED (CARBON_LIBRARY)
  SET(EXTRA_LIBS_CS ${EXTRA_LIBS} ${CARBON_LIBRARY})
  TARGET_LINK_LIBRARIES ( ${OY_MODULE_LIB} ${PROJECT_NAME} ${EXTRA_LIBS_CS}
               ${XINERAMA_LIBRARIES} ${XRANDR_LIBRARIES} ${XCM_LIBRARIES}
               ${XFIXES_LIBRARIES} ${X11_LIBRARIES} )
  INSTALL (TARGETS ${OY_MODULE_LIB} DESTINATION lib${LIB_SUFFIX}/${OY_CMMSUBPATH})
  INSTALL( FILES       ${CMAKE_SOURCE_DIR}/color/rank-map/config.icc_profile.monitor.oyX1.qarz.json
           DESTINATION ${CMAKE_INSTALL_PREFIX}/share/color/rank-map/
         )
ENDIF()

IF( HAVE_LIBRAW_PLUGIN )
  SET( OY_MODULE oyRE )
  SET( OY_MODULE_LIB ${PACKAGE_NAME}_${OY_MODULE}${OY_MODULE_NAME} )
  ADD_LIBRARY( ${OY_MODULE_LIB}
               SHARED ${PACKAGE_NAME}_cmm_${OY_MODULE}.cpp )
  TARGET_LINK_LIBRARIES ( ${OY_MODULE_LIB} ${PROJECT_NAME} ${EXTRA_LIBS} ${LIBRAW_LIBRARIES} ${EXIV2_LIBRARIES} )
  INSTALL (TARGETS ${OY_MODULE_LIB} DESTINATION lib${LIB_SUFFIX}/${OY_CMMSUBPATH})
  SET( OY_MODULE_LIBRARIES ${OY_MODULE_LIBRARIES} ${EXIV2_LIBRARIES} )
  INSTALL( FILES       ${CMAKE_SOURCE_DIR}/color/rank-map/config.icc_profile.raw-image.${OY_MODULE}.json
           DESTINATION ${CMAKE_INSTALL_PREFIX}/share/color/rank-map/
         )
ENDIF()

IF( CUPS_FOUND )
  SET( OY_MODULE CUPS )
  SET( OY_MODULE_LIB ${PACKAGE_NAME}_${OY_MODULE}${OY_MODULE_NAME} )
  ADD_LIBRARY( ${OY_MODULE_LIB}
               SHARED ${PACKAGE_NAME}_cmm_${OY_MODULE}.c )
  TARGET_LINK_LIBRARIES ( ${OY_MODULE_LIB} ${PROJECT_NAME} ${EXTRA_LIBS} ${CUPS_LIBRARIES})
  INSTALL (TARGETS ${OY_MODULE_LIB} DESTINATION lib${LIB_SUFFIX}/${OY_CMMSUBPATH})
  INSTALL( FILES       ${CMAKE_SOURCE_DIR}/color/rank-map/config.icc_profile.printer.${OY_MODULE}.json
           DESTINATION ${CMAKE_INSTALL_PREFIX}/share/color/rank-map/
         )
ENDIF()

# SANE
IF(SANE_FOUND)
  SET( OY_MODULE SANE )
  SET( OY_MODULE_LIB ${PACKAGE_NAME}_${OY_MODULE}${OY_MODULE_NAME} )
  ADD_LIBRARY( ${OY_MODULE_LIB}
               SHARED ${PACKAGE_NAME}_cmm_${OY_MODULE}.c )
  TARGET_LINK_LIBRARIES ( ${OY_MODULE_LIB} ${PROJECT_NAME} ${EXTRA_LIBS} ${SANE_LIBRARY})
  INSTALL (TARGETS ${OY_MODULE_LIB} DESTINATION lib${LIB_SUFFIX}/${OY_CMMSUBPATH})
  INSTALL( FILES       ${CMAKE_SOURCE_DIR}/color/rank-map/config.icc_profile.scanner.${OY_MODULE}.json
           DESTINATION ${CMAKE_INSTALL_PREFIX}/share/color/rank-map/
         )
ENDIF(SANE_FOUND)

SET( OY_MODULE_LIBRARIES ${OY_MODULE_LIBRARIES} PARENT_SCOPE )
