我非常新的CMake和這裏的文件是在我的項目的根目錄我的CMakeLists.txt文件如何指定依賴於其他文件
cmake_minimum_required (VERSION 2.6)
project (Tools C)
set(CMAKE_C_FLAGS "-ansi -pedantic -Wall -Werror")
include_directories("include")
SET_SOURCE_FILES_PROPERTIES(lib/xstr.c PROPERTIES
OBJECT_DEPENDS "lib/xalloc.c")
SET_SOURCE_FILES_PROPERTIES(lib/counter.c PROPERTIES
OBJECT_DEPENDS "lib/xstr.c")
SET_SOURCE_FILES_PROPERTIES(lib/dynamic_array.c PROPERTIES
OBJECT_DEPENDS "lib/xalloc.c")
SET_SOURCE_FILES_PROPERTIES(lib/list.c PROPERTIES
OBJECT_DEPENDS "lib/xalloc.c")
add_executable(cat cat.c lib/xalloc.c lib/xfopen.c)
add_executable(counter counter.c lib/counter.c)
add_executable(darr dynamic_array.c lib/dynamic_array.c)
add_executable(linked list.c lib/list.c)
我把C文件包含在我的根main()
功能目錄。我將其他c文件保存在{project_root}/lib
目錄中。
我的問題是,我收到以下錯誤:
[ 33%] Built target cat
mingw32-make.exe[2]: *** No rule to make target 'lib/xstr.c', needed by 'CMakeFi
les/counter.dir/lib/counter.c.obj'. Stop.
CMakeFiles\Makefile2:94: recipe for target 'CMakeFiles/counter.dir/all' failed
mingw32-make.exe[1]: *** [CMakeFiles/counter.dir/all] Error 2
Makefile:75: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2
我想實現的是與{project_root}/lib/xstr.c
和{project_root}/lib/xalloc.c
鏈接{project_root}/cat.c
等
我怎樣才能做到這一點?
嗨,你有沒有關於我的回答任何反饋? – Antonio 2015-04-07 07:37:52