Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8522471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:07:42+00:00 2026-06-11T07:07:42+00:00

Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library

  • 0

Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library is available (it is available only in quite recent version of the library). If it is, I will use it in my code, if it is not, I redefine it in my code, in btw #ifdefs.

Here is a snippet of my CMakeLists.txt:

FIND_PACKAGE(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
set(CMAKE_REQUIRED_INCLUDES ${OpenCV_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${OpenCV_LIBS})
INCLUDE(CheckCXXSourceCompiles) 
CHECK_CXX_SOURCE_COMPILES(
"
#include <opencv2/imgproc/imgproc.hpp>
int
main()
{
cv::Mat toto = cv::getGaborKernel(cv::Size(11,11), 1,0,3,1,0, CV_64F);
}
" HAVE_OPENCV_GABOR)
if(HAVE_OPENCV_GABOR)
message("Using OpenCV Gabor implementation")
else(HAVE_OPENCV_GABOR)
message("Using custom Gabor implementation")
endif(HAVE_OPENCV_GABOR)

When deploying on a computer with recent OpenCV version (which does have cv::getGaborKernel), the test fails, forcing the redefinition of the function and some compilation errors.
The problem reside in the fact that OpenCV not beeing installed in standard directory, it first fails to locate the library. So the sample program cannot be built. However, after I properly set up OpenCV dependencies, the test for HAVE_OPENCV_GABOR is not run again as the failure is registered in the cache.
How can I force CMake to rerun the test in that case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:07:43+00:00Added an answer on June 11, 2026 at 7:07 am

    Just wrap your CHECK_CXX_SOURCE_COMPILES() call with

    if(NOT OpenCV_INCLUDE_DIRS OR NOT OpenCV_LIBS)
    ...
    endif()
    

    Another solution – add unset(HAVE_OPENCV_GABOR CACHE) before running CHECK_CXX_SOURCE_COMPILES().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run code which needs boost libraries. I built it using CMake.
I have project in which I want to use check library for unit testing.
I want to set up automated build using CMake on Windows. I am using
I am using CMake 2.8 under Windows XP and want to generate a Visual
I am using CMake to generate Visual Studio project files. I want to run
I have a C++ library that is using cmake. The structure of my library
I've been using CMake for quite some time to generate VS 2008 solutions to
I want to install open cv library and i am using Dev c++ compiler.
I downloaded cpptest from internet, and I want to build it using Visual Studio
I'm using cmake with C++ project. I want to use precompiled headers in GCC.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.