<commit_before>set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

# HACK: ugly hack to provide default compilation type
IF(DEFINED CMAKE_BUILD_TYPE)
   SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of
build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug
Release RelWithDebInfo MinSizeRel.")
ELSE()
   SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build,
options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release
RelWithDebInfo MinSizeRel.")
ENDIF()

project(VELES C CXX)
if(WIN32)
  cmake_minimum_required(VERSION 3.7.0)
else(WIN32)
  cmake_minimum_required(VERSION 3.1.0)
endif(WIN32)

# Basic packaging data
set(CPACK_PACKAGE_VENDOR "Codilime")
set(CPACK_PACKAGE_NAME "veles")
set(CPACK_DEBIAN_PACKAGE_SECTION "Editors")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "VELES hex editor")

include("cmake/googletest.cmake")
include("cmake/qt.cmake")
include("cmake/zlib.cmake")
include("cmake/protobuf.cmake")
# Compiler flags
set(CMAKE_CXX_STANDARD_REQUIRED 11) # Use c++11
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
set(CMAKE_INSTALL_RPATH ".")
if(CMAKE_COMPILER_IS_GNUCXX)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall --std=c++11") # All warnings
  set(ADDITIONAL_LINK_LIBRARIES "pthread")
endif()
if(MSVC)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc ") # set exception handling mode and linking mode
endif()
if(APPLE)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif(APPLE)

