<commit_before>CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(gadgetd)
########################################################
# Generation options:
# -DBUILD_DOC_ONLY - only doxygen documentation is build
# -DBUILD_DOC - build also doxygen documentation
# -DSUPPORT_FFS_LEGACY_API - use legacy ffs API
# -DBUILD_EXAMPLES - build also sample applications
########################################################

########################################################
# NOTE:
# Remember to add all directories with files to DOC_SRC_DIRS_IN list
#
########################################################

IF(BUILD_DOC_ONLY)
	SET(BUILD_EXECUTABLE FALSE)
	SET(BUILD_DOC TRUE)
ELSE(BUILD_DOC_ONLY)
	SET(BUILD_EXECUTABLE TRUE)
ENDIF(BUILD_DOC_ONLY)

IF(BUILD_EXECUTABLE)

	SET(GADGETD_SRCS
		src/gadgetd.c
		src/gadgetd-create.c
		src/gadgetd-remove.c
		src/gadgetd-config.c
		src/strdelim.c
		src/ffs-service.c
	)

	SET(FFS-DAEMON-SRC
	        src/libffs-daemon/ffs-daemon.c
	)

	INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
        INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)

	SET(PREFIX ${CMAKE_INSTALL_PREFIX})
	SET(PACKAGE ${PROJECT_NAME})
	SET(BINDIR "${PREFIX}/bin")
	SET(LIBDIR "${PREFIX}/lib")
	SET(INCLUDEDIR "${PREFIX}/include")
	SET(DATADIR "${PREFIX}/share/${PACKAGE}/data")

	SET(PKG_MODULES
		libusbg
		glib-2.0
	)

	INCLUDE(FindPkgConfig)
	pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})

	FOREACH(flag ${pkgs_CFLAGS})
		SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
	ENDFOREACH(flag)

	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Wall")
	MESSAGE("FLAGS: ${CMAKE_C_FLAGS}")

	ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
	ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
	ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")

	IF(SUPPORT_FFS_LEGACY_API)
	        ADD_DEFINITIONS("-D__FFS_LEGACY_API_SUPPORT")
	ENDIF(SUPPORT_FFS_LEGACY_API)

	ADD_EXECUTABLE(${PROJECT_NAME} ${GADGETD_SRCS})
	TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-lusbg -ldl -lgio-2.0 -lgobject-2.0 -lglib-2.0")

	ADD_DEFINITIONS("-DGD_EXPORT_SYMBOLS")

	ADD_LIBRARY(ffs-daemon SHARED ${FFS-DAEMON-SRC})
	SET_TARGET_PROPERTIES(ffs-daemon PROPERTIES
	        SOVERSION 0
	        VERSION 0.0.0
	)

	INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
	INSTALL(TARGETS ffs-daemon ARCHIVE
	        DESTINATION ${LIBDIR}
	        LIBRARY DESTINATION ${LIBDIR}
	        COMPONENT library)<commit_msg>gadgetd: add gdbus codegen files generator<commit_after>CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(gadgetd)
########################################################
# Generation options:
# -DBUILD_DOC_ONLY - only doxygen documentation is build
# -DBUILD_DOC - build also doxygen documentation
# -DSUPPORT_FFS_LEGACY_API - use legacy ffs API
# -DBUILD_EXAMPLES - build also sample applications
########################################################

########################################################
# NOTE:
# Remember to add all directories with files to DOC_SRC_DIRS_IN list
#
########################################################

IF(BUILD_DOC_ONLY)
	SET(BUILD_EXECUTABLE FALSE)
	SET(BUILD_DOC TRUE)
ELSE(BUILD_DOC_ONLY)
	SET(BUILD_EXECUTABLE TRUE)
ENDIF(BUILD_DOC_ONLY)

IF(BUILD_EXECUTABLE)

	SET(GADGETD_SRCS
		src/gadgetd.c
		src/gadgetd-create.c
		src/gadgetd-remove.c
		src/gadgetd-config.c
		src/strdelim.c
		src/ffs-service.c
	)

	SET(FFS-DAEMON-SRC
	        src/libffs-daemon/ffs-daemon.c
	)

	INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
        INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)

	SET(PREFIX ${CMAKE_INSTALL_PREFIX})
	SET(PACKAGE ${PROJECT_NAME})
	SET(BINDIR "${PREFIX}/bin")
	SET(LIBDIR "${PREFIX}/lib")
	SET(INCLUDEDIR "${PREFIX}/include")
	SET(DATADIR "${PREFIX}/share/${PACKAGE}/data")

	SET(PKG_MODULES
		libusbg
		glib-2.0
		gio-unix-2.0
	)

	INCLUDE(FindPkgConfig)
	pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})

	FOREACH(flag ${pkgs_CFLAGS})
		SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
	ENDFOREACH(flag)

	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Wall")
	MESSAGE("FLAGS: ${CMAKE_C_FLAGS}")

	ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
	ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
	ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")

	IF(SUPPORT_FFS_LEGACY_API)
	        ADD_DEFINITIONS("-D__FFS_LEGACY_API_SUPPORT")
	ENDIF(SUPPORT_FFS_LEGACY_API)

	# DBUS code generation using gdbus-codegen
	SET(CODEGEN_PREFIX
                gadgetd-gdbus-codegen
	)

        SET(CODEGEN_COMMAND
                gdbus-codegen
		--interface-prefix org.usb.device.
		--generate-c-code ${CODEGEN_PREFIX}
		--c-generate-object-manager
		--c-namespace Gadgetd
		${CMAKE_CURRENT_SOURCE_DIR}/xml/gadgetd.xml
	)

	ADD_CUSTOM_COMMAND(
	        OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/${CODEGEN_PREFIX}.c
	        OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/${CODEGEN_PREFIX}.h
		COMMAND ${CODEGEN_COMMAND}
		COMMAND mv ${CODEGEN_PREFIX}.c ${CMAKE_CURRENT_SOURCE_DIR}/src/
		COMMAND mv ${CODEGEN_PREFIX}.h ${CMAKE_CURRENT_SOURCE_DIR}/include/
	)

        SET(GADGETD_SRCS
                ${GADGETD_SRCS}
                ${CMAKE_CURRENT_SOURCE_DIR}/src/${CODEGEN_PREFIX}.c
	)

	ADD_EXECUTABLE(${PROJECT_NAME} ${GADGETD_SRCS})

	TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-lusbg -ldl -lgio-2.0 -lgobject-2.0 -lglib-2.0")

	ADD_DEFINITIONS("-DGD_EXPORT_SYMBOLS")

	ADD_LIBRARY(ffs-daemon SHARED ${FFS-DAEMON-SRC})
	SET_TARGET_PROPERTIES(ffs-daemon PROPERTIES
	        SOVERSION 0
	        VERSION 0.0.0
	)

	INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
	INSTALL(TARGETS ffs-daemon ARCHIVE
	        DESTINATION ${LIBDIR}
	        LIBRARY DESTINATION ${LIBDIR}
	        COMPONENT library)
{'fraction_non_alphanumeric': 0.1965389369592089, 'fraction_numerical': 0.005297545470598622, 'mean_word_length': 5.025531914893617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4841900', 'n_tokens_mistral': 2270, 'n_tokens_neox': 2141, 'n_words': 298}