Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/sdl-compliance-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ jobs:
with:
# The path of the directory in which to save the SARIF results (../results/cpp.sarif)
output: ${{ env.CodeQLResultsDir }}
upload: "always" # Options: 'always', 'failure-only', 'never'
upload: "always" # Options: 'always', 'failure-only', 'never'
24 changes: 24 additions & 0 deletions LogMonitor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.15)

# Define the project
project(LogMonitor)

# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Use vcpkg if available
if (DEFINED ENV{VCPKG_ROOT})
set(VCPKG_ROOT $ENV{VCPKG_ROOT})
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Toolchain file for vcpkg" FORCE)
endif()

# Enable testing framework
enable_testing()

# Enable Unicode globally
add_definitions(-DUNICODE -D_UNICODE)

# Include subdirectories for main and test executables
add_subdirectory(src) # Add main executable's CMake
add_subdirectory(LogMonitorTests) # Add test executable's CMake
58 changes: 58 additions & 0 deletions LogMonitor/LogMonitorTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
cmake_minimum_required(VERSION 3.15)

project(LogMonitorTests)

find_package(Boost REQUIRED)

set(TEST_SOURCES
JsonProcessorTests.cpp
EtwMonitorTests.cpp
EventMonitorTests.cpp
LogFileMonitorTests.cpp
LogMonitorTests.cpp
UtilityTests.cpp
Utility.cpp
pch.cpp
ConfigFileParserTests.cpp
)

# Ensure all source files exist before proceeding
foreach(FILE ${TEST_SOURCES})
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}")
message(WARNING "File not found: ${FILE}")
list(REMOVE_ITEM TEST_SOURCES ${FILE})
endif()
endforeach()

if(NOT TEST_SOURCES)
message(FATAL_ERROR "No valid source files found for LogMonitorTests.")
endif()

# Define test shared library (DLL)
add_library(LogMonitorTests SHARED ${TEST_SOURCES})

# Add a definition for symbol exporting
target_compile_definitions(LogMonitorTests PRIVATE LOGMONITORTESTS_EXPORTS)

# Include directories (for headers)
target_include_directories(LogMonitorTests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR} # Includes Utility.h and pch.h
${CMAKE_CURRENT_SOURCE_DIR}/../src
${Boost_INCLUDE_DIRS}
)

# Set Windows-specific linker flags
set_target_properties(LogMonitorTests PROPERTIES
COMPILE_PDB_NAME "LogMonitorTests"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
LINK_FLAGS "/DEBUG:FULL /OPT:REF /OPT:ICF"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)

# Link with LogMonitor and Boost
target_link_libraries(LogMonitorTests PRIVATE LogMonitor ${Boost_LIBRARIES})

# Enable testing
enable_testing()

add_test(NAME LogMonitorTests COMMAND LogMonitorTests)
Loading