Skip to content

Commit fa18ce4

Browse files
authored
Add TORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR environment variable to disable Werror
1 parent 0673a4a commit fa18ce4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def _build_all_extensions_with_cmake(self):
112112
torch_dir = Path(torch.utils.cmake_prefix_path) / "Torch"
113113
cmake_build_type = os.environ.get("CMAKE_BUILD_TYPE", "Release")
114114
enable_cuda = os.environ.get("ENABLE_CUDA", "")
115+
torchcodec_disable_compile_warning_as_error = os.environ.get("TORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR", "OFF")
115116
python_version = sys.version_info
116117
cmake_args = [
117118
f"-DCMAKE_INSTALL_PREFIX={self._install_prefix}",
@@ -120,6 +121,7 @@ def _build_all_extensions_with_cmake(self):
120121
f"-DCMAKE_BUILD_TYPE={cmake_build_type}",
121122
f"-DPYTHON_VERSION={python_version.major}.{python_version.minor}",
122123
f"-DENABLE_CUDA={enable_cuda}",
124+
f"-DTORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR={torchcodec_disable_compile_warning_as_error}"
123125
]
124126

125127
Path(self.build_temp).mkdir(parents=True, exist_ok=True)

src/torchcodec/_core/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ find_package(pybind11 REQUIRED)
88
find_package(Torch REQUIRED)
99
find_package(Python3 ${PYTHON_VERSION} EXACT COMPONENTS Development)
1010

11-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Werror ${TORCH_CXX_FLAGS}")
11+
if(DEFINED TORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR AND TORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR)
12+
set(TORCHCODEC_WERROR_OPTION "")
13+
else()
14+
set(TORCHCODEC_WERROR_OPTION "-Werror")
15+
endif()
16+
17+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic ${TORCHCODEC_WERROR_OPTION} ${TORCH_CXX_FLAGS}")
1218

1319
function(make_torchcodec_sublibrary
1420
library_name

0 commit comments

Comments
 (0)