[arrayfire] 79/84: BUILD Adding option MIN_BUILD_TIME to CMake. Options sets O0 for fast compile

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Jan 4 23:22:29 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository arrayfire.

commit 4243ffcd2a45d74ba33d6edd4873ad2acabb2848
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date:   Wed Dec 30 11:41:29 2015 -0500

    BUILD Adding option MIN_BUILD_TIME to CMake. Options sets O0 for fast compile
    
    * Od on MSVC
    * Default is OFF. Flags are set when toggled to ON.
    * Resets the flags to default release when toggled back to OFF.
---
 CMakeLists.txt                  |  3 ++
 CMakeModules/MinBuildTime.cmake | 93 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ea92cbe..c79fbca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,6 +45,9 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
       "MinSizeRel" "RelWithDebInfo")
 endif()
 
+OPTION(MIN_BUILD_TIME "This flag compiles ArrayFire with O0, which is the fastest way to compile" OFF)
+INCLUDE(${CMAKE_MODULE_PATH}/MinBuildTime.cmake)
+
 FIND_PACKAGE(FreeImage)
 IF(FREEIMAGE_FOUND)
     ADD_DEFINITIONS(-DWITH_FREEIMAGE)
diff --git a/CMakeModules/MinBuildTime.cmake b/CMakeModules/MinBuildTime.cmake
new file mode 100644
index 0000000..dcd3d35
--- /dev/null
+++ b/CMakeModules/MinBuildTime.cmake
@@ -0,0 +1,93 @@
+IF(NOT DEFINED MINBUILDTIME_FLAG)
+    SET(MINBUILDTIME_FLAG OFF CACHE INTERNAL "Flag" FORCE)
+ENDIF()
+
+IF(${MIN_BUILD_TIME})
+    IF(NOT ${CMAKE_BUILD_TYPE} MATCHES "Release")
+        MESSAGE(WARNING "The MIN_BUILD_TIME Flag only works with Release.\
+                        Other CMAKE_BUILD_TYPEs will be ignore this flag")
+    ELSEIF(NOT ${MINBUILDTIME_FLAG})
+    # BUILD_TYPE is Release - Set the flags
+    # The flags should be set only when going from OFF -> ON. This is
+    # determined by MINBUILDTIME_FLAG
+    # IF FLAG is ON, then the flags were already set, no need to set them again
+    # IF FLAG is OFF, then the flags are not set, so set them now, and back up
+    # release flags
+    MESSAGE(STATUS "Setting Release flags to no optimizations")
+
+        # Backup Default Release Flags
+        SET(CMAKE_CXX_FLAGS_RELEASE_DEFAULT ${CMAKE_CXX_FLAGS_RELEASE} CACHE
+            INTERNAL "Default compiler flags during release build" FORCE)
+        SET(CMAKE_C_FLAGS_RELEASE_DEFAULT ${CMAKE_C_FLAGS_RELEASE} CACHE
+            INTERNAL "Default compiler flags during release build" FORCE)
+        SET(CMAKE_EXE_LINKER_FLAGS_RELEASE_DEFAULT ${CMAKE_EXE_LINKER_FLAGS_RELEASE} CACHE
+            INTERNAL "Default linker flags during release build" FORCE)
+        SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE_DEFAULT ${CMAKE_MODULE_LINKER_FLAGS_RELEASE} CACHE
+            INTERNAL "Default linker flags during release build" FORCE)
+        SET(CMAKE_STATIC_LINKER_FLAGS_RELEASE_DEFAULT ${CMAKE_STATIC_LINKER_FLAGS_RELEASE} CACHE
+            INTERNAL "Default linker flags during release build" FORCE)
+        SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE_DEFAULT ${CMAKE_SHARED_LINKER_FLAGS_RELEASE} CACHE
+            INTERNAL "Default linker flags during release build" FORCE)
+
+        IF(MSVC)
+            MESSAGE(STATUS "MSVC Flags")
+            SET(CMAKE_CXX_FLAGS_RELEASE "/MD /Od /Ob1 /D NDEBUG" CACHE
+                STRING "Flags used by the compiler during release builds." FORCE)
+            SET(CMAKE_C_FLAGS_RELEASE "/MD /Od /Ob1 /D NDEBUG" CACHE
+                STRING "Flags used by the compiler during release builds." FORCE)
+            SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO" CACHE
+                STRING "Flags used by the linker during release builds." FORCE)
+            SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO" CACHE
+                STRING "Flags used by the linker during release builds." FORCE)
+            SET(CMAKE_STATIC_LINKER_FLAGS_RELEASE "" CACHE
+                STRING "Flags used by the linker during release builds." FORCE)
+            SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO" CACHE
+                STRING "Flags used by the linker during release builds." FORCE)
+        ELSE(MSVC)
+            MESSAGE(STATUS "Other Flags")
+            SET(CMAKE_CXX_FLAGS_RELEASE "-O0 -DNDEBUG" CACHE
+                STRING "Flags used by the compiler during release builds." FORCE)
+            SET(CMAKE_C_FLAGS_RELEASE "-O0 -DNDEBUG" CACHE
+                STRING "Flags used by the compiler during release builds." FORCE)
+            SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "" CACHE
+                STRING "Flags used by the linker during release builds." FORCE)
+            SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "" CACHE
+                STRING "Flags used by the linker during release builds." FORCE)
+            SET(CMAKE_STATIC_LINKER_FLAGS_RELEASE "" CACHE
+                STRING "Flags used by the linker during release builds." FORCE)
+            SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "" CACHE
+                STRING "Flags used by the linker during release builds." FORCE)
+        ENDIF(MSVC)
+
+        SET(MINBUILDTIME_FLAG ON CACHE INTERNAL "Flag" FORCE)
+    ENDIF()
+ELSE()
+  MESSAGE(STATUS "MIN_BUILD_TIME IS OFF")
+
+    # MIN_BUILD_TIME is OFF. Change the flags back only if the flag was set before
+    IF(${MINBUILDTIME_FLAG})
+        MESSAGE(STATUS "MIN_BUILD_FLAG was toggled. Resetting Release FLags")
+        SET(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE_DEFAULT} CACHE
+            STRING "Flags used by the compiler during release builds." FORCE)
+        SET(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE_DEFAULT} CACHE
+            STRING "Flags used by the compiler during release builds." FORCE)
+        SET(CMAKE_EXE_LINKER_FLAGS_RELEASE ${CMAKE_EXE_LINKER_FLAGS_RELEASE_DEFAULT} CACHE
+            STRING "Flags used by the linker during release builds." FORCE)
+        SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE ${CMAKE_MODULE_LINKER_FLAGS_RELEASE_DEFAULT} CACHE
+            STRING "Flags used by the linker during release builds." FORCE)
+        SET(CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE_DEFAULT} CACHE
+            STRING "Flags used by the linker during release builds." FORCE)
+        SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE_DEFAULT} CACHE
+            STRING "Flags used by the linker during release builds." FORCE)
+        SET(MINBUILDTIME_FLAG OFF CACHE INTERNAL "Flag" FORCE)
+    ENDIF()
+ENDIF()
+
+MARK_AS_ADVANCED(
+    CMAKE_CXX_FLAGS_RELEASE
+    CMAKE_C_FLAGS_RELEASE
+    CMAKE_EXE_LINKER_FLAGS_RELEASE
+    CMAKE_MODULE_LINKER_FLAGS_RELEASE
+    CMAKE_STATIC_LINKER_FLAGS_RELEASE
+    CMAKE_SHARED_LINKER_FLAGS_RELEASE
+    )

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list