<commit_before># Macros for automatically compiling LCM types into C, Java, and Python
# libraries.
#
# Defines the following macros/functions:
#
#     lcmtypes_setup([C_AGGREGATE_HEADER header_fname] 
#                    [C_LIBNAME lib_name]
#		     [CPP_AGGREGATE_HEADER header_fname]
#                    [JARNAME jar_name]
#                    )
#
#          After invoking this macro, the following variables will be set:
#             LCMTYPES_INCLUDE_DIR
#             LCMTYPES_LIBS
#             LCMTYPES_JAR
#
#     lcmtypes_build()  # this must be called to finish
#
#     add_lcmtype(lcmfile)
#          which generates build rules for C,CPP, Java (if java is available), and 
#	   Python (if python is available) by calling the methods below
#
#     add_c_lcmtype(lcmfile)
#     add_cpp_lcmtype(lcmfile)
#     add_java_lcmtype(lcmfile)
#     add_python_lcmtype(lcmfile)
#    
# C
# ==
# 
# The autogenerated C bindings get compiled to a static and shared library.  
# The library prefix will be stored in LCMTYPES_LIBS on output. This prefix 
# can be manually set using the C_LIBNAME option.
# 
# Additionally, a header file will be generated that automatically includes
# all of the other automatically generated header files.  The name of this
# header file defaults to a cleaned-up version of "${PROJECT_NAME}.h" 
# (non-alphanumeric characters replaced with underscores), but can
# be manually set using the C_AGGREGATE_HEADER option.
#
# C++
# ==
# 
# The autogenerated CPP bindings are header only, so no library is created.
# 
# A header file will be generated that automatically includes
# all of the other automatically generated header files.  The name of this
# header file defaults to a cleaned-up version of "${PROJECT_NAME}.hpp" 
# (non-alphanumeric characters replaced with underscores), but can
# be manually set using the CPP_AGGREGATE_HEADER option.
#
#
# Java
# ====
#
# Targets are added to automatically compile the .java files to a
# .jar file that will be installed to 
#   ${CMAKE_INSTALL_PREFIX}/share/java
# The location of this jar file is stored in LCMTYPES_JAR
#
# Python
# ======
#
# .py files will be installed to 
#   ${CMAKE_INSTALL_PREFIX}/lib/python{X.Y}/dist-packages
#   
# where {X.Y} refers to the python version used to build the .py files.
#
# ----
# File: lcmtypes.cmake
# Distributed with pods version: 12.09.21

cmake_minimum_required(VERSION 2.8.3) # for the CMakeParseArguments macro 

find_package(Java REQUIRED)
include(UseJava)

macro(lcmtypes_setup)
  find_package(PkgConfig REQUIRED)
  pkg_check_modules(LCM REQUIRED lcm)
    
  #find lcm-gen (it may be in the install path)
  find_program(LCM_GEN_EXECUTABLE lcm-gen ${EXECUTABLE_OUTPUT_PATH} ${EXECUTABLE_INSTALL_PATH})
  
  if (NOT LCM_GEN_EXECUTABLE)
    message(FATAL_ERROR "lcm-gen not found!\n")
    return()
  endif()

  cmake_parse_arguments("LCMTYPES" "" "C_AGGREGATE_HEADER;C_LIBNAME;CPP_AGGREGATE_HEADER;JARNAME" "" ${ARGV})

  string(REGEX REPLACE "[^a-zA-Z0-9]" "_" __sanitized_project_name "${PROJECT_NAME}")

  # default values
  if (NOT LCMTYPES_C_AGGREGATE_HEADER)
    set(LCMTYPES_C_AGGREGATE_HEADER "${__sanitized_project_name}.h")
  endif()
  if (NOT LCMTYPES_C_LIBNAME)
    set(LCMTYPES_C_LIBNAME "${__sanitized_project_name}_lcmtypes")
  endif()
  if (NOT LCMTYPES_CPP_AGGREGATE_HEADER)
    set(LCMTYPES_C_AGGREGATE_HEADER "${__sanitized_project_name}.hpp")
  endif()
  if (NOT LCMTYPES_JARNAME)
    set(LCMTYPES_JARNAME "${__sanitized_project_name}")
  endif()

  set(LCMTYPES_DIR ${CMAKE_CURRENT_BINARY_DIR}/lcmtypes)
  execute_process(COMMAND mkdir -p ${LCMTYPES_DIR})

  set(LCMTYPES_C_SOURCEFILES)

