-1

add_custom_command の使用法を理解しようとしています。次のような最小限のメイク ファイル (CMakeLists.txt) を作成しました。

$cmake.

$makeperfecthash.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 .

$make

以下のエラーを与える

-- 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
4

1 に答える 1

0

ただのタイプミス:
gperf_generate_new(command_options.new.gperf pefecthash .hpp)
...
DEPENDS perfecthash .hpp

于 2015-10-13T20:43:34.813 に答える