<commit_before># Copyright (C) 1995-2021, <NAME> and <NAME>.
# All rights reserved.
#
# For the licensing terms see $ROOTSYS/LICENSE.
# For the list of contributors see $ROOTSYS/README/CREDITS.

############################################################################
# CMakeLists.txt file for building TMVA SOFIE tests.
# @author <NAME>
############################################################################


set(SOFIE_PARSERS_DIR ../../sofie_parsers)

if (NOT ONNX_MODELS_DIR)
  set(ONNX_MODELS_DIR input_models)
endif()

protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS "${SOFIE_PARSERS_DIR}/onnx_proto3")
set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS} PROPERTIES GENERATED TRUE)

add_executable(sofiec
	Emit.cxx
	../src/SOFIE_common.cxx
	../src/RModel.cxx
	${SOFIE_PARSERS_DIR}/src/RModelParser_ONNX.cxx
	${PROTO_SRCS}
)
target_include_directories(sofiec PRIVATE
  ../inc
  ${SOFIE_PARSERS_DIR}/inc
  ../../tmva/inc
  ../../../core/foundation/inc
  ${CMAKE_BINARY_DIR}/include   # this is for RConfigure.h
  ${CMAKE_CURRENT_BINARY_DIR}   # this is for the protobuf headerfile
)
target_link_libraries(sofiec ${Protobuf_LIBRARIES} ROOTTMVASofie )
set_target_properties(sofiec PROPERTIES
  POSITION_INDEPENDENT_CODE TRUE)

# Automatic compilation of headers from onnx files
add_custom_target(SofieCompileModels_ONNX)
add_dependencies(SofieCompileModels_ONNX sofiec)

# Finding .onnx files to be compiled and creating the appropriate command
file(GLOB ONNX_FILES "${ONNX_MODELS_DIR}/*.onnx")
foreach(onnx_file ${ONNX_FILES})
	get_filename_component(fname ${onnx_file} NAME_WE)  # trim
	get_filename_component(fdir ${onnx_file} DIRECTORY)
	add_custom_command(TARGET SofieCompileModels_ONNX POST_BUILD
		COMMAND ./sofiec ${onnx_file} ${CMAKE_CURRENT_BINARY_DIR}/${fname}.hxx
		USES_TERMINAL
	)
endforeach() 

# Creating a Google Test
ROOT_ADD_GTEST(TestCustomModels TestCustomModels.cxx
  LIBRARIES
    ROOTTMVASofie
    blas
  INCLUDE_DIRS<commit_msg>use /ginclude instead of /include for tmva/sofie/test<commit_after># Copyright (C) 1995-2021, <NAME> and <NAME>.
# All rights reserved.
#
# For the licensing terms see $ROOTSYS/LICENSE.
# For the list of contributors see $ROOTSYS/README/CREDITS.

############################################################################
# CMakeLists.txt file for building TMVA SOFIE tests.
# @author <NAME>
############################################################################


set(SOFIE_PARSERS_DIR ../../sofie_parsers)

if (NOT ONNX_MODELS_DIR)
  set(ONNX_MODELS_DIR input_models)
endif()

protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS "${SOFIE_PARSERS_DIR}/onnx_proto3")
set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS} PROPERTIES GENERATED TRUE)

add_executable(sofiec
	Emit.cxx
	../src/SOFIE_common.cxx
	../src/RModel.cxx
	${SOFIE_PARSERS_DIR}/src/RModelParser_ONNX.cxx
	${PROTO_SRCS}
)
target_include_directories(sofiec PRIVATE
  ../inc
  ${SOFIE_PARSERS_DIR}/inc
  ../../tmva/inc
  ../../../core/foundation/inc
  ${CMAKE_BINARY_DIR}/ginclude   # this is for RConfigure.h
  ${CMAKE_CURRENT_BINARY_DIR}   # this is for the protobuf headerfile
)
target_link_libraries(sofiec ${Protobuf_LIBRARIES} ROOTTMVASofie )
set_target_properties(sofiec PROPERTIES
  POSITION_INDEPENDENT_CODE TRUE)

# Automatic compilation of headers from onnx files
add_custom_target(SofieCompileModels_ONNX)
add_dependencies(SofieCompileModels_ONNX sofiec)

# Finding .onnx files to be compiled and creating the appropriate command
file(GLOB ONNX_FILES "${ONNX_MODELS_DIR}/*.onnx")
foreach(onnx_file ${ONNX_FILES})
	get_filename_component(fname ${onnx_file} NAME_WE)  # trim
	get_filename_component(fdir ${onnx_file} DIRECTORY)
	add_custom_command(TARGET SofieCompileModels_ONNX POST_BUILD
		COMMAND ./sofiec ${onnx_file} ${CMAKE_CURRENT_BINARY_DIR}/${fname}.hxx
		USES_TERMINAL
	)
endforeach() 

# Creating a Google Test
ROOT_ADD_GTEST(TestCustomModels TestCustomModels.cxx
  LIBRARIES
    ROOTTMVASofie
    blas
  INCLUDE_DIRS
{'fraction_non_alphanumeric': 0.1687232435154873, 'fraction_numerical': 0.004532863258625032, 'mean_word_length': 6.288073394495413, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4488322', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1420, 'n_words': 267}