Skip to content

Commit 1b38ba4

Browse files
authored
Merge branch 'main' into saumya/pref-setup
2 parents 01855f8 + 9d385d3 commit 1b38ba4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

mssql_python/pybind/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,37 @@ project(ddbc_bindings)
55
set(CMAKE_CXX_STANDARD 17)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
77

8+
# Enable verbose output to see actual compiler/linker commands
9+
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Verbose output" FORCE)
10+
811
if (MSVC)
12+
# Security compiler options for OneBranch compliance
13+
message(STATUS "Applying MSVC security compiler options for OneBranch compliance")
14+
15+
add_compile_options(
16+
/GS # Buffer security check - detects buffer overruns
17+
/guard:cf # Control Flow Guard - protects against control flow hijacking
18+
)
19+
20+
add_link_options(
21+
/DYNAMICBASE # ASLR - Address Space Layout Randomization
22+
/NXCOMPAT # DEP - Data Execution Prevention
23+
/GUARD:CF # Control Flow Guard (linker)
24+
)
25+
26+
# SAFESEH only for x86 (32-bit) builds
27+
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # 32-bit
28+
message(STATUS "Applying /SAFESEH for 32-bit build")
29+
add_link_options(/SAFESEH) # Safe Structured Exception Handling
30+
else()
31+
message(STATUS "Skipping /SAFESEH (not applicable for 64-bit builds)")
32+
endif()
33+
934
# Enable PDB generation for all target types
1035
add_compile_options("$<$<CONFIG:Release>:/Zi>")
1136
add_link_options("$<$<CONFIG:Release>:/DEBUG /OPT:REF /OPT:ICF>")
37+
38+
message(STATUS "Security flags applied: /GS /guard:cf /DYNAMICBASE /NXCOMPAT /GUARD:CF")
1239
endif()
1340

1441
# Detect platform

0 commit comments

Comments
 (0)