CMake忽略路径集

时间:2020-05-15 19:25:10

标签: cmake

当我运行cmake时,它告诉我它正在使用opencv 4.1.0版本。

(base) haziq@cheemc52:~/hope/build$ cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at CMakeLists.txt:27 (find_package):
  Ignoring EXACT since no version is requested.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found OpenCV: /usr (found version "4.1.0")
--     version: 4.1.0
-- OPENCV include:   /usr/include/opencv4
-- OPENCV libs dir:
-- OPENCV libs:   opencv_calib3dopencv_coreopencv_dnnopencv_features2dopencv_flannopencv_gapiopencv_highguiopencv_imgcodecsopencv_imgprocopencv_mlopencv_objdetectopencv_photoopencv_stitchingopencv_videoopencv_videoioopencv_arucoopencv_bgsegmopencv_bioinspiredopencv_ccalibopencv_datasetsopencv_dnn_objdetectopencv_dpmopencv_faceopencv_fuzzyopencv_hdfopencv_hfsopencv_img_hashopencv_line_descriptoropencv_optflowopencv_phase_unwrappingopencv_plotopencv_qualityopencv_regopencv_rgbdopencv_saliencyopencv_shapeopencv_stereoopencv_structured_lightopencv_superresopencv_surface_matchingopencv_textopencv_trackingopencv_videostabopencv_xfeatures2dopencv_ximgprocopencv_xobjdetectopencv_xphoto
-- Configuring done
-- Generating done
-- Build files have been written to: /home/haziq/hope/build

我尝试更改cmake代码,使其使用3.2,但它忽略了我的命令。您可以在下面看到我正在使用find_package( OpenCV EXACT REQUIRED PATHS /usr/include/opencv2)。我还需要设置什么才能让它听我说话?

cmake_minimum_required(VERSION 2.4)
#set(OpenCV_DIR /home/pedro/opencv-3.1.0/build)
# QT5 insert

  # Tell CMake to run moc when necessary:
  set(CMAKE_AUTOMOC ON)
  # As moc files are generated in the binary dir, tell CMake
  # to always look for includes there:
  set(CMAKE_INCLUDE_CURRENT_DIR ON)

  # Widgets finds its own dependencies (QtGui and QtCore).
  find_package(Qt5Widgets REQUIRED)

  # The Qt5Widgets_INCLUDES also includes the include directories for
  # dependencies QtCore and QtGui
  include_directories(${Qt5Widgets_INCLUDES})

  # We need add -DQT_WIDGETS_LIB when using QtWidgets in Qt 5.
  add_definitions(${Qt5Widgets_DEFINITIONS})

  # Executables fail to build with Qt 5 in the default configuration
  # without -fPIE. We add that here.
  set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

# OpenCV Config
SET(OpenCV_DIR "/home/pedro/opencv-2.4.13.6/build")
find_package( OpenCV EXACT REQUIRED PATHS /usr/include/opencv2)
set(OpenCV_FOUND 1)
message(STATUS "    version: ${OpenCV_VERSION}")
message("-- OPENCV include:   " ${OpenCV_INCLUDE_DIRS})
message("-- OPENCV libs dir:  " ${OpenCV_LIB_DIR})
message("-- OPENCV libs:   " ${OpenCV_LIBS} )

INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})
LINK_DIRECTORIES(${OpenCV_LIB_DIR})

ADD_DEFINITIONS(-DDEBUG -ggdb -O3 -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fbranch-probabilities)

if(COMMAND cmake_policy)
   cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

################################

option(WARP ON)
if(WARP)
    ADD_EXECUTABLE(
      compute_flow_si_warp
      compute_flow_si_warp.cpp
      ${SRCS}
    )

    TARGET_LINK_LIBRARIES(
      compute_flow_si_warp
      ${OPENCV_LIBRARIES}
      ${OpenCV_LIBS}
      ${Qt5Widgets_LIBRARIES}
    )
else()
    ADD_EXECUTABLE(
      compute_flow
      compute_flow.cpp
      ${SRCS}
    )

    TARGET_LINK_LIBRARIES(
      compute_flow
      ${OPENCV_LIBRARIES}
      ${OpenCV_LIBS}
      ${Qt5Widgets_LIBRARIES}
    )
endif()
################################

foreach(dir ${DIRS})
  FILE(GLOB files ${dir}/*.h*)
  LIST(APPEND h_files ${files})
endforeach(dir)
add_custom_target(TAGS etags --members -l c++ ${h_files} ${SRCS})

0 个答案:

没有答案