[cmake-developers] add_custom_commad build error with ninja generator
Claus Klein
claus.klein at arcormail.de
Thu Apr 10 01:01:58 EDT 2014
Hi all,
I have problems with the following cmake build script:
find_program(CCP_EXECUTABLE cpp REQUIRED HINTS /opt/local/bin)
find_program(ASN1C_EXECUTABLE asn1c REQUIRED HINTS /opt/local/bin)
if(ASN1C_EXECUTABLE AND CCP_EXECUTABLE)
set(ASN1C_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
### collect the list of generated source
###TBD### aux_source_directory(${ASN1C_OUTPUT_DIR} ASN1_SOURCES)
### message(„${ASN1_SOURCES}“)
set(ASN1_SOURCES converter-sample.c pdu_collection.c)
### Add a target with no output so it will always be built.
add_custom_target(regen
COMMAND ${CCP_EXECUTABLE} -undef -P
-include ${CMAKE_CURRENT_SOURCE_DIR}/CertificateProfile.asn1
${CMAKE_CURRENT_SOURCE_DIR}/EncryptedBsc.asn1 >
_sample.asn1
WORKING_DIRECTORY ${ASN1C_OUTPUT_DIR}
VERBATIM)
### adding a custom command to produce an output.
add_custom_target(OUTPUT ${ASN1_SOURCES}
COMMAND ${ASN1C_EXECUTABLE} -S ${CMAKE_CURRENT_SOURCE_DIR}/../../skeletons
-pdu=all ${ASN1C_OUTPUT_DIR}/_sample.asn1
COMMAND astyle *.c *.h
DEPENDS ${ASN1C_OUTPUT_DIR}/_sample.asn1
WORKING_DIRECTORY ${ASN1C_OUTPUT_DIR}
VERBATIM)
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES ${ASN1C_OUTPUT_DIR}/_sample.asn1 ${ASN1_SOURCES})
# Tell CMake to build a library from this source files
add_library(sample-asn1 ${ASN1_SOURCES})
message ("asn1c found, use target regen to generate code again")
endif()
My intention is to create a dependency tree from the library to the asn1 file.
The source file list should be dynamic because it will be changed when the asn1 specification is changed.
The OUTPUT parameter is generated to illegal shell syntax.
I would expect that the library is rebuild after build target ‚regen'.
This is not the case, so I manually start the build the target ‚OUTPUT’.
But than I get the following error while build:
Claus-MacBook-Pro:build clausklein$ ninja OUTPUT
[1/1] cd /Users/clausklein/Workspace/c/asn1c/examples/Certificate/buil.../c/asn1c/examples/Certificate/build/_sample.asn1 && astyle "*.c" "*.h
FAILED: cd /Users/clausklein/Workspace/c/asn1c/examples/Certificate/build && converter-sample.c pdu_collection.c && /opt/local/bin/asn1c -S /Users/clausklein/Workspace/c/asn1c/examples/Certificate/../../skeletons -pdu=all /Users/clausklein/Workspace/c/asn1c/examples/Certificate/build/_sample.asn1 && astyle "*.c" "*.h"
/bin/sh: converter-sample.c: command not found
ninja: build stopped: subcommand failed.
Claus-MacBook-Pro:build clausklein$
too find the target name „OUTPUT“ strange:
Claus-MacBook-Pro:build clausklein$ ninja help
[1/1] All primary targets available:
OUTPUT: phony
edit_cache: phony
install: phony
install/local: phony
install/strip: phony
list_install_components: phony
rebuild_cache: phony
regen: phony
converter-sample: phony
libsample-asn1.a: phony
sample: phony
sample-asn1: phony
build.ninja: RERUN_CMAKE
clean: CLEAN
help: HELP
Claus-MacBook-Pro:build clausklein$
/usr/bin/cmake --version
cmake version 3.0.0-rc3
Any help would be welcome
Claus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20140410/18cf3cef/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20140410/18cf3cef/attachment.sig>
More information about the cmake-developers
mailing list