5
我想要CMake找到add_executable的頭並找到target_link_libraries的.so文件。Cmake在/ usr/local/include中找到/ usr/local/lib中的頭文件
頭文件我想找到的是LCM-cpp.hpp(上ubunthu)
ls /usr/local/include/lcm/
eventlog.h lcm_coretypes.h lcm-cpp.hpp lcm-cpp-impl.hpp lcm.h
在我的項目
cmake_minimum_required (VERSION 2.6)
project (libFoo)
include_directories(include /usr/local/include/lcm/)
set(PROJECT_SRC
src/Foo.cpp)
set(PROJECT_H
include/Foo.hpp)
find_library(LCM_LIBRARY
NAMES liblcm.so
PATHS
/usr/local/lib/
)
add_library(liblcm STATIC IMPORTED)
add_library(foo_lib ${PROJECT_SRC} ${PROJECT_H})
add_executable(foo_lcm src/lcm_foo.cpp ${PROJECT_H} lcm-cpp.hpp)
我得到的錯誤的根的CMakeLists.txt文件:
Cannot find source file:
lcm-cpp.hpp
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
你的問題*非常*不清楚。你能詳細說明嗎?瘋狂的猜測:你是否在尋找['include_directories'](http://cmake.org/cmake/help/v2.8.12/cmake.html#command:include_directories)並將完整路徑傳遞給'target_link_libraries'? – Angew
@Angew include_directories(include/usr/local/include)不起作用(我有一個目錄./include用於我自己的頭文件) – user1443778
請發表[SSCCE](http://sscce.org/): CMakeList&源代碼,演示這個問題,發佈你的頭文件位置和任何你得到的錯誤(編譯器錯誤,我假設)。 – Angew