Skip to content

Commit f85fcb6

Browse files
committed
fix: add option for _ check, only define on pybind11
1 parent 666f13f commit f85fcb6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
python: '3.6'
4545
args: >
4646
-DPYBIND11_FINDPYTHON=ON
47-
-DCMAKE_CXX_FLAGS="-D_=1"
47+
-DPYBIND11_DEFINE_UNDERSCORE=ON
4848
- runs-on: windows-latest
4949
python: '3.6'
5050
args: >

tests/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../tools")
8181
option(PYBIND11_WERROR "Report all warnings as errors" OFF)
8282
option(DOWNLOAD_EIGEN "Download EIGEN (requires CMake 3.11+)" OFF)
8383
option(PYBIND11_CUDA_TESTS "Enable building CUDA tests (requires CMake 3.12+)" OFF)
84+
option(PYBIND11_DEFINE_UNDERSCORE "Define the underscore to make sure it is safe" OFF)
85+
8486
set(PYBIND11_TEST_OVERRIDE
8587
""
8688
CACHE STRING "Tests from ;-separated list of *.cpp files will be built instead of all tests")
@@ -435,6 +437,9 @@ foreach(target ${test_targets})
435437
# Create the binding library
436438
pybind11_add_module(${target} THIN_LTO ${target}.cpp ${test_files} ${PYBIND11_HEADERS})
437439
pybind11_enable_warnings(${target})
440+
if(PYBIND11_DEFINE_UNDERSCORE)
441+
target_compile_definitions(-D_=1)
442+
endif()
438443

439444
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
440445
get_property(

0 commit comments

Comments
 (0)