我正在尝试使用Mac上的cmake编译opencv项目。当我尝试编译时,我遇到了这个错误:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:301:10: fatal error: 'math.h' file not found
告诉我math.h没找到。该库肯定存在,因为当我编译没有cmake时,它工作正常。
的CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project( Optimotive )
find_package( OpenCV )
file(GLOB_RECURSE Optimotive_SOURCES "../Optimotive/*.cpp")
file(GLOB_RECURSE Optimotive_HEADERS "../Optimotive/*.h")
set(Optimotive_INCLUDE_DIRS "")
foreach(_headerFile ${Optimotive_HEADERS})
get_filename_component(_dir ${_headerFile} PATH)
list(APPEND Optimotive_INCLUDE_DIRS ${_dir})
endforeach()
list(REMOVE_DUPLICATES Optimotive_INCLUDE_DIRS)
include_directories(${Optimotive_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
add_executable(Optimotive ${Optimotive_SOURCES})
target_link_libraries(Optimotive ${OpenCV_LIBS})