forked from intel/ipmctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
716 lines (639 loc) · 24.5 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
# Copyright (c) 2018, Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause
cmake_minimum_required(VERSION 2.8.12)
message("cmake version: " ${CMAKE_VERSION})
project(ipmctl)
set(CMAKE_VERBOSE_MAKEFILE on)
get_filename_component(ROOT ./ ABSOLUTE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake/Find")
set(LIBIPMCTL_VERSION_MAJOR 4)
set(LIBIPMCTL_VERSION_MINOR 0)
set(LIBIPMCTL_VERSION_PATCH 0)
set(LIBIPMCTL_VERSION_STRING ${LIBIPMCTL_VERSION_MAJOR}.${LIBIPMCTL_VERSION_MINOR}.${LIBIPMCTL_VERSION_PATCH})
set(IPMCTL_VERSION_MAJOR 02)
set(IPMCTL_VERSION_MINOR 00)
set(IPMCTL_VERSION_PATCH 00)
set(IPMCTL_SPEC_VERSION_MAJOR 2)
set(IPMCTL_SPEC_VERSION_MINOR 05)
set(IPMCTL_DRAFT "-draft")
set(IPMCTL_SPEC_VERSION_STRING ${IPMCTL_SPEC_VERSION_MAJOR}.${IPMCTL_SPEC_VERSION_MINOR}${IPMCTL_DRAFT})
if(BUILDNUM)
set(IPMCTL_VERSION_STRING ${BUILDNUM})
else()
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tag --dirty
OUTPUT_VARIABLE IPMCTL_VERSION_STRING
RESULT_VARIABLE GIT_RETURN_CODE
)
# strip leading string in git tag
string(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)" IPMCTL_VERSION_STRING "${IPMCTL_VERSION_STRING}")
# strip ending newline
string(REGEX REPLACE "\n" "" IPMCTL_VERSION_STRING "${IPMCTL_VERSION_STRING}")
endif()
if(NOT GIT_FOUND OR ${GIT_RETURN_CODE})
set(IPMCTL_VERSION_STRING ${IPMCTL_VERSION_MAJOR}.${IPMCTL_VERSION_MINOR}.${IPMCTL_VERSION_PATCH}.3885)
endif()
endif()
message(VERSION: ${IPMCTL_VERSION_STRING})
if(RELEASE)
set(BUILD_TYPE release)
set(CMAKE_BUILD_TYPE Release)
SET(CMAKE_SKIP_BUILD_RPATH TRUE)
else()
set(BUILD_TYPE debug)
set(CMAKE_BUILD_TYPE Debug)
add_definitions(
-DDEBUG_BUILD
)
endif()
message(BUILD_TYPE: ${CMAKE_BUILD_TYPE})
if(BUILD_STATIC)
set(LIB_TYPE STATIC)
else()
set(LIB_TYPE SHARED)
endif()
if(ESX_BUILD)
set(OS_TYPE esx)
set(FILE_PREFIX esx)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "/opt/intel/bin")
find_package(PythonInterp REQUIRED)
elseif(UNIX)
set(LNX_BUILD 1)
set(OS_TYPE linux)
set(FILE_PREFIX lnx)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(PythonInterp REQUIRED)
find_package(asciidoctor)
find_package(asciidoc)
pkg_check_modules(NDCTL REQUIRED libndctl>=58.2)
pkg_check_modules(SYSTEMD systemd)
elseif(MSVC)
set(WIN_BUILD 1)
set(OS_TYPE win)
set(FILE_PREFIX win)
find_package(PythonInterp REQUIRED)
find_package(asciidoctor)
find_package(asciidoc)
endif()
message(BUILD_TYPE: ${CMAKE_BUILD_TYPE})
message(OS_TYPE: ${OS_TYPE})
message(LIB_TYPE: ${LIB_TYPE})
message(COMPILER: ${CMAKE_C_COMPILER})
message(SYSROOT: ${MY_CMAKE_SYSROOT})
message(TOOLCHAIN: ${CMAKE_TOOLCHAIN_FILE})
set(OUTPUT_DIR ${ROOT}/output/${BUILD_TYPE})
file(MAKE_DIRECTORY ${OUTPUT_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ROOT}/output/${BUILD_TYPE})
set(CMAKE_BINARY_DIR ${OUTPUT_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
if(INTERNAL_MFG)
include(CMake/mfg.cmake)
endif()
#----------------------------------------------------------------------------------------------------
# Project wide defines and flags
#----------------------------------------------------------------------------------------------------
add_definitions(
-DOS_BUILD
-DPCD_CACHE_ENABLED
-D__VERSION_NUMBER__=${IPMCTL_VERSION_STRING}
-DPLAYBACK_RECORD_SUPPORTED
)
# Promote warnings to errors only for release builds
if(MSVC)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /O2 /WX")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /WX")
set(CMAKE_C_FLAGS_DEBUG_ "${CMAKE_C_FLAGS_DEBUG} /Od")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od")
else()
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -fno-strict-aliasing -D_FORTIFY_SOURCE=2")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fno-strict-aliasing -D_FORTIFY_SOURCE=2")
if(LNX_BUILD)
#A few warnings yet to resolve under esx
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Werror")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Werror")
endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ggdb")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
endif()
if(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_MSABI_VA_FUNCS -std=c99 -Wformat -Wformat-security -D_XOPEN_SOURCE=500 -Wall -Wfatal-errors -MMD -fPIC -fno-strict-aliasing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wformat -Wformat-security -D_XOPEN_SOURCE=500 -Drestrict=__restrict__ -Wall -Wfatal-errors -MMD -fPIC -fno-strict-aliasing")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now -pie")
elseif(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GS /DynamicBase /sdl")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS /DynamicBase /sdl")
set(CMAKE_SHARED_LINKER_FLAGS "/NXCompat")
endif()
if(LNX_BUILD)
if("${CMAKE_INSTALL_DATAROOTDIR}" STREQUAL "/usr/share")
# Workaround for the RPM build cause the %{_datarootdir} is already prefixed
set(INI_INSTALL_FILEPATH "${CMAKE_INSTALL_DATAROOTDIR}")
else()
if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/")
# In case the CMAKE_INSTALL_PREFIX equals "/" for <dir> other than the SYSCONFDIR and LOCALSTATEDIR,
# the value of CMAKE_INSTALL_<dir> is prefixed with usr/ if it is not user-specified as an absolute path.
set(CMAKE_INSTALL_PREFIX "/usr")
message("CMAKE_INSTALL_PREFIX value changed to: ${CMAKE_INSTALL_PREFIX}")
endif()
if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
set(CMAKE_INSTALL_DATAROOTDIR "share")
message("CMAKE_INSTALL_DATAROOTDIR not defined. Creating a new definition with value: ${CMAKE_INSTALL_DATAROOTDIR}")
endif()
set(INI_INSTALL_FILEPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}")
endif()
message("INI_INSTALL_FILEPATH definition create with value: ${INI_INSTALL_FILEPATH}")
add_definitions(
-D_GNU_SOURCE
-D__LINUX__
-DHAVE_C99
-DINI_INSTALL_FILEPATH="${INI_INSTALL_FILEPATH}/ipmctl/"
)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.9)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong")
endif()
endif()
if(MSVC)
if(VCREDIST_STATIC)
# Force vcredist to be linked static
# Keep this after all other compiler flag setup
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
message("VCREDIST: STATIC")
else()
message("VCREDIST: SHARED")
endif()
endif()
#----------------------------------------------------------------------------------------------------
# OS driver interface library
#----------------------------------------------------------------------------------------------------
if(MSVC)
FILE(GLOB OS_INTERFACE_SOURCE_FILES
src/os/os_str.c
src/os/os_common.c
src/os/win/win_scm2_ioctl.c
src/os/win/win_scm2_passthrough.c
src/os/win/win_scm2_ioctl_passthrough.c
src/os/win/win_common.c
src/os/win/win_api.c
src/os/win/win_scm2_adapter.c
src/os/win/win_system.c
)
elseif(UNIX)
FILE(GLOB OS_INTERFACE_SOURCE_FILES
src/os/os_str.c
src/os/os_common.c
src/os/${OS_TYPE}/${FILE_PREFIX}_adapter_passthrough.c
src/os/${OS_TYPE}/${FILE_PREFIX}_acpi.c
src/os/${OS_TYPE}/${FILE_PREFIX}_common.c
src/os/${OS_TYPE}/${FILE_PREFIX}_api.c
src/os/${OS_TYPE}/${FILE_PREFIX}_adapter.c
src/os/${OS_TYPE}/${FILE_PREFIX}_system.c
)
endif()
add_library(ipmctl_os_interface STATIC ${OS_INTERFACE_SOURCE_FILES})
target_link_libraries(ipmctl_os_interface
${CMAKE_THREAD_LIBS_INIT}
)
target_include_directories(ipmctl_os_interface PUBLIC
src/os
src/os/${OS_TYPE}
DcpmPkg/common
src/os/nvm_api
src/os/s_string
MdePkg/Include
MdePkg/Include/Uefi
src/os/efi_shim
)
if (MSVC)
string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+\\.[0-9]+" "\\1" sdk_version_major $ENV{WindowsSDKVersion})
string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" sdk_version_major2 $ENV{WindowsSDKVersion})
string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" sdk_version_minor $ENV{WindowsSDKVersion})
if (${sdk_version_major} GREATER 9 AND ${sdk_version_minor} GREATER 17650)
MESSAGE("Using Windows SDK 17650+")
else()
MESSAGE(FATAL_ERROR "Requires Windows SDK version 17650 or newer.")
endif()
endif()
#----------------------------------------------------------------------------------------------------
# libipmctl
#----------------------------------------------------------------------------------------------------
file(GLOB LIBIPMCTL_SOURCE_FILES
src/os/efi_shim/AutoGen.c
src/os/efi_shim/os_efi_api.c
src/os/efi_shim/os_efi_preferences.c
src/os/efi_shim/os_efi_shell_parameters_protocol.c
src/os/efi_shim/os_efi_simple_file_protocol.c
src/os/efi_shim/os_efi_bs_protocol.c
src/os/ini/ini.c
src/os/eventlog/event.c
src/os/nvm_api/nvm_management.c
src/os/nvm_api/nvm_output_parsing.c
src/os/s_string/s_str.c
DcpmPkg/cli/NvmDimmCli.c
DcpmPkg/cli/CommandParser.c
DcpmPkg/cli/Common.c
DcpmPkg/cli/ShowAcpiCommand.c
DcpmPkg/cli/ShowSensorCommand.c
DcpmPkg/cli/ShowDimmsCommand.c
DcpmPkg/cli/ShowSocketsCommand.c
DcpmPkg/cli/ShowMemoryResourcesCommand.c
DcpmPkg/cli/ShowSystemCapabilitiesCommand.c
DcpmPkg/cli/ShowFirmwareCommand.c
DcpmPkg/cli/ShowPcdCommand.c
DcpmPkg/cli/DeletePcdCommand.c
DcpmPkg/cli/ShowRegionsCommand.c
DcpmPkg/cli/CreateGoalCommand.c
DcpmPkg/cli/ShowGoalCommand.c
DcpmPkg/cli/DeleteGoalCommand.c
DcpmPkg/cli/ShowErrorCommand.c
DcpmPkg/cli/ShowCelCommand.c
DcpmPkg/cli/DumpDebugCommand.c
DcpmPkg/cli/StartDiagnosticCommand.c
DcpmPkg/cli/ShowPreferencesCommand.c
DcpmPkg/cli/ShowTopologyCommand.c
DcpmPkg/cli/SetPreferencesCommand.c
DcpmPkg/cli/SetSensorCommand.c
DcpmPkg/cli/LoadGoalCommand.c
DcpmPkg/cli/DumpGoalCommand.c
DcpmPkg/cli/SetDimmCommand.c
DcpmPkg/cli/LoadCommand.c
DcpmPkg/cli/DeleteDimmCommand.c
src/os/cli_cmds/DumpSupportCommand.c
DcpmPkg/cli/ShowRegisterCommand.c
DcpmPkg/cli/StartFormatCommand.c
DcpmPkg/cli/ShowPerformanceCommand.c
DcpmPkg/cli/ShowHostServerCommand.c
DcpmPkg/cli/ShowCmdAccessPolicyCommand.c
DcpmPkg/cli/StartSessionCommand.c
DcpmPkg/cli/StopSessionCommand.c
DcpmPkg/cli/LoadSessionCommand.c
DcpmPkg/cli/ShowSessionCommand.c
DcpmPkg/cli/DumpSessionCommand.c
DcpmPkg/common/FwUtility.c
DcpmPkg/common/Utility.c
DcpmPkg/common/NvmTables.c
DcpmPkg/common/ShowAcpi.c
DcpmPkg/common/NvmStatus.c
DcpmPkg/common/NvmHealth.c
DcpmPkg/common/LbaCommon.c
DcpmPkg/common/Convert.c
DcpmPkg/common/PcdCommon.c
DcpmPkg/common/OsCommon.c
DcpmPkg/common/DataSet.c
DcpmPkg/common/Printer.c
DcpmPkg/common/Strings.c
DcpmPkg/common/Nlog.c
DcpmPkg/common/ReadRunTimePreferences.c
DcpmPkg/driver/Protocol/Driver/NvmDimmConfig.c
DcpmPkg/driver/NvmDimmDriver.c
DcpmPkg/driver/Core/Dimm.c
DcpmPkg/driver/Core/Namespace.c
DcpmPkg/driver/Core/NvmSecurity.c
DcpmPkg/driver/Core/Region.c
DcpmPkg/driver/Core/Btt.c
DcpmPkg/driver/Core/Pfn.c
DcpmPkg/driver/Core/Diagnostics/ConfigDiagnostic.c
DcpmPkg/driver/Core/Diagnostics/CoreDiagnostics.c
DcpmPkg/driver/Core/Diagnostics/FwDiagnostic.c
DcpmPkg/driver/Core/Diagnostics/QuickDiagnostic.c
DcpmPkg/driver/Core/Diagnostics/SecurityDiagnostic.c
DcpmPkg/driver/Protocol/Device/NvmFirmwareManagement.c
DcpmPkg/driver/Protocol/Namespace/NvmDimmBlockIo.c
DcpmPkg/driver/Utils/PlatformConfigData.c
DcpmPkg/driver/Utils/AcpiParsing.c
DcpmPkg/driver/Utils/ProcessorAndTopologyInfo.c
DcpmPkg/driver/Utils/Interleave.c
DcpmPkg/driver/Utils/SmbiosUtility.c
DcpmPkg/driver/Utils/DumpLoadRegions.c
DcpmPkg/common/Pbr.c
DcpmPkg/common/PbrDcpmm.c
DcpmPkg/common/PbrOs.c
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c
MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
MdePkg/Library/BaseLib/Math64.c
MdePkg/Library/BaseLib/MultU64x32.c
MdePkg/Library/BaseLib/DivU64x32Remainder.c
MdePkg/Library/BaseLib/Unaligned.c
MdePkg/Library/BaseLib/BitField.c
MdePkg/Library/BaseLib/LinkedList.c
MdePkg/Library/BaseLib/LShiftU64.c
MdePkg/Library/BaseLib/Math64.c
MdePkg/Library/BaseLib/SwapBytes64.c
MdePkg/Library/BaseLib/SwapBytes32.c
MdePkg/Library/BaseLib/SwapBytes16.c
MdePkg/Library/BaseLib/String.c
MdePkg/Library/BaseLib/SafeString.c
MdePkg/Library/BaseLib/RShiftU64.c
MdePkg/Library/BaseLib/Math64.c
MdePkg/Library/BaseLib/DivU64x32.c
${LIBIPMCTL_MFG_FILES}
)
if(EXISTS "${ROOT}/CMake/internal.cmake")
include("${ROOT}/CMake/internal.cmake")
endif()
# OS Files
list(APPEND LIBIPMCTL_SOURCE_FILES
src/os/efi_shim/${FILE_PREFIX}_efi_api.c
)
add_library(ipmctl ${LIB_TYPE} ${LIBIPMCTL_SOURCE_FILES})
target_include_directories(ipmctl PUBLIC
DcpmPkg/cli
src/os
src/os/efi_shim
src/os/ini
src/os/eventlog
src/os/nvm_api
src/os/s_string
src/os/cli_cmds
DcpmPkg/common
DcpmPkg/driver
DcpmPkg/driver/Utils
DcpmPkg/driver/Protocol/Driver
DcpmPkg/driver/Core
DcpmPkg/driver/Protocol/Namespace
DcpmPkg/driver/Protocol/Device
DcpmPkg/driver/Core/Diagnostics
MdePkg
MdePkg/Include
MdePkg/Include/Protocol
MdePkg/Include/Uefi
MdePkg/Include/Library
ShellPkg
ShellPkg/Include
ShellPkg/Include/Protocol
ShellPkg/Include/Library
ShellPkg/Library
MdeModulePkg
MdeModulePkg/Include
MdeModulePkg/Include/Library
)
if(MSVC)
set_target_properties(ipmctl PROPERTIES PREFIX "lib")
target_compile_options(ipmctl PRIVATE /FIAutoGen.h -D__NVM_DLL__ -D__NVM_API_DLL_EXPORTS__ )
# FIXME: Ignore warnings for secure functions
SET_SOURCE_FILES_PROPERTIES(src/os/efi_shim/os_efi_simple_file_protocol.c PROPERTIES COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS)
SET_SOURCE_FILES_PROPERTIES(src/os/eventlog/event.c PROPERTIES COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS)
SET_SOURCE_FILES_PROPERTIES(src/os/ini/ini.c PROPERTIES COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS)
SET_SOURCE_FILES_PROPERTIES(src/os/efi_shim/os_efi_preferences.c PROPERTIES COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS)
SET_SOURCE_FILES_PROPERTIES(src/os/nvm_api/nvm_management.c PROPERTIES COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS)
SET_SOURCE_FILES_PROPERTIES(DcpmPkg/cli/Common.c PROPERTIES COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS)
SET_SOURCE_FILES_PROPERTIES(src/os/nvm_api/nvm_output_parsing.c PROPERTIES COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS)
SET_SOURCE_FILES_PROPERTIES(src/os/efi_shim/os_efi_shell_parameters_protocol.c PROPERTIES COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS)
SET_SOURCE_FILES_PROPERTIES(src/os/cli_cmds/DumpSupportCommand.c PROPERTIES COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS)
else()
target_compile_options(ipmctl PRIVATE
-include AutoGen.h
)
endif()
add_dependencies(ipmctl
stringdefs
iniconfig
)
target_link_libraries(ipmctl
ipmctl_os_interface
)
if(LNX_BUILD)
target_link_libraries(ipmctl
${NDCTL_LIBRARIES}
)
endif()
set_target_properties(ipmctl PROPERTIES
VERSION ${LIBIPMCTL_VERSION_STRING}
SOVERSION ${LIBIPMCTL_VERSION_MAJOR}
)
#---------------------------------------------------------------------------------------------------
# ipmctl executable
#---------------------------------------------------------------------------------------------------
FILE(GLOB IPMCTL_SOURCE_FILES
src/os/os_main.c
)
add_executable(ipmctl-bin ${IPMCTL_SOURCE_FILES})
target_link_libraries(ipmctl-bin
ipmctl
)
target_include_directories(ipmctl-bin PUBLIC
src/os
src/os/nvm_api
src/os/ini
)
set_target_properties(ipmctl-bin
PROPERTIES OUTPUT_NAME ipmctl
)
if ((ASCIIDOCTOR_FOUND OR A2X_FOUND) AND LNX_BUILD)
add_dependencies(ipmctl-bin
manpage
)
endif()
if(MSVC)
set_target_properties(ipmctl-bin PROPERTIES LINK_FLAGS "/STACK:3000000")
else()
target_compile_options(ipmctl-bin PRIVATE "-fPIE")
set_target_properties(ipmctl-bin PROPERTIES LINK_FLAGS "-pie")
endif()
#----------------------------------------------------------------------------------------------------
# Generate String Definitions
#----------------------------------------------------------------------------------------------------
set(STRING_DEFS_INPUT_FILES
${ROOT}/DcpmPkg/common/NvmStatus.uni
${ROOT}/DcpmPkg/driver/Core/Diagnostics/DiagnosticsMessages.uni
${ROOT}/src/os/efi_shim/os_efi_hii_auto_gen_strings.py
)
set(STRING_DEFS_OUTPUT_FILES
${ROOT}/src/os/efi_shim/os_efi_hii_auto_gen_strings.h
${ROOT}/src/os/efi_shim/os_efi_hii_auto_gen_defs.h
)
add_custom_target(stringdefs ALL
DEPENDS ${STRING_DEFS_OUTPUT_FILES} ${STRING_DEFS_INPUT_FILES})
add_custom_command(OUTPUT ${STRING_DEFS_OUTPUT_FILES}
COMMAND ${PYTHON_EXECUTABLE} ${ROOT}/src/os/efi_shim/os_efi_hii_auto_gen_strings.py
COMMENT "Generating String Definitions"
DEPENDS ${STRING_DEFS_INPUT_FILES}
)
#----------------------------------------------------------------------------------------------------
# Generate INI Default Config File
#----------------------------------------------------------------------------------------------------
add_custom_target(iniconfig ALL
DEPENDS ${OUTPUT_DIR}/ipmctl_default.conf
)
if(MSVC)
set(PRECOMPILER_FLAG /EP)
else()
set(PRECOMPILER_FLAG -E -P -D__LINUX__)
endif()
add_custom_command(OUTPUT ${OUTPUT_DIR}/ipmctl_default.conf
COMMAND ${CMAKE_C_COMPILER} ${MY_CMAKE_SYSROOT} ${PRECOMPILER_FLAG} ${ROOT}/src/os/ini/ipmctl_default.c > ${ROOT}/src/os/ini/ipmctl_default.i
COMMAND ${PYTHON_EXECUTABLE} ${ROOT}/src/os/ini/ini_auto_gen_default_config.py ${ROOT}/src/os/ini/ipmctl_default.i ${OUTPUT_DIR}/ipmctl_default.conf
COMMAND ${CMAKE_COMMAND} -E remove -f ${ROOT}/src/os/ini/ipmctl_default.i
COMMENT "Generating INI Default Config File"
)
#----------------------------------------------------------------------------------------------------
# Install
#----------------------------------------------------------------------------------------------------
FILE(GLOB NVM_HEADERS
src/os/nvm_api/export_api.h
src/os/nvm_api/nvm_management.h
src/os/nvm_api/nvm_types.h
DcpmPkg/common/NvmSharedDefs.h
)
FILE(COPY LICENSE
DESTINATION ${OUTPUT_DIR})
FILE(COPY ${NVM_HEADERS}
DESTINATION ${OUTPUT_DIR})
FILE(COPY install/linux/logrotate/ipmctl.logrotate.conf
DESTINATION ${OUTPUT_DIR})
if(LNX_BUILD)
include(GNUInstallDirs)
find_package(PkgConfig)
pkg_check_modules(SYSTEMD systemd)
configure_file(${ROOT}/install/linux/libipmctl.pc.in ${OUTPUT_DIR}/libipmctl.pc @ONLY)
if(BUILD_STATIC)
install(TARGETS ipmctl-bin
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
else()
install(TARGETS ipmctl-bin ipmctl
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()
install(FILES ${OUTPUT_DIR}/LICENSE
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/ipmctl
)
install(FILES ${OUTPUT_DIR}/ipmctl_default.conf
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/ipmctl
)
install(FILES ${OUTPUT_DIR}/ipmctl_default.conf
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/ipmctl
RENAME ipmctl.conf
)
install(FILES ${NVM_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
file(MAKE_DIRECTORY output/ipmctl)
install(DIRECTORY output/ipmctl
DESTINATION ${CMAKE_INSTALL_LOCALSTATEDIR}/log
)
install(FILES ${OUTPUT_DIR}/ipmctl.logrotate.conf
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d
RENAME ipmctl
)
install(FILES ${OUTPUT_DIR}/libipmctl.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
if(ASCIIDOCTOR_FOUND OR A2X_FOUND)
install(DIRECTORY ${OUTPUT_DIR}/manpage/
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
)
endif()
endif()
#----------------------------------------------------------------------------------------------------
# Generate man pages with asciidoctor
#----------------------------------------------------------------------------------------------------
if((ASCIIDOCTOR_FOUND OR A2X_FOUND) AND LNX_BUILD)
file(MAKE_DIRECTORY ${OUTPUT_DIR}/manpage)
file(MAKE_DIRECTORY ${OUTPUT_DIR}/docs)
set(DOCUMENTATION_INPUT_FILES
${ROOT}/Documentation/ipmctl/ipmctl.txt
${ROOT}/Documentation/ipmctl/Discovery/ipmctl-show-device.txt
${ROOT}/Documentation/ipmctl/Discovery/ipmctl-show-memory-resources.txt
${ROOT}/Documentation/ipmctl/Discovery/ipmctl-show-socket.txt
${ROOT}/Documentation/ipmctl/Discovery/ipmctl-show-system-capabilities.txt
${ROOT}/Documentation/ipmctl/Discovery/ipmctl-show-topology.txt
${ROOT}/Documentation/ipmctl/Memory_Subsystem_Provisioning/ipmctl-create-goal.txt
${ROOT}/Documentation/ipmctl/Memory_Subsystem_Provisioning/ipmctl-delete-goal.txt
${ROOT}/Documentation/ipmctl/Memory_Subsystem_Provisioning/ipmctl-dump-goal.txt
${ROOT}/Documentation/ipmctl/Memory_Subsystem_Provisioning/ipmctl-load-goal.txt
${ROOT}/Documentation/ipmctl/Memory_Subsystem_Provisioning/ipmctl-show-goal.txt
${ROOT}/Documentation/ipmctl/Persistent_Memory_Provisioning/ipmctl-show-region.txt
${ROOT}/Documentation/ipmctl/Instrumentation/ipmctl-change-sensor.txt
${ROOT}/Documentation/ipmctl/Instrumentation/ipmctl-show-performance.txt
${ROOT}/Documentation/ipmctl/Instrumentation/ipmctl-show-sensor.txt
${ROOT}/Documentation/ipmctl/Support_and_Maintenance/ipmctl-change-preferences.txt
${ROOT}/Documentation/ipmctl/Support_and_Maintenance/ipmctl-dump-support-data.txt
${ROOT}/Documentation/ipmctl/Support_and_Maintenance/ipmctl-help.txt
${ROOT}/Documentation/ipmctl/Support_and_Maintenance/ipmctl-modify-device.txt
${ROOT}/Documentation/ipmctl/Support_and_Maintenance/ipmctl-show-firmware.txt
${ROOT}/Documentation/ipmctl/Support_and_Maintenance/ipmctl-show-preferences.txt
${ROOT}/Documentation/ipmctl/Support_and_Maintenance/ipmctl-update-firmware.txt
${ROOT}/Documentation/ipmctl/Support_and_Maintenance/ipmctl-version.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-show-pcd.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-delete-pcd.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-dump-debug-log.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-inject-error.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-show-cap.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-show-cel.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-start-diagnostic.txt
# ${ROOT}/Documentation/ipmctl/Debug/ipmctl-diagnostic-events.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-show-acpi.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-show-error-log.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-show-session.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-start-session.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-stop-session.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-load-session.txt
${ROOT}/Documentation/ipmctl/Debug/ipmctl-dump-session.txt
)
list(LENGTH DOCUMENTATION_INPUT_FILES LEN)
math(EXPR INPUT_LENGTH "${LEN} -1")
foreach(INDEX RANGE ${INPUT_LENGTH})
list(GET DOCUMENTATION_INPUT_FILES ${INDEX} MAN_INPUT)
string(REGEX MATCH "[^/]*$" MAN_BARE_FILENAME ${MAN_INPUT})
set(MAN_TMP_INPUT ${OUTPUT_DIR}/manpage/${MAN_BARE_FILENAME})
string(REGEX REPLACE "txt$" "1.gz" MAN_OUTPUT "${MAN_TMP_INPUT}")
list(APPEND MANPAGE_OUTPUT_FILES ${MAN_OUTPUT})
if(NOT ASCIIDOCTOR_FOUND)
string(REGEX REPLACE "\\.[^.]*$" "" MAN_GZ_INPUT ${MAN_OUTPUT})
add_custom_command(OUTPUT ${MAN_OUTPUT}
COMMENT "Clean out link markup because they are invalid in the manpages"
COMMAND sed -e 's/<</\\[/g' -e 's/>>/]/g' ${MAN_INPUT} > ${MAN_TMP_INPUT}
COMMAND ${A2X_BINARIES} -f manpage -a mansource=ipmctl -a manmanual="ipmctl" -a ipmctl_version=${IPMCTL_VERSION_STRING} -a os_build=1 -a manpage=1 -D ${OUTPUT_DIR}/manpage ${MAN_TMP_INPUT}
COMMAND gzip -f ${MAN_GZ_INPUT}
COMMAND rm -f ${MAN_TMP_INPUT}
COMMENT "Generating man pages"
DEPENDS ${MAN_INPUT}
)
endif()
endforeach()
add_custom_target(manpage ALL
DEPENDS ${MANPAGE_OUTPUT_FILES} ${DOCUMENTATION_INPUT_FILES}
)
if(ASCIIDOCTOR_FOUND)
add_custom_command(OUTPUT ${MANPAGE_OUTPUT_FILES}
COMMAND ${ASCIIDOCTOR_BINARIES} -b manpage -a mansource=ipmctl -a manmanual="ipmctl" -a ipmctl_version=${IPMCTL_VERSION_STRING} -a os_build=1 -a manpage=1 -D ${OUTPUT_DIR}/manpage ${DOCUMENTATION_INPUT_FILES}
COMMAND gzip -f ${OUTPUT_DIR}/manpage/*.1
COMMENT "Generating man pages"
DEPENDS ${DOCUMENTATION_INPUT_FILES}
)
endif()
endif()
# --------------------------------------------------------------------------------------------------
# Additional includes
# --------------------------------------------------------------------------------------------------
if(LNX_BUILD AND UNIT_TEST)
include(CMake/unit_test.cmake)
endif()
if(ESX_BUILD)
include(CMake/esx.cmake)
endif()
add_subdirectory(src/os/nvm_api_sample)