From 44098b2fbb95c4fe9889adee0e402816328ca7a1 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 17 Apr 2012 11:45:24 +0000 Subject: [PATCH] #1813 fixed compiler options with profiling enabled --- android/android.toolchain.cmake | 2 +- cmake/OpenCVCompilerOptions.cmake | 5 +++++ cmake/OpenCVIOLibs.cmake | 8 +++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/android/android.toolchain.cmake b/android/android.toolchain.cmake index d171f3c808..a469715acd 100644 --- a/android/android.toolchain.cmake +++ b/android/android.toolchain.cmake @@ -1056,6 +1056,7 @@ endif() # ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a" or "x86" depending on ANDROID_ABI # ANDROID_ARCH_NAME : "arm" or "x86" depending on ANDROID_ABI # TOOL_OS_SUFFIX : "" or ".exe" depending on host platform +# ANDROID_SYSROOT : path to the compiler sysroot # ANDROID_SYSTEM_INCLUDE_DIRS # ANDROID_SYSTEM_LIB_DIRS # Obsolete: @@ -1065,7 +1066,6 @@ endif() # ANDROID_COMPILER_VERSION : GCC version used # ANDROID_CXX_FLAGS : C/C++ compiler flags required by Android platform # ANDROID_SUPPORTED_ABIS : list of currently allowed values for ANDROID_ABI -# ANDROID_SYSROOT : path to the compiler sysroot # ANDROID_TOOLCHAIN_NAME : "standalone", "arm-linux-androideabi-4.4.3" or "x86-4.4.3" or something similar. # ANDROID_TOOLCHAIN_MACHINE_NAME : "arm-linux-androideabi", "arm-eabi" or "i686-android-linux" # ANDROID_TOOLCHAIN_ROOT : path to the top level of toolchain (standalone or placed inside NDK) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index 8f8bdc75f3..45e5b236eb 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -116,6 +116,11 @@ if(CMAKE_COMPILER_IS_GNUCXX) # Profiling? if(ENABLE_PROFILING) set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -pg -g") + # turn off incompatible options + foreach(flags CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG OPENCV_EXTRA_C_FLAGS_RELEASE) + string(REPLACE "-fomit-frame-pointer" "" ${flags} "${${flags}}") + string(REPLACE "-ffunction-sections" "" ${flags} "${${flags}}") + endforeach() elseif(NOT APPLE AND NOT ANDROID) # Remove unreferenced functions: function level linking set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -ffunction-sections") diff --git a/cmake/OpenCVIOLibs.cmake b/cmake/OpenCVIOLibs.cmake index 5788ecf23f..223b0c6c00 100644 --- a/cmake/OpenCVIOLibs.cmake +++ b/cmake/OpenCVIOLibs.cmake @@ -9,9 +9,15 @@ if(BUILD_ZLIB) unset_all(ZLIB_FOUND) else() include(FindZLIB) - if(NOT ZLIB_VERSION_STRING) + if(ZLIB_FOUND AND NOT ZLIB_VERSION_STRING) ocv_parse_header2(ZLIB "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_VERSION "") endif() + if(ZLIB_FOUND AND ANDROID) + if(ZLIB_LIBRARY STREQUAL "${ANDROID_SYSROOT}/usr/lib/libz.so") + set(ZLIB_LIBRARY z) + set(ZLIB_LIBRARIES z) + endif() + endif() endif() if(NOT ZLIB_FOUND)