# Template rules for modules
if(WANT_COEXISTENCE)
	set(KVIRC_BINARYNAME ${PACKAGE}${VERSION_MAJOR})
	set(KVILIB_BINARYNAME kvilib${VERSION_MAJOR})
else()
	set(KVIRC_BINARYNAME ${PACKAGE})
	set(KVILIB_BINARYNAME kvilib)
endif()

add_library(${kvi_module_name} MODULE ${${kvi_module_name}_SRCS} ${${kvi_module_name}_MOC_SRCS})

target_link_libraries(${kvi_module_name} ${KVILIB_BINARYNAME} ${KVIRC_BINARYNAME} ${LIBS} ${qt_kvirc_modules})

set_target_properties(${kvi_module_name} PROPERTIES LINK_FLAGS "${MODULE_ADDITIONAL_LINK_FLAGS}")
set_target_properties(${kvi_module_name} PROPERTIES COMPILE_FLAGS "${ADDITIONAL_COMPILE_FLAGS}")

if(WANT_STRIP)
	IF(APPLE)
		add_custom_command(
			TARGET ${kvi_module_name}
			POST_BUILD
			COMMAND ${STRIP_EXECUTABLE} -x $<TARGET_FILE:${kvi_module_name}>
		)
	ELSE()
		add_custom_command(
			TARGET ${kvi_module_name}
			POST_BUILD
			COMMAND ${STRIP_EXECUTABLE} -s $<TARGET_FILE:${kvi_module_name}>
		)
	ENDIF()
endif()

install(TARGETS ${kvi_module_name} LIBRARY DESTINATION "${KVIRC_MOD_PATH}")
if(MSVC)
	install(FILES $<TARGET_PDB_FILE:${kvi_module_name}> DESTINATION ${KVIRC_MOD_PATH} OPTIONAL)
endif()
