fix: add option for _ check, only define on pybind11

This commit is contained in:
Henry Schreiner 2022-02-04 00:23:01 -05:00
parent 666f13f061
commit 86817db488
No known key found for this signature in database
GPG Key ID: B9D0E45146A241E8
2 changed files with 6 additions and 1 deletions

View File

@ -44,7 +44,7 @@ jobs:
python: '3.6'
args: >
-DPYBIND11_FINDPYTHON=ON
-DCMAKE_CXX_FLAGS="-D_=1"
-DPYBIND11_DEFINE_UNDERSCORE=ON
- runs-on: windows-latest
python: '3.6'
args: >

View File

@ -81,6 +81,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../tools")
option(PYBIND11_WERROR "Report all warnings as errors" OFF)
option(DOWNLOAD_EIGEN "Download EIGEN (requires CMake 3.11+)" OFF)
option(PYBIND11_CUDA_TESTS "Enable building CUDA tests (requires CMake 3.12+)" OFF)
option(PYBIND11_DEFINE_UNDERSCORE "Define the underscore to make sure it is safe" OFF)
set(PYBIND11_TEST_OVERRIDE
""
CACHE STRING "Tests from ;-separated list of *.cpp files will be built instead of all tests")
@ -435,6 +437,9 @@ foreach(target ${test_targets})
# Create the binding library
pybind11_add_module(${target} THIN_LTO ${target}.cpp ${test_files} ${PYBIND11_HEADERS})
pybind11_enable_warnings(${target})
if(PYBIND11_DEFINE_UNDERSCORE)
target_compile_definitions(${target} PUBLIC -D_=1)
endif()
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
get_property(