endmacro()

macro(lcmtypes_build)

#  add_custom_target(${LCMTYPES_DIR}/${LCMTYPES_C_AGGREGATE_HEADER})
   
  if (LCMTYPES_C_SOURCEFILES)
    add_library(${LCMTYPES_C_LIBNAME} ${LCMTYPES_C_SOURCEFILES})

    # todo: write aggregate header
  endif()

  if (LCMTYPES_CPP_HEADERFILES)
    # todo: write aggregate header
  endif()

  if (LCMTYPES_JAVA_SOURCEFILES)
    add_jar(${LCMTYPES_JARNAME} ${LCMTYPES_JAVA_SOURCEFILES})
  endif()

#  todo: handle python

#  todo: add install rules

endmacro()

function(lcmgen)
  execute_process(COMMAND ${LCM_GEN_EXECUTABLE} ${ARGV} RESULT_VARIABLE lcmgen_result)<commit_msg>cleaned up interface for backwards compatibility. fixed java implementation<commit_after># Macros for automatically compiling LCM types into C, Java, and Python
# libraries.
#
# Defines the following macros/functions:
#
#     add_lcmtype(lcmfile)
#          which generates build rules for C,CPP, Java (if java is available), and 
#	   Python (if python is available) by calling the methods below
#
#     add_c_lcmtype(lcmfile)
#     add_cpp_lcmtype(lcmfile)
#     add_java_lcmtype(lcmfile)
#     add_python_lcmtype(lcmfile)
#
#  The following should be called AFTER all add_lcmtype calls:
#
#     lcmtypes_build([C_AGGREGATE_HEADER header_fname] 
#                    [C_LIBNAME lib_name]
#		     [CPP_AGGREGATE_HEADER header_fname]
#                    [JARNAME jar_name])
#
#          In addition to any files added via add_lcm calls, this function will 
#          search the variable ${LCMTYPES_SEARCHDIR} and automatically call
#          add_lcm() for all .lcm files in that directory.  For backwards 
#          compatibility, the default value is 
#             LCMTYPES_SEARCHDIR=CMAKE_SOURCE_DIR/lcmtypes
#
#          After invoking this macro, the following variables will be set:
#             LCMTYPES_INCLUDE_DIR
#             LCMTYPES_LIBS
#             LCMTYPES_JAR
#    
# C
# ==
# 
# The autogenerated C bindings get compiled to a static and shared library.  
# The library prefix will be stored in LCMTYPES_LIBS on output. This prefix 
# can be manually set using the C_LIBNAME option.
# 
# Additionally, a header file will be generated that automatically includes
# all of the other automatically generated header files.  The name of this
# header file defaults to a cleaned-up version of "${PROJECT_NAME}.h" 
# (non-alphanumeric characters replaced with underscores), but can
# be manually set using the C_AGGREGATE_HEADER option.
#
# C++
# ==
# 
# The autogenerated CPP bindings are header only, so no library is created.
# 
# A header file will be generated that automatically includes
# all of the other automatically generated header files.  The name of this
# header file defaults to a cleaned-up version of "${PROJECT_NAME}.hpp" 
# (non-alphanumeric characters replaced with underscores), but can
# be manually set using the CPP_AGGREGATE_HEADER option.
#
#
# Java
# ====
#
# Targets are added to automatically compile the .java files to a
# .jar file that will be installed to 
#   ${CMAKE_INSTALL_PREFIX}/share/java
# The location of this jar file is stored in LCMTYPES_JAR
#
# Python
# ======
#
# .py files will be installed to 
#   ${CMAKE_INSTALL_PREFIX}/lib/python{X.Y}/dist-packages
#   
# where {X.Y} refers to the python version used to build the .py files.
#
# ----
# File: lcmtypes.cmake
# Distributed with pods version: 12.09.21

cmake_minimum_required(VERSION 2.8.3) # for the CMakeParseArguments macro 

