<commit_before>cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
project (tcmu-runner C)
set(VERSION 1.4.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -Wdeclaration-after-statement -std=c99")

include(GNUInstallDirs)
include(CheckIncludeFile)

set(tcmu-runner_HANDLER_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/tcmu-runner")

option(with-glfs "build Gluster glfs handler" true)
option(with-qcow "build qcow handler" true)
option(with-rbd "build Ceph rbd handler" true)

find_library(LIBNL_LIB nl-3)
find_library(LIBNL_GENL_LIB nl-genl-3)
set(LIBNL_LIBS
  ${LIBNL_LIB}
  ${LIBNL_GENL_LIB}
  )

find_path (LIBNL_INCLUDE_DIR
  NAMES
  netlink/netlink.h
  PATH_SUFFIXES
  libnl3
  )

find_package(PkgConfig)
pkg_check_modules(GLIB REQUIRED gio-unix-2.0)
pkg_check_modules(KMOD REQUIRED libkmod)

find_library(PTHREAD pthread)
find_library(DL dl)

# Stuff for building the shared library
add_library(tcmu
  SHARED
  strlcpy.c
  configfs.c
  api.c
  libtcmu.c
  libtcmu-register.c
  tcmuhandler-generated.c
  libtcmu_log.c
  libtcmu_config.c
  libtcmu_time.c
  )
set_target_properties(tcmu
  PROPERTIES
  SOVERSION "2"
  )
target_include_directories(tcmu
  PUBLIC ${LIBNL_INCLUDE_DIR}
  PUBLIC ${GLIB_INCLUDE_DIRS}
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )
target_link_libraries(tcmu
  ${LIBNL_LIB}
  ${LIBNL_GENL_LIB}
  ${GLIB_LIBRARIES}
  )
install(TARGETS tcmu LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} NAMELINK_SKIP)

# Stuff for building the static library
add_library(tcmu_static
  strlcpy.c
  configfs.c
  api.c
  libtcmu.c
  libtcmu-register.c
  tcmuhandler-generated.c
  libtcmu_log.c
  libtcmu_config.c
  libtcmu_time.c
  )
target_include_directories(tcmu_static
  PUBLIC ${LIBNL_INCLUDE_DIR}
  PUBLIC ${GLIB_INCLUDE_DIRS}
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )
target_link_libraries(tcmu_static
  ${GLIB_LIBRARIES}
  )

# Stuff for building the main binary
add_executable(tcmu-runner
  tcmur_cmd_handler.c
  tcmur_aio.c
  tcmur_device.c
  target.c
  alua.c
  main.c
  tcmuhandler-generated.c
  )
target_link_libraries(tcmu-runner tcmu)
target_include_directories(tcmu-runner
  PUBLIC ${PROJECT_BINARY_DIR}
  PUBLIC ${GLIB_INCLUDE_DIRS}
  PUBLIC ${KMOD_INCLUDE_DIRS}
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )
target_link_libraries(tcmu-runner
  ${GLIB_LIBRARIES}
  ${PTHREAD}
  ${DL}
  ${KMOD_LIBRARIES}
  -Wl,--no-export-dynamic
  -Wl,--dynamic-list=${CMAKE_SOURCE_DIR}/main-syms.txt
  )
install(TARGETS tcmu-runner RUNTIME DESTINATION bin)

add_executable(tcmu-synthesizer
  tcmu-synthesizer.c
  )
target_link_libraries(tcmu-synthesizer tcmu)
target_include_directories(tcmu-synthesizer
  PUBLIC ${PROJECT_BINARY_DIR}
  PUBLIC ${GLIB_INCLUDE_DIRS}
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )
target_link_libraries(tcmu-synthesizer
  ${GLIB_LIBRARIES}
  )

install(TARGETS RUNTIME DESTINATION bin)

add_custom_command(
  OUTPUT ${CMAKE_SOURCE_DIR}/tcmuhandler-generated.c ${CMAKE_SOURCE_DIR}/tcmuhandler-generated.h
  COMMAND gdbus-codegen ${CMAKE_SOURCE_DIR}/tcmu-handler.xml --generate-c-code ${CMAKE_SOURCE_DIR}/tcmuhandler-generated --c-generate-object-manager --interface-prefix org.kernel
  MAIN_DEPENDENCY tcmu-handler.xml
  )

add_custom_target(
  cscope
  COMMAND find -name '*.[ch]' > cscope.files
  COMMAND cscope -bq
  )
set_directory_properties(
  PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
  "cscope.files;cscope.in.out;cscope.out;cscope.po.out"
  )

# Stuff for building the file handler
add_library(handler_file
  SHARED
  file_example.c
  )
set_target_properties(handler_file
  PROPERTIES
  PREFIX ""
  )
target_include_directories(handler_file
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )

# Stuff for building the file optical handler
add_library(handler_file_optical
  SHARED
  file_optical.c
  )
set_target_properties(handler_file_optical
  PROPERTIES
  PREFIX ""
  )
target_include_directories(handler_file_optical
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )
target_link_libraries(handler_file_optical ${PTHREAD})

# Stuff for building the file zbc handler
add_library(handler_file_zbc
  SHARED
  file_zbc.c
  )
set_target_properties(handler_file_zbc
  PROPERTIES
  PREFIX ""
  )
target_include_directories(handler_file_zbc
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )
install(TARGETS handler_file_zbc DESTINATION ${CMAKE_INSTALL_LIBDIR}/tcmu-runner)

# The minimal library consumer
add_executable(consumer
  consumer.c
  )
target_link_libraries(consumer tcmu)

if (with-rbd)
	find_library(LIBRBD rbd)

	# Stuff for building the rbd handler
	add_library(handler_rbd
	  SHARED
	  rbd.c
	  )
	set_target_properties(handler_rbd
	  PROPERTIES
	  PREFIX ""
	  )
	target_include_directories(handler_rbd
	  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
	  )
	target_link_libraries(handler_rbd
	  ${LIBRBD}
	  )
	install(TARGETS handler_rbd DESTINATION ${CMAKE_INSTALL_LIBDIR}/tcmu-runner)
endif (with-rbd)<commit_msg>file_zbc: optionally build zbc handler<commit_after>cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
project (tcmu-runner C)
set(VERSION 1.4.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -Wdeclaration-after-statement -std=c99")

include(GNUInstallDirs)
include(CheckIncludeFile)

set(tcmu-runner_HANDLER_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/tcmu-runner")

option(with-glfs "build Gluster glfs handler" true)
option(with-qcow "build qcow handler" true)
option(with-rbd "build Ceph rbd handler" true)
option(with-zbc "build zbc handler" true)

find_library(LIBNL_LIB nl-3)
find_library(LIBNL_GENL_LIB nl-genl-3)
set(LIBNL_LIBS
  ${LIBNL_LIB}
  ${LIBNL_GENL_LIB}
  )

find_path (LIBNL_INCLUDE_DIR
  NAMES
  netlink/netlink.h
  PATH_SUFFIXES
  libnl3
  )

find_package(PkgConfig)
pkg_check_modules(GLIB REQUIRED gio-unix-2.0)
pkg_check_modules(KMOD REQUIRED libkmod)

find_library(PTHREAD pthread)
find_library(DL dl)

# Stuff for building the shared library
add_library(tcmu
  SHARED
  strlcpy.c
  configfs.c
  api.c
  libtcmu.c
  libtcmu-register.c
  tcmuhandler-generated.c
  libtcmu_log.c
  libtcmu_config.c
  libtcmu_time.c
  )
set_target_properties(tcmu
  PROPERTIES
  SOVERSION "2"
  )
target_include_directories(tcmu
  PUBLIC ${LIBNL_INCLUDE_DIR}
  PUBLIC ${GLIB_INCLUDE_DIRS}
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )
target_link_libraries(tcmu
  ${LIBNL_LIB}
  ${LIBNL_GENL_LIB}
  ${GLIB_LIBRARIES}
  )
install(TARGETS tcmu LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} NAMELINK_SKIP)

# Stuff for building the static library
add_library(tcmu_static
  strlcpy.c
  configfs.c
  api.c
  libtcmu.c
  libtcmu-register.c
  tcmuhandler-generated.c
  libtcmu_log.c
  libtcmu_config.c
  libtcmu_time.c
  )
target_include_directories(tcmu_static
  PUBLIC ${LIBNL_INCLUDE_DIR}
  PUBLIC ${GLIB_INCLUDE_DIRS}
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )
target_link_libraries(tcmu_static
  ${GLIB_LIBRARIES}
  )

# Stuff for building the main binary
add_executable(tcmu-runner
  tcmur_cmd_handler.c
  tcmur_aio.c
  tcmur_device.c
  target.c
  alua.c
  main.c
  tcmuhandler-generated.c
  )
target_link_libraries(tcmu-runner tcmu)
target_include_directories(tcmu-runner
  PUBLIC ${PROJECT_BINARY_DIR}
  PUBLIC ${GLIB_INCLUDE_DIRS}
  PUBLIC ${KMOD_INCLUDE_DIRS}
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )
target_link_libraries(tcmu-runner
  ${GLIB_LIBRARIES}
  ${PTHREAD}
  ${DL}
  ${KMOD_LIBRARIES}
  -Wl,--no-export-dynamic
  -Wl,--dynamic-list=${CMAKE_SOURCE_DIR}/main-syms.txt
  )
install(TARGETS tcmu-runner RUNTIME DESTINATION bin)

add_executable(tcmu-synthesizer
  tcmu-synthesizer.c
  )
target_link_libraries(tcmu-synthesizer tcmu)
target_include_directories(tcmu-synthesizer
  PUBLIC ${PROJECT_BINARY_DIR}
  PUBLIC ${GLIB_INCLUDE_DIRS}
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )
target_link_libraries(tcmu-synthesizer
  ${GLIB_LIBRARIES}
  )

install(TARGETS RUNTIME DESTINATION bin)

add_custom_command(
  OUTPUT ${CMAKE_SOURCE_DIR}/tcmuhandler-generated.c ${CMAKE_SOURCE_DIR}/tcmuhandler-generated.h
  COMMAND gdbus-codegen ${CMAKE_SOURCE_DIR}/tcmu-handler.xml --generate-c-code ${CMAKE_SOURCE_DIR}/tcmuhandler-generated --c-generate-object-manager --interface-prefix org.kernel
  MAIN_DEPENDENCY tcmu-handler.xml
  )

add_custom_target(
  cscope
  COMMAND find -name '*.[ch]' > cscope.files
  COMMAND cscope -bq
  )
set_directory_properties(
  PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
  "cscope.files;cscope.in.out;cscope.out;cscope.po.out"
  )

# Stuff for building the file handler
add_library(handler_file
  SHARED
  file_example.c
  )
set_target_properties(handler_file
  PROPERTIES
  PREFIX ""
  )
target_include_directories(handler_file
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )

# Stuff for building the file optical handler
add_library(handler_file_optical
  SHARED
  file_optical.c
  )
set_target_properties(handler_file_optical
  PROPERTIES
  PREFIX ""
  )
target_include_directories(handler_file_optical
  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
  )
target_link_libraries(handler_file_optical ${PTHREAD})

# The minimal library consumer
add_executable(consumer
  consumer.c
  )
target_link_libraries(consumer tcmu)

if (with-zbc)
	# Stuff for building the file zbc handler
	add_library(handler_file_zbc
	  SHARED
	  file_zbc.c
	  )
	set_target_properties(handler_file_zbc
	  PROPERTIES
	  PREFIX ""
	  )
	target_include_directories(handler_file_zbc
	  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
	  )
	install(TARGETS handler_file_zbc DESTINATION ${CMAKE_INSTALL_LIBDIR}/tcmu-runner)
endif (with-zbc)

if (with-rbd)
	find_library(LIBRBD rbd)

	# Stuff for building the rbd handler
	add_library(handler_rbd
	  SHARED
	  rbd.c
	  )
	set_target_properties(handler_rbd
	  PROPERTIES
	  PREFIX ""
	  )
	target_include_directories(handler_rbd
	  PUBLIC ${PROJECT_SOURCE_DIR}/ccan
	  )
	target_link_libraries(handler_rbd
	  ${LIBRBD}
	  )
	install(TARGETS handler_rbd DESTINATION ${CMAKE_INSTALL_LIBDIR}/tcmu-runner)
endif (with-rbd)
{'fraction_non_alphanumeric': 0.08841932505898041, 'fraction_numerical': 0.0026669401989947686, 'mean_word_length': 5.372549019607843, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '6666886', 'n_tokens_mistral': 4073, 'n_tokens_neox': 3846, 'n_words': 598}