From 84ed36224f3b71e389860bbbf58357bebec4b1b2 Mon Sep 17 00:00:00 2001
From: Roman Tsisyk <roman@tsisyk.com>
Date: Sun, 7 Feb 2016 20:08:53 +0300
Subject: [PATCH] CMake: fix order of ENABLE_BACKTRACE and compiler.cmake

---
 CMakeLists.txt       | 22 ----------------------
 cmake/compiler.cmake | 25 +++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 990588dbbf..72b79bbd8b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -256,28 +256,6 @@ option(ENABLE_DOC "Enable building of documentation" OFF)
 option(ENABLE_TRACE "Enable debug trace of tarantool_box execution to
 a file specified in TARANTOOL_TRACE environment variable" ON)
 
-option(ENABLE_BACKTRACE "Enable output of fiber backtrace information in 'show
-fiber' administrative command. Only works on x86 architectures, if compiled
-with gcc. If GNU binutils and binutils-dev libraries are installed, backtrace
-is output with resolved function (symbol) names. Otherwise only frame
-addresses are printed." ${CMAKE_COMPILER_IS_GNUCC})
-
-set (HAVE_BFD False)
-if (ENABLE_BACKTRACE)
-    if (NOT ${CMAKE_COMPILER_IS_GNUCC})
-        # We only know this option to work with gcc
-        message (FATAL_ERROR "ENABLE_BACKTRACE option is set but the system is not x86 based (${CMAKE_SYSTEM_PROCESSOR}) or the compiler is not GNU GCC (${CMAKE_C_COMPILER}).")
-    endif()
-    # Use GNU bfd if present.
-    check_library_exists (bfd bfd_init ""  HAVE_BFD_LIB)
-    check_library_exists (iberty cplus_demangle "" HAVE_IBERTY_LIB)
-    set(CMAKE_REQUIRED_DEFINITIONS -DPACKAGE=${PACKAGE} -DPACKAGE_VERSION=${PACKAGE_VERSION})
-    check_include_file(bfd.h HAVE_BFD_H)
-    set(CMAKE_REQUIRED_DEFINITIONS)
-    if (HAVE_BFD_LIB AND HAVE_BFD_H AND HAVE_IBERTY_LIB)
-        set (HAVE_BFD True)
-    endif()
-endif()
 
 ##
 ## Third-Party libraries
diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
index e0a44381a4..bf848b712b 100644
--- a/cmake/compiler.cmake
+++ b/cmake/compiler.cmake
@@ -100,6 +100,31 @@ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO
 
 unset(CC_DEBUG_OPT)
 
+option(ENABLE_BACKTRACE "Enable output of fiber backtrace information in 'show
+fiber' administrative command. Only works on x86 architectures, if compiled
+with gcc. If GNU binutils and binutils-dev libraries are installed, backtrace
+is output with resolved function (symbol) names. Otherwise only frame
+addresses are printed." ${CMAKE_COMPILER_IS_GNUCC})
+
+set (HAVE_BFD False)
+if (ENABLE_BACKTRACE)
+    if (NOT ${CMAKE_COMPILER_IS_GNUCC})
+        # We only know this option to work with gcc
+        message (FATAL_ERROR "ENABLE_BACKTRACE option is set but the system
+                is not x86 based (${CMAKE_SYSTEM_PROCESSOR}) or the compiler
+                is not GNU GCC (${CMAKE_C_COMPILER}).")
+    endif()
+    # Use GNU bfd if present.
+    check_library_exists (bfd bfd_init ""  HAVE_BFD_LIB)
+    check_library_exists (iberty cplus_demangle "" HAVE_IBERTY_LIB)
+    set(CMAKE_REQUIRED_DEFINITIONS -DPACKAGE=${PACKAGE} -DPACKAGE_VERSION=${PACKAGE_VERSION})
+    check_include_file(bfd.h HAVE_BFD_H)
+    set(CMAKE_REQUIRED_DEFINITIONS)
+    if (HAVE_BFD_LIB AND HAVE_BFD_H AND HAVE_IBERTY_LIB)
+        set (HAVE_BFD True)
+    endif()
+endif()
+
 #
 # Set flags for all include files: those maintained by us and
 # coming from third parties.
-- 
GitLab