add_custom_command 不工作

add_custom_command not working

我试图了解 add_custom_command 用法,我写了一个最小的 make 文件 (CMakeLists.txt) 如下图所示 当我 运行 make 文件使用

$cmake.

$制作 我没有看到 perfecthash.cpp 正在创建并且构建中断

cmake_minimum_required(VERSION 2.8)
# Call add_custom_command() with appropriate arguments for generate output file
# Note, that *gperf* will work in the build tree,
# so for file in the source tree full path should be used.
function(gperf_generate_new input output)
    MESSAGE("debugging function")
    add_custom_command(
        OUTPUT ${output}
        COMMAND gperf -L c++ ${input} > ${output}
        DEPENDS ${input}
        COMMENT "printing ${output}" # Just for nice message during build
    )
endfunction()

# Generate *example.hpp* file ...
gperf_generate_new(command_options.new.gperf pefecthash.hpp)

# ... for use it in executable
add_custom_target(my_target
    ALL # Force target to be built with default build target.
    DEPENDS perfecthash.hpp

)

$cmake.

$制作

给出以下错误

-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- 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
-- 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
debugging function
-- Configuring done
-- Generating done
-- Build files have been written to: /home/srinivas
Scanning dependencies of target my_target
make[2]: *** No rule to make target `perfecthash.hpp', needed by `CMakeFiles/my_target'.  Stop.
make[1]: *** [CMakeFiles/my_target.dir/all] Error 2
make: *** [all] Error 2

只是一个错字:
gperf_generate_new(command_options.new.gperf pefecthash.hpp)
...
取决于 perfecthash.hpp