Skip to content

Commit 548cfca

Browse files
author
Charity Kathure
committed
CMakeLists and pipeline changes
Signed-off-by: Charity Kathure <[email protected]>
1 parent 510d60b commit 548cfca

File tree

3 files changed

+47
-27
lines changed

3 files changed

+47
-27
lines changed

LogMonitor/LogMonitorTests/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15)
22

33
project(LogMonitorTests)
44

5-
find_package(Boost REQUIRED)
5+
find_package(Boost REQUIRED COMPONENTS json)
66

77
# Automatically gather all test source files
88
file(GLOB_RECURSE TEST_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.cpp")
@@ -33,8 +33,8 @@ set_target_properties(LogMonitorTests PROPERTIES
3333
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
3434
)
3535

36-
# Link with LogMonitor and Boost
37-
target_link_libraries(LogMonitorTests PRIVATE LogMonitor ${Boost_LIBRARIES})
36+
# Link LogMonitor and Boost.JSON
37+
target_link_libraries(LogMonitorTests PRIVATE LogMonitor Boost::json)
3838

3939
# Enable testing
4040
enable_testing()

LogMonitor/src/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@ cmake_minimum_required(VERSION 3.15)
22

33
project(LogMonitor)
44

5-
# Find Boost (Boost is installed)
6-
find_package(Boost REQUIRED)
5+
find_package(Boost REQUIRED COMPONENTS json)
76

87
file(GLOB_RECURSE SourceFiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.cpp")
98

109
# Define LogMonitor as a library
1110
add_library(LogMonitor ${SourceFiles})
1211

12+
# Add precompiled headers (PCH)
13+
target_precompile_headers(LogMonitor PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/LogMonitor/pch.h)
14+
1315
# Include directories for LogMonitor
1416
target_include_directories(LogMonitor PRIVATE
1517
${CMAKE_CURRENT_SOURCE_DIR}/LogMonitor
1618
${CMAKE_CURRENT_SOURCE_DIR}/LogMonitor/FileMonitor
1719
${Boost_INCLUDE_DIRS}
1820
)
1921

20-
# Link Boost libraries to LogMonitor
21-
target_link_libraries(LogMonitor PRIVATE ${Boost_LIBRARIES})
22+
# Link Boost JSON to LogMonitor
23+
target_link_libraries(LogMonitor PRIVATE Boost::json)

azure-pipelines.yml

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pool:
1010

1111
variables:
1212
solution: '**/*.sln'
13-
buildPlatform: 'x64|ARM'
13+
buildPlatform: 'x64' # Set to x64 or ARM64 depending on the build you want
1414
buildConfiguration: 'Release'
1515
VCPKG_ROOT: '$(Build.SourcesDirectory)\vcpkg'
1616
VCPKG_CMAKE_OPTIONS: '-DCMAKE_TOOLCHAIN_FILE=$(VCPKG_ROOT)\scripts\buildsystems\vcpkg.cmake'
@@ -30,7 +30,7 @@ jobs:
3030
.\bootstrap-vcpkg.bat
3131
.\vcpkg.exe integrate install # Integrate vcpkg with MSBuild
3232
33-
# Install Boost JSON
33+
# Install Boost JSON for the selected platform (x64 or ARM64)
3434
- task: PowerShell@2
3535
displayName: 'Install Boost JSON'
3636
inputs:
@@ -40,20 +40,34 @@ jobs:
4040
Write-Error "vcpkg.exe not found. Exiting..."
4141
exit 1
4242
}
43-
Write-Host "Installing Boost JSON..."
44-
& "$(VCPKG_ROOT)\vcpkg.exe" install boost-json:x64-windows
43+
Write-Host "Installing Boost JSON for platform: $(buildPlatform)..."
44+
if ('$(buildPlatform)' -eq 'x64') {
45+
& "$(VCPKG_ROOT)\vcpkg.exe" install boost-json:x64-windows
46+
} elseif ('$(buildPlatform)' -eq 'ARM64') {
47+
& "$(VCPKG_ROOT)\vcpkg.exe" install boost-json:arm64-windows
48+
} else {
49+
Write-Error "Unsupported build platform: $(buildPlatform)"
50+
exit 1
51+
}
4552
4653
# Verify vcpkg integration
4754
- task: PowerShell@2
4855
displayName: 'Verify vcpkg Integration'
4956
inputs:
5057
targetType: 'inline'
5158
script: |
52-
echo "Verifying vcpkg integration..."
53-
$(VCPKG_ROOT)\vcpkg.exe integrate install
54-
if (!(Test-Path "$(VCPKG_ROOT)\installed\x64-windows\include\boost\json.hpp")) {
55-
Write-Error "Boost JSON header not found. Exiting..."
56-
exit 1
59+
echo "Verifying vcpkg integration for platform: $(buildPlatform)..."
60+
& "$(VCPKG_ROOT)\vcpkg.exe" integrate install
61+
if ('$(buildPlatform)' -eq 'x64') {
62+
if (!(Test-Path "$(VCPKG_ROOT)\installed\x64-windows\include\boost\json.hpp")) {
63+
Write-Error "Boost JSON header not found for x64. Exiting..."
64+
exit 1
65+
}
66+
} elseif ('$(buildPlatform)' -eq 'ARM64') {
67+
if (!(Test-Path "$(VCPKG_ROOT)\installed\arm64-windows\include\boost\json.hpp")) {
68+
Write-Error "Boost JSON header not found for ARM64. Exiting..."
69+
exit 1
70+
}
5771
}
5872
Write-Output "vcpkg integration verified."
5973
@@ -65,12 +79,11 @@ jobs:
6579
script: |
6680
$x86SdkPath = "C:\Program Files (x86)\Windows Kits\10\Include"
6781
$x64SdkPath = "C:\Program Files\Windows Kits\10\Include"
68-
82+
$armSdkPath = "C:\Program Files\Windows Kits\10\Include\arm64"
83+
6984
function Get-SdkVersion {
7085
param ($sdkPath)
71-
7286
$sdkVersion = Get-ChildItem $sdkPath | Where-Object { $_.PSIsContainer -and $_.Name -match '^\d+\.\d+' } | Sort-Object -Property Name | Select-Object -Last 1
73-
7487
return $sdkVersion
7588
}
7689
@@ -79,6 +92,8 @@ jobs:
7992
$sdkFolder = Get-SdkVersion -sdkPath $x64SdkPath
8093
} elseif (Test-Path $x86SdkPath) {
8194
$sdkFolder = Get-SdkVersion -sdkPath $x86SdkPath
95+
} elseif (Test-Path $armSdkPath) {
96+
$sdkFolder = Get-SdkVersion -sdkPath $armSdkPath
8297
}
8398
8499
if ($sdkFolder) {
@@ -89,44 +104,47 @@ jobs:
89104
exit 1
90105
}
91106
92-
# Configure CMake
107+
# Configure CMake based on selected platform
93108
- task: CMake@1
94109
displayName: 'Configure CMake'
95110
inputs:
96111
workingDirectory: '$(Build.SourcesDirectory)\LogMonitor'
97112
cmakeArgs: |
98-
-A x64 -S $(Build.SourcesDirectory)\LogMonitor -B $(Build.BinariesDirectory)\LogMonitor\x64
113+
-A $(buildPlatform) -S $(Build.SourcesDirectory)\LogMonitor -B $(Build.BinariesDirectory)\LogMonitor\$(buildPlatform)
99114
100115
- task: CMake@1
101116
displayName: 'Build with CMake'
102117
inputs:
103-
workingDirectory: '$(Build.BinariesDirectory)\LogMonitor\x64'
118+
workingDirectory: '$(Build.BinariesDirectory)\LogMonitor\$(buildPlatform)'
104119
cmakeArgs: '--build . --config $(buildConfiguration) --parallel'
105-
120+
121+
# Component Governance
106122
- task: ComponentGovernanceComponentDetection@0
107123
inputs:
108124
scanType: 'Register'
109125
verbosity: 'Verbose'
110126
alertWarningLevel: 'Low'
111127

128+
# Install Visual Studio Test Platform
112129
- task: VisualStudioTestPlatformInstaller@1
113130
inputs:
114131
packageFeedSelector: 'nugetOrg'
115132
versionSelector: 'latestPreRelease'
116133

134+
# Run Tests
117135
- task: VSTest@2
118136
inputs:
119137
testSelector: 'testAssemblies'
120138
testAssemblyVer2: '**\*test*.dll'
121-
searchFolder: '$(Build.BinariesDirectory)\LogMonitor\x64\Release\'
139+
searchFolder: '$(Build.BinariesDirectory)\LogMonitor\$(buildPlatform)\$(buildConfiguration)\'
122140
runOnlyImpactedTests: false
123141
runInParallel: false
124142
rerunFailedTests: true
125143
rerunMaxAttempts: 3
126-
144+
127145
# Publish build artifacts
128146
- task: PublishPipelineArtifact@1
129147
inputs:
130-
targetPath: '$(Build.BinariesDirectory)\LogMonitor\x64\Release\'
148+
targetPath: '$(Build.BinariesDirectory)\LogMonitor\$(buildPlatform)\$(buildConfiguration)\'
131149
artifactType: 'pipeline'
132-
artifactName: '64-bit'
150+
artifactName: '$(buildPlatform)-$(buildConfiguration)'

0 commit comments

Comments
 (0)