find_package(PkgConfig REQUIRED)
pkg_check_modules(LCM REQUIRED lcm)
    
#find lcm-gen (it may be in the install path)
find_program(LCM_GEN_EXECUTABLE lcm-gen ${EXECUTABLE_OUTPUT_PATH} ${EXECUTABLE_INSTALL_PATH})
  
if (NOT LCM_GEN_EXECUTABLE)
  message(FATAL_ERROR "lcm-gen not found!\n")
  return()
endif()

set(LCMTYPES_DIR ${CMAKE_CURRENT_BINARY_DIR}/lcmtypes)
execute_process(COMMAND mkdir -p ${LCMTYPES_DIR})

set(LCMTYPES_SEARCHDIR ${CMAKE_SOURCE_DIR}/lcmtypes)

macro(lcmtypes_build_c)
  cmake_parse_arguments("LCMTYPES" "" "C_AGGREGATE_HEADER;C_LIBNAME" "" ${ARGV})
  string(REGEX REPLACE "[^a-zA-Z0-9]" "_" __sanitized_project_name "${PROJECT_NAME}")

  if (NOT LCMTYPES_C_AGGREGATE_HEADER)
    set(LCMTYPES_C_AGGREGATE_HEADER "${__sanitized_project_name}.h")
  endif()
  if (NOT LCMTYPES_C_LIBNAME)
    set(LCMTYPES_C_LIBNAME "${__sanitized_project_name}_lcmtypes")
  endif()

  if (LCMTYPES_C_SOURCEFILES)
    add_library(${LCMTYPES_C_LIBNAME} ${LCMTYPES_C_SOURCEFILES})

    # todo: write aggregate header

    #  todo: add install rules
  endif()
endmacro()

macro(lcmtypes_build_cpp)
  cmake_parse_arguments("LCMTYPES" "" "CPP_AGGREGATE_HEADER" "" ${ARGV})
  string(REGEX REPLACE "[^a-zA-Z0-9]" "_" __sanitized_project_name "${PROJECT_NAME}")

  if (NOT LCMTYPES_CPP_AGGREGATE_HEADER)
    set(LCMTYPES_C_AGGREGATE_HEADER "${__sanitized_project_name}.hpp")
  endif()

  if (LCMTYPES_CPP_HEADERFILES)
    # todo: write aggregate header

    #  todo: add install rules
  endif()
endmacro()

macro(lcmtypes_build_java)
  cmake_parse_arguments("LCMTYPES" "" "JARNAME" "" ${ARGV})
  string(REGEX REPLACE "[^a-zA-Z0-9]" "_" __sanitized_project_name "${PROJECT_NAME}")

  if (NOT LCMTYPES_JARNAME)
    set(LCMTYPES_JARNAME "lcmtypes_${__sanitized_project_name}")
  endif()

  if (LCMTYPES_JAVA_SOURCEFILES)
    find_package(Java REQUIRED)
    include(UseJava)

    execute_process(COMMAND pkg-config --variable=classpath lcm-java OUTPUT_VARIABLE LCM_JAR_FILE OUTPUT_STRIP_TRAILING_WHITESPACE)
    if(NOT LCM_JAR_FILE)
        message(STATUS "Not building Java LCM type bindings (Can't find lcm.jar)")
        return()
    endif()
    set(CMAKE_JAVA_INCLUDE_PATH ${LCM_JAR_FILE})

    add_jar(${LCMTYPES_JARNAME} ${LCMTYPES_JAVA_SOURCEFILES})

    #  todo: add install rules

  endif()
endmacro()


macro(lcmtypes_build)

  lcmtypes_build_c(${ARGV})

  lcmtypes_build_cpp(${ARGV})

  lcmtypes_build_java(${ARGV})

#  todo: handle python

endmacro()

function(lcmgen)
  execute_process(COMMAND ${LCM_GEN_EXECUTABLE} ${ARGV} RESULT_VARIABLE lcmgen_result)
{'fraction_non_alphanumeric': 0.09265010351966874, 'fraction_numerical': 0.002691511387163561, 'mean_word_length': 4.2505434782608695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2938608', 'n_tokens_mistral': 3507, 'n_tokens_neox': 3424, 'n_words': 858}