Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/cunn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoumith Chintala <soumith@gmail.com>2017-01-29 23:45:55 +0300
committerGitHub <noreply@github.com>2017-01-29 23:45:55 +0300
commitfbef6e7732bfb4b449833971e3964f71c3d5a369 (patch)
treefd733b7604f50e6f483ae6f5e9167f1e50fb24c5
parent37db7b80735e0a6d74c0f7a9b6fc72b1df5ccd38 (diff)
parent6568da825ee7de0a8e80d7bb234092c39ba2bee7 (diff)
Merge pull request #431 from apaszke/asserts
Compile with asserts by default
-rw-r--r--lib/THCUNN/CMakeLists.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/THCUNN/CMakeLists.txt b/lib/THCUNN/CMakeLists.txt
index 28fa2e7..433d99d 100644
--- a/lib/THCUNN/CMakeLists.txt
+++ b/lib/THCUNN/CMakeLists.txt
@@ -1,6 +1,17 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
CMAKE_POLICY(VERSION 2.8)
+OPTION(NDEBUG "disable asserts (WARNING: this may result in silent UB e.g. with out-of-bound indices)")
+IF(NOT NDEBUG)
+ MESSAGE(STATUS "Removing -DNDEBUG from compile flags")
+ STRING(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS "" ${CMAKE_C_FLAGS})
+ STRING(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_DEBUG "" ${CMAKE_C_FLAGS_DEBUG})
+ STRING(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELEASE "" ${CMAKE_C_FLAGS_RELEASE})
+ STRING(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS "" ${CMAKE_CXX_FLAGS})
+ STRING(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_DEBUG "" ${CMAKE_CXX_FLAGS_DEBUG})
+ STRING(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELEASE "" ${CMAKE_CXX_FLAGS_RELEASE})
+ENDIF()
+
IF(NOT Torch_FOUND)
FIND_PACKAGE(Torch REQUIRED)
ENDIF()