# Sources
set(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(SRC_DIR ${CMAKE_SOURCE_DIR}/src)
set(TEST_DIR ${CMAKE_SOURCE_DIR}/test)

include_directories(${INCLUDE_DIR})
include_directories(${CMAKE_BINARY_DIR}/protobuf)

# VELES build rules
# LIB: veles_base
add_library(veles_base
    ${INCLUDE_DIR}/util/icons.h
    ${INCLUDE_DIR}/util/concurrency/threadpool.h
    ${INCLUDE_DIR}/util/sampling/isampler.h
    ${INCLUDE_DIR}/util/sampling/uniform_sampler.h
    ${INCLUDE_DIR}/util/sampling/fake_sampler.h
    ${INCLUDE_DIR}/util/settings/theme.h
    ${INCLUDE_DIR}/util/settings/hexedit.h
    ${INCLUDE_DIR}/util/settings/network.h

    ${INCLUDE_DIR}/util/encoders/base64_encoder.h
    ${INCLUDE_DIR}/util/encoders/c_data_encoder.h
    ${INCLUDE_DIR}/util/encoders/c_string_encoder.h
    ${INCLUDE_DIR}/util/encoders/factory.h
    ${INCLUDE_DIR}/util/encoders/hex_encoder.h
    ${INCLUDE_DIR}/util/encoders/idecoder.h
    ${INCLUDE_DIR}/util/encoders/iencoder.h
    ${INCLUDE_DIR}/util/encoders/text_encoder.h
    ${INCLUDE_DIR}/util/encoders/url_encoder.h

    ${INCLUDE_DIR}/util/string_utils.h

    ${SRC_DIR}/util/icons.cc
    ${SRC_DIR}/util/concurrency/threadpool.cc
    ${SRC_DIR}/util/sampling/isampler.cc
    ${SRC_DIR}/util/sampling/uniform_sampler.cc
    ${SRC_DIR}/util/sampling/fake_sampler.cc
    ${SRC_DIR}/util/settings/theme.cc
    ${SRC_DIR}/util/settings/hexedit.cc
    ${SRC_DIR}/util/settings/network.cc

    ${SRC_DIR}/util/encoders/base64_encoder.cc
    ${SRC_DIR}/util/encoders/c_data_encoder.cc
    ${SRC_DIR}/util/encoders/c_string_encoder.cc
    ${SRC_DIR}/util/encoders/factory.cc
    ${SRC_DIR}/util/encoders/hex_encoder.cc
    ${SRC_DIR}/util/encoders/text_encoder.cc
    ${SRC_DIR}/util/encoders/url_encoder.cc

    ${SRC_DIR}/util/string_utils.cc
    ${SRC_DIR}/util/version.cc)

qt5_use_modules(veles_base Core Gui Widgets)
target_link_libraries(veles_base ${ADDITIONAL_LINK_LIBRARIES})

# LIB: veles_visualisation

qt5_wrap_ui(VISUALISATION_FORMS
    ${SRC_DIR}/visualisation/selectrangedialog.ui
    ${SRC_DIR}/visualisation/samplingmethoddialog.ui
    )

qt5_add_resources(VISUALISATION_SHADERS ${SRC_DIR}/visualisation/shaders/shaders.qrc)
add_library(veles_visualisation
    ${INCLUDE_DIR}/visualisation/panel.h
    ${INCLUDE_DIR}/visualisation/base.h
    ${INCLUDE_DIR}/visualisation/digram.h
    ${INCLUDE_DIR}/visualisation/trigram.h
    ${INCLUDE_DIR}/visualisation/minimap.h
    ${INCLUDE_DIR}/visualisation/minimap_panel.h
    ${INCLUDE_DIR}/visualisation/selectrangedialog.h
    ${INCLUDE_DIR}/visualisation/manipulator.h
    ${INCLUDE_DIR}/visualisation/samplingmethoddialog.h
    ${SRC_DIR}/visualisation/panel.cc
    ${SRC_DIR}/visualisation/base.cc
    ${SRC_DIR}/visualisation/digram.cc
    ${SRC_DIR}/visualisation/trigram.cc
    ${SRC_DIR}/visualisation/minimap.cc
    ${SRC_DIR}/visualisation/minimap_panel.cc
    ${SRC_DIR}/visualisation/selectrangedialog.cc
    ${SRC_DIR}/visualisation/manipulator.cc
    ${SRC_DIR}/visualisation/samplingmethoddialog.cc
    ${VISUALISATION_FORMS}
    ${VISUALISATION_SHADERS})

qt5_use_modules(veles_visualisation Core Gui Widgets)
target_link_libraries(veles_visualisation veles_base)

# LIB: veles_data
add_library(veles_data
    ${INCLUDE_DIR}/data/types.h
    ${INCLUDE_DIR}/data/bindata.h
    ${INCLUDE_DIR}/data/repack.h
    ${INCLUDE_DIR}/data/field.h
    ${SRC_DIR}/data/bindata.cc
    ${SRC_DIR}/data/repack.cc
)

qt5_use_modules(veles_data Core)

# LIB: veles_dbif
add_library(veles_dbif
    ${INCLUDE_DIR}/dbif/error.h
    ${INCLUDE_DIR}/dbif/info.h
    ${INCLUDE_DIR}/dbif/method.h
    ${INCLUDE_DIR}/dbif/promise.h
    ${INCLUDE_DIR}/dbif/types.h
    ${INCLUDE_DIR}/dbif/universe.h
    ${SRC_DIR}/dbif/dbif.cc
)

qt5_use_modules(veles_dbif Core)
target_link_libraries(veles_dbif veles_data)

file(GLOB kaitai_headers
    "${INCLUDE_DIR}/kaitai/*.h"
)

file(GLOB kaitai_sources
    "${SRC_DIR}/kaitai/*.cc"
)

# LIB: parser
add_library(parser
    ${INCLUDE_DIR}/parser/parser.h
    ${INCLUDE_DIR}/parser/stream.h
    ${INCLUDE_DIR}/parser/unpyc.h
    ${INCLUDE_DIR}/parser/unpng.h
    ${INCLUDE_DIR}/parser/utils.h
    ${kaitai_headers}
    ${SRC_DIR}/parser/parser.cc
    ${SRC_DIR}/parser/unpyc.cc
    ${SRC_DIR}/parser/unpng.cc
    ${SRC_DIR}/parser/utils.cc
    ${kaitai_sources}
)

qt5_use_modules(parser Core)
add_dependencies(parser zlib)
target_link_libraries(parser veles_db veles_dbif ${ZLIB_LIBRARIES})

# generate protobuf files
add_subdirectory(protobuf)

# LIB: veles_db
add_library(veles_db
    ${INCLUDE_DIR}/db/db.h
    ${INCLUDE_DIR}/db/getter.h
    ${INCLUDE_DIR}/db/handle.h
    ${INCLUDE_DIR}/db/object.h
    ${INCLUDE_DIR}/db/types.h
    ${INCLUDE_DIR}/db/universe.h
    ${SRC_DIR}/db/universe.cc
    ${SRC_DIR}/db/object.cc
    ${SRC_DIR}/db/handle.cc
)

qt5_use_modules(veles_db Core)
add_dependencies(veles_db veles_network)
target_link_libraries(veles_db veles_dbif parser)

# EXE: dbif_test
add_executable(dbif_test ${SRC_DIR}/dbif_test.cc)

qt5_use_modules(dbif_test Core)

target_link_libraries(dbif_test veles_db veles_network)

# EXE: unpyc
add_executable(unpyc ${SRC_DIR}/unpyc.cc)

qt5_use_modules(unpyc Core)

target_link_libraries(unpyc veles_db parser veles_network)

#target_link_libraries(test_veles veles)

# Resources
qt5_add_resources(RESOURCES resources/veles.qrc)
qt5_wrap_ui(FORMS
    ${SRC_DIR}/ui/optionsdialog.ui
    ${SRC_DIR}/ui/searchdialog.ui
    ${SRC_DIR}/ui/gotoaddressdialog.ui
    ${SRC_DIR}/ui/createchunkdialog.ui
    ${SRC_DIR}/ui/databaseinfo.ui
    ${SRC_DIR}/ui/logwidget.ui
    )

if(WIN32)
  set(ICONS ${CMAKE_SOURCE_DIR}/resources/icons/veles.rc)
endif(WIN32)

if(APPLE)
  set(ICONS ${CMAKE_SOURCE_DIR}/resources/icons/veles.icns)
  set(MACOSX_BUNDLE_ICON_FILE veles.icns)
  set_source_files_properties(${ICONS} PROPERTIES
    MACOSX_PACKAGE_LOCATION Resources)
endif(APPLE)

# EXE: Main executable
add_executable(main_ui
    ${INCLUDE_DIR}/ui/logwidget.h
    ${INCLUDE_DIR}/ui/veles_mainwindow.h
    ${INCLUDE_DIR}/ui/dockwidget.h
    ${INCLUDE_DIR}/ui/dockwidget_native.h
    ${INCLUDE_DIR}/ui/hexeditwidget.h
    ${INCLUDE_DIR}/ui/nodetreewidget.h
    ${INCLUDE_DIR}/ui/nodewidget.h
    ${INCLUDE_DIR}/ui/optionsdialog.h
    ${INCLUDE_DIR}/ui/hexedit.h
    ${INCLUDE_DIR}/ui/searchdialog.h
    ${INCLUDE_DIR}/ui/gotoaddressdialog.h
    ${INCLUDE_DIR}/ui/slice.h
    ${INCLUDE_DIR}/ui/fileblobitem.h<commit_msg>Disable console window on Windows<commit_after>set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

# HACK: ugly hack to provide default compilation type
IF(DEFINED CMAKE_BUILD_TYPE)
   SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of
build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug
Release RelWithDebInfo MinSizeRel.")
ELSE()
   SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build,
options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release
RelWithDebInfo MinSizeRel.")
ENDIF()

project(VELES C CXX)
if(WIN32)
  cmake_minimum_required(VERSION 3.7.0)
else(WIN32)
  cmake_minimum_required(VERSION 3.1.0)
endif(WIN32)

# Basic packaging data
set(CPACK_PACKAGE_VENDOR "Codilime")
set(CPACK_PACKAGE_NAME "veles")
set(CPACK_DEBIAN_PACKAGE_SECTION "Editors")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "VELES hex editor")

include("cmake/googletest.cmake")
include("cmake/qt.cmake")
include("cmake/zlib.cmake")
include("cmake/protobuf.cmake")
# Compiler flags
set(CMAKE_CXX_STANDARD_REQUIRED 11) # Use c++11
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
set(CMAKE_INSTALL_RPATH ".")
if(CMAKE_COMPILER_IS_GNUCXX)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall --std=c++11") # All warnings
  set(ADDITIONAL_LINK_LIBRARIES "pthread")
endif()
if(MSVC)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc ") # set exception handling mode and linking mode
endif()
if(APPLE)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif(APPLE)

# Sources
set(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(SRC_DIR ${CMAKE_SOURCE_DIR}/src)
set(TEST_DIR ${CMAKE_SOURCE_DIR}/test)

include_directories(${INCLUDE_DIR})
include_directories(${CMAKE_BINARY_DIR}/protobuf)

# VELES build rules
# LIB: veles_base
add_library(veles_base
    ${INCLUDE_DIR}/util/icons.h
    ${INCLUDE_DIR}/util/concurrency/threadpool.h
    ${INCLUDE_DIR}/util/sampling/isampler.h
    ${INCLUDE_DIR}/util/sampling/uniform_sampler.h
    ${INCLUDE_DIR}/util/sampling/fake_sampler.h
    ${INCLUDE_DIR}/util/settings/theme.h
    ${INCLUDE_DIR}/util/settings/hexedit.h
    ${INCLUDE_DIR}/util/settings/network.h

    ${INCLUDE_DIR}/util/encoders/base64_encoder.h
    ${INCLUDE_DIR}/util/encoders/c_data_encoder.h
    ${INCLUDE_DIR}/util/encoders/c_string_encoder.h
    ${INCLUDE_DIR}/util/encoders/factory.h
    ${INCLUDE_DIR}/util/encoders/hex_encoder.h
    ${INCLUDE_DIR}/util/encoders/idecoder.h
    ${INCLUDE_DIR}/util/encoders/iencoder.h
    ${INCLUDE_DIR}/util/encoders/text_encoder.h
    ${INCLUDE_DIR}/util/encoders/url_encoder.h

    ${INCLUDE_DIR}/util/string_utils.h

    ${SRC_DIR}/util/icons.cc
    ${SRC_DIR}/util/concurrency/threadpool.cc
    ${SRC_DIR}/util/sampling/isampler.cc
    ${SRC_DIR}/util/sampling/uniform_sampler.cc
    ${SRC_DIR}/util/sampling/fake_sampler.cc
    ${SRC_DIR}/util/settings/theme.cc
    ${SRC_DIR}/util/settings/hexedit.cc
    ${SRC_DIR}/util/settings/network.cc

    ${SRC_DIR}/util/encoders/base64_encoder.cc
    ${SRC_DIR}/util/encoders/c_data_encoder.cc
    ${SRC_DIR}/util/encoders/c_string_encoder.cc
    ${SRC_DIR}/util/encoders/factory.cc
    ${SRC_DIR}/util/encoders/hex_encoder.cc
    ${SRC_DIR}/util/encoders/text_encoder.cc
    ${SRC_DIR}/util/encoders/url_encoder.cc

    ${SRC_DIR}/util/string_utils.cc
    ${SRC_DIR}/util/version.cc)

qt5_use_modules(veles_base Core Gui Widgets)
target_link_libraries(veles_base ${ADDITIONAL_LINK_LIBRARIES})

# LIB: veles_visualisation

qt5_wrap_ui(VISUALISATION_FORMS
    ${SRC_DIR}/visualisation/selectrangedialog.ui
    ${SRC_DIR}/visualisation/samplingmethoddialog.ui
    )

qt5_add_resources(VISUALISATION_SHADERS ${SRC_DIR}/visualisation/shaders/shaders.qrc)
add_library(veles_visualisation
    ${INCLUDE_DIR}/visualisation/panel.h
    ${INCLUDE_DIR}/visualisation/base.h
    ${INCLUDE_DIR}/visualisation/digram.h
    ${INCLUDE_DIR}/visualisation/trigram.h
    ${INCLUDE_DIR}/visualisation/minimap.h
    ${INCLUDE_DIR}/visualisation/minimap_panel.h
    ${INCLUDE_DIR}/visualisation/selectrangedialog.h
    ${INCLUDE_DIR}/visualisation/manipulator.h
    ${INCLUDE_DIR}/visualisation/samplingmethoddialog.h
    ${SRC_DIR}/visualisation/panel.cc
    ${SRC_DIR}/visualisation/base.cc
    ${SRC_DIR}/visualisation/digram.cc
    ${SRC_DIR}/visualisation/trigram.cc
    ${SRC_DIR}/visualisation/minimap.cc
    ${SRC_DIR}/visualisation/minimap_panel.cc
    ${SRC_DIR}/visualisation/selectrangedialog.cc
    ${SRC_DIR}/visualisation/manipulator.cc
    ${SRC_DIR}/visualisation/samplingmethoddialog.cc
    ${VISUALISATION_FORMS}
    ${VISUALISATION_SHADERS})

qt5_use_modules(veles_visualisation Core Gui Widgets)
target_link_libraries(veles_visualisation veles_base)

# LIB: veles_data
add_library(veles_data
    ${INCLUDE_DIR}/data/types.h
    ${INCLUDE_DIR}/data/bindata.h
    ${INCLUDE_DIR}/data/repack.h
    ${INCLUDE_DIR}/data/field.h
    ${SRC_DIR}/data/bindata.cc
    ${SRC_DIR}/data/repack.cc
)

qt5_use_modules(veles_data Core)

# LIB: veles_dbif
add_library(veles_dbif
    ${INCLUDE_DIR}/dbif/error.h
    ${INCLUDE_DIR}/dbif/info.h
    ${INCLUDE_DIR}/dbif/method.h
    ${INCLUDE_DIR}/dbif/promise.h
    ${INCLUDE_DIR}/dbif/types.h
    ${INCLUDE_DIR}/dbif/universe.h
    ${SRC_DIR}/dbif/dbif.cc
)

qt5_use_modules(veles_dbif Core)
target_link_libraries(veles_dbif veles_data)

file(GLOB kaitai_headers
    "${INCLUDE_DIR}/kaitai/*.h"
)

file(GLOB kaitai_sources
    "${SRC_DIR}/kaitai/*.cc"
)

# LIB: parser
add_library(parser
    ${INCLUDE_DIR}/parser/parser.h
    ${INCLUDE_DIR}/parser/stream.h
    ${INCLUDE_DIR}/parser/unpyc.h
    ${INCLUDE_DIR}/parser/unpng.h
    ${INCLUDE_DIR}/parser/utils.h
    ${kaitai_headers}
    ${SRC_DIR}/parser/parser.cc
    ${SRC_DIR}/parser/unpyc.cc
    ${SRC_DIR}/parser/unpng.cc
    ${SRC_DIR}/parser/utils.cc
    ${kaitai_sources}
)

qt5_use_modules(parser Core)
add_dependencies(parser zlib)
target_link_libraries(parser veles_db veles_dbif ${ZLIB_LIBRARIES})

# generate protobuf files
add_subdirectory(protobuf)

# LIB: veles_db
add_library(veles_db
    ${INCLUDE_DIR}/db/db.h
    ${INCLUDE_DIR}/db/getter.h
    ${INCLUDE_DIR}/db/handle.h
    ${INCLUDE_DIR}/db/object.h
    ${INCLUDE_DIR}/db/types.h
    ${INCLUDE_DIR}/db/universe.h
    ${SRC_DIR}/db/universe.cc
    ${SRC_DIR}/db/object.cc
    ${SRC_DIR}/db/handle.cc
)

qt5_use_modules(veles_db Core)
add_dependencies(veles_db veles_network)
target_link_libraries(veles_db veles_dbif parser)

# EXE: dbif_test
add_executable(dbif_test ${SRC_DIR}/dbif_test.cc)

qt5_use_modules(dbif_test Core)

target_link_libraries(dbif_test veles_db veles_network)

# EXE: unpyc
add_executable(unpyc ${SRC_DIR}/unpyc.cc)

qt5_use_modules(unpyc Core)

target_link_libraries(unpyc veles_db parser veles_network)

#target_link_libraries(test_veles veles)

# Resources
qt5_add_resources(RESOURCES resources/veles.qrc)
qt5_wrap_ui(FORMS
    ${SRC_DIR}/ui/optionsdialog.ui
    ${SRC_DIR}/ui/searchdialog.ui
    ${SRC_DIR}/ui/gotoaddressdialog.ui
    ${SRC_DIR}/ui/createchunkdialog.ui
    ${SRC_DIR}/ui/databaseinfo.ui
    ${SRC_DIR}/ui/logwidget.ui
    )

if(WIN32)
  set(ICONS ${CMAKE_SOURCE_DIR}/resources/icons/veles.rc)
endif(WIN32)

if(APPLE)
  set(ICONS ${CMAKE_SOURCE_DIR}/resources/icons/veles.icns)
  set(MACOSX_BUNDLE_ICON_FILE veles.icns)
  set_source_files_properties(${ICONS} PROPERTIES
    MACOSX_PACKAGE_LOCATION Resources)
endif(APPLE)

if(WIN32)
  # Don't create console window.
  set(GUI_TYPE WIN32)
endif(WIN32)

# EXE: Main executable
add_executable(main_ui
    ${GUI_TYPE}
    ${INCLUDE_DIR}/ui/logwidget.h
    ${INCLUDE_DIR}/ui/veles_mainwindow.h
    ${INCLUDE_DIR}/ui/dockwidget.h
    ${INCLUDE_DIR}/ui/dockwidget_native.h
    ${INCLUDE_DIR}/ui/hexeditwidget.h
    ${INCLUDE_DIR}/ui/nodetreewidget.h
    ${INCLUDE_DIR}/ui/nodewidget.h
    ${INCLUDE_DIR}/ui/optionsdialog.h
    ${INCLUDE_DIR}/ui/hexedit.h
    ${INCLUDE_DIR}/ui/searchdialog.h
    ${INCLUDE_DIR}/ui/gotoaddressdialog.h
    ${INCLUDE_DIR}/ui/slice.h
    ${INCLUDE_DIR}/ui/fileblobitem.h
{'fraction_non_alphanumeric': 0.13062865037995353, 'fraction_numerical': 0.005400992275325002, 'mean_word_length': 5.108170310701956, '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': '600462', 'n_tokens_mistral': 6612, 'n_tokens_neox': 6107, 'n_words': 704}