0
我得到了一個基於C的主項目,我需要包含一個CPP功能(使用OpenCV)。 我正在使用Cmake文件來這樣做,但是當我添加cpp文件時,這不起作用。混合CPP OpenCV /主程序C
這裏我的Makefile
cmake_minimum_required (VERSION 2.8.9)
project(tictactoe)
### Requierements
find_package(OpenCV REQUIRED)
include_directories(../Sources)
include_directories(${OpenCV_INCLUDE_DIRS})
include(CheckIncludeFiles)
include(CheckIncludeFileCXX)
### Subdirectories where the sources are
FILE(GLOB MyCSources "../Sources/*.c")
ADD_LIBRARY(detect_tag ../Sources/detect_tag.cpp ../Sources/detect_tag.hpp)
ADD_EXECUTABLE(tictactoe ${MyCSources} ../Sources/detect_tag.cpp ../Sources/detect_tag.hpp)
TARGET_LINK_LIBRARIES(tictactoe rt ${CMAKE_THREAD_LIBS_INIT} ${OpenCV_LIBS})
不是你的主要問題,但我很確定'* .hpp'文件不需要在源文件中列出:它們沒有被編譯,如果它們沒有被包含,那麼它們就不會被使用。 ..所以cmake不需要知道他們。 – dave 2014-11-23 21:36:58