Skip to content
Merged
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'
36 changes: 36 additions & 0 deletions LogMonitor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_BUILD_TYPE Release)
set(VCPKG_TARGET_TRIPLET x64-windows)

# 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)

# Set Boost paths
set(BOOST_ROOT "${VCPKG_ROOT}/installed/x64-windows" CACHE PATH "Boost installation root")
set(Boost_INCLUDE_DIR "${VCPKG_ROOT}/installed/x64-windows/include" CACHE PATH "Boost include directory")
endif()

# Set Windows SDK version if available
if (DEFINED ENV{SDKVersion})
set(CMAKE_SYSTEM_VERSION $ENV{SDKVersion})
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
42 changes: 42 additions & 0 deletions LogMonitor/LogMonitorTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
cmake_minimum_required(VERSION 3.15)

project(LogMonitorTests)

find_package(Boost REQUIRED COMPONENTS json)

# Automatically gather all test source files
file(GLOB_RECURSE TEST_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.cpp")

# Ensure all source files exist before proceeding
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 LogMonitor and Boost.JSON
target_link_libraries(LogMonitorTests PRIVATE LogMonitor Boost::json)

# Enable testing
enable_testing()

add_test(NAME LogMonitorTests COMMAND LogMonitorTests)
Loading