1) First draft of the TUI functionality
2) Added env_reader functions (env.hpp and env.cpp) 3) Program looks for a .env on startup and creates one based on user input if not found. 4) Refactored log_parsing and ip_to_geo to use the global env variables for parsing and ip lookup from the local .mmdb database 5) CMakeLists.txt is now cross platform functional 6) Added various cross platform checks for creating .env variables
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(ParseLogCLI LANGUAGES CXX)
|
||||
|
||||
# System and compiler configurations
|
||||
@@ -6,14 +6,16 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# ==========================================
|
||||
# 1. CORE LIBRARY TARGET
|
||||
# ==========================================
|
||||
# Compiles your core logic files into a shared library module
|
||||
add_library(parselog_core
|
||||
log_parsing/log_parsing.cpp
|
||||
ip_to_geo/ip_to_geo.cpp
|
||||
third_party/src/GeoLite2PP.cpp
|
||||
add_library(parselog_core
|
||||
log_parsing/log_parsing.cpp
|
||||
ip_to_geo/ip_to_geo.cpp
|
||||
env_reader/env.cpp
|
||||
third_party/src/GeoLite2PP.cpp
|
||||
third_party/src/GeoLite2PP_error_category.cpp
|
||||
)
|
||||
|
||||
@@ -21,13 +23,45 @@ add_library(parselog_core
|
||||
target_include_directories(parselog_core PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/log_parsing
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ip_to_geo
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/third_party/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/third_party/include
|
||||
)
|
||||
|
||||
# Link the static third-party MaxMind binary
|
||||
target_link_libraries(parselog_core PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/third_party/lib/libmaxminddb.a
|
||||
)
|
||||
# CROSS-PLATFORM FIXED: Automatically links appropriate binary dependencies based on OS
|
||||
if(WIN32)
|
||||
if(MSVC)
|
||||
# Windows via Visual Studio Compiler
|
||||
target_link_libraries(parselog_core PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/third_party/lib/maxminddb.lib
|
||||
)
|
||||
else()
|
||||
# Windows via MinGW/GCC Toolchain
|
||||
target_link_libraries(parselog_core PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/third_party/lib/libmaxminddb.a
|
||||
)
|
||||
endif()
|
||||
|
||||
# Windows requires Windows Sockets API linked for libmaxminddb network resolutions
|
||||
target_link_libraries(parselog_core PRIVATE ws2_32)
|
||||
|
||||
elseif(APPLE)
|
||||
# macOS Specific Path Integrations (Handles Intel /opt/local and Apple Silicon /opt/homebrew)
|
||||
find_library(MAXMIND_LIB maxminddb HINTS /opt/homebrew/lib /usr/local/lib /opt/local/lib)
|
||||
|
||||
if(MAXMIND_LIB)
|
||||
target_link_libraries(parselog_core PRIVATE ${MAXMIND_LIB})
|
||||
else()
|
||||
# Fallback to local static file repository boundary if brew package is missing
|
||||
target_link_libraries(parselog_core PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/third_party/lib/libmaxminddb.a
|
||||
)
|
||||
endif()
|
||||
|
||||
else()
|
||||
# Standard Linux (Ubuntu, Arch Linux, Fedora, etc.)
|
||||
target_link_libraries(parselog_core PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/third_party/lib/libmaxminddb.a
|
||||
)
|
||||
endif()
|
||||
|
||||
# Version definitions needed by your GeoLite2PP wrapper
|
||||
target_compile_definitions(parselog_core PRIVATE
|
||||
@@ -35,24 +69,36 @@ target_compile_definitions(parselog_core PRIVATE
|
||||
)
|
||||
|
||||
# ==========================================
|
||||
# 2. APPLICATION EXECUTABLE
|
||||
# 2. FTXUI Library Download
|
||||
# ==========================================
|
||||
# Compiles your main user-facing CLI binary
|
||||
add_executable(parselog_cli main.cpp)
|
||||
target_link_libraries(parselog_cli PRIVATE parselog_core)
|
||||
FetchContent_Declare(
|
||||
ftxui
|
||||
GIT_REPOSITORY https://github.com/ArthurSonzogni/FTXUI.git
|
||||
GIT_TAG v6.1.9
|
||||
)
|
||||
FetchContent_MakeAvailable(ftxui)
|
||||
|
||||
set_target_properties(parselog_cli PROPERTIES
|
||||
# ==========================================
|
||||
# 3. APPLICATION EXECUTABLE
|
||||
# ==========================================
|
||||
add_executable(parselog_cli main.cpp)
|
||||
|
||||
target_link_libraries(parselog_cli
|
||||
PRIVATE
|
||||
parselog_core
|
||||
ftxui::screen
|
||||
ftxui::dom
|
||||
ftxui::component
|
||||
)
|
||||
|
||||
# CROSS-PLATFORM FIXED: Output targets route uniformly into the root project space
|
||||
set_target_properties(parselog_cli PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
|
||||
# ==========================================
|
||||
# 3. TEST SUITE
|
||||
# 4. TEST SUITE
|
||||
# ==========================================
|
||||
# Activates the built-in CTest engine
|
||||
enable_testing()
|
||||
|
||||
# add_executable(parselog_test tests.cpp)
|
||||
# target_link_libraries(parselog_test PRIVATE parselog_core)
|
||||
|
||||
# Registers the testing executable under the "RunAllTests" banner
|
||||
# add_test(NAME RunAllTests COMMAND parselog_test)
|
||||
|
||||
Reference in New Issue
Block a user