cmake: add asn1 target, avoid unnecessary rebuilds

Add an "asn1" build target that rebuilds all ASN.1 dissectors.

Do not always generate the ASN.1 dissector when invoking the
"generate_dissector-PROTO" target. Use a special "packet-PROTO-stamp"
file to detect whether the dissector is out of date.

This indirection is needed because cmake removes output files from
add_custom_command in the clean target, but we would like to keep the
generated packet-PROTO.c files.

Make all EXTRA_CNF and EXPORT_DEPENDS point to absolute paths for
generated exported configs (PROTO-exp.cnf). This is done by automake too
and is needed for proper dependency tracking. Example: when h225.cnf is
updated, h225-exp.cnf needs to be generated. That is the purpose of the
"generate-h225-exp.cnf" target. Now h235 (and other) dissectors need to
be regenerated as well because the h225-exp.cnf is updated. This is why
there is a separate add_custom_command and add_custom_target.

Change-Id: I8cfc1f8f43cea595267b21eae30b4548f3407c0b
Reviewed-on: https://code.wireshark.org/review/12080
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Peter Wu 2015-11-24 23:18:44 +01:00 committed by Anders Broman
parent edb3388303
commit a198f47c06
47 changed files with 192 additions and 157 deletions

1
.gitignore vendored
View File

@ -131,6 +131,7 @@ build.ninja
rules.ninja
.ninja_deps
.ninja_log
asn1/*/*-stamp
# Generated dir #

View File

@ -130,7 +130,11 @@ set( BROKEN_ASN1_SRC_DIRS
x721
)
set(_asn1_deps)
foreach(ASN1_DIR ${ASN1_SRC_DIRS})
add_subdirectory( ${ASN1_DIR} )
list(APPEND _asn1_deps ${ASN1_DIR}/generate_dissector-${ASN1_DIR})
endforeach()
# Target to regenerate all outdated ASN.1 dissectors
add_custom_target(asn1 DEPENDS ${_asn1_deps})

View File

@ -46,11 +46,11 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
p1-exp.cnf
x509af-exp.cnf
x509ce-exp.cnf
x509if-exp.cnf
x509sat-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../p1/p1-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509ce/x509ce-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509sat/x509sat-exp.cnf"
)
ASN2WRS()

View File

@ -49,7 +49,7 @@ set( SRC_FILES
set( A2W_FLAGS -b -C )
set( EXTRA_CNF
x509if-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
)
ASN2WRS()

View File

@ -40,7 +40,7 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
gsm_map-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../gsm_map/gsm_map-exp.cnf"
)
ASN2WRS()

View File

@ -63,8 +63,8 @@ set( SRC_FILES
set( A2W_FLAGS -b -L )
set( EXTRA_CNF
inap-exp.cnf
gsm_map-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../inap/inap-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../gsm_map/gsm_map-exp.cnf"
)
ASN2WRS()

View File

@ -54,7 +54,7 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
acse-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../acse/acse-exp.cnf"
)
ASN2WRS()

View File

@ -47,7 +47,7 @@ set( A2W_FLAGS -b )
set( EXTRA_CNF
../pkix1explicit/pkix1explicit_exp.cnf
../pkix1implicit/pkix1implicit_exp.cnf
crmf-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../crmf/crmf-exp.cnf"
)
ASN2WRS()

View File

@ -50,14 +50,14 @@ set( SRC_FILES
set( A2W_FLAGS -b -C )
set( EXTRA_CNF
x509af-exp.cnf
x509ce-exp.cnf
x509if-exp.cnf
x509sat-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509ce/x509ce-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509sat/x509sat-exp.cnf"
)
set ( EXPORT_DEPENDS
x509af-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
)
ASN2WRS()

View File

@ -49,7 +49,7 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
cms-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../cms/cms-exp.cnf"
)
ASN2WRS()

View File

@ -50,15 +50,15 @@ set( SRC_FILES
set( A2W_FLAGS -b -L )
set( EXTRA_CNF
acse-exp.cnf
dop-exp.cnf
disp-exp.cnf
dsp-exp.cnf
crmf-exp.cnf
ros-exp.cnf
x509af-exp.cnf
x509if-exp.cnf
x509sat-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../acse/acse-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../dop/dop-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../disp/disp-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../dsp/dsp-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../crmf/crmf-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../ros/ros-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509sat/x509sat-exp.cnf"
)
ASN2WRS()

View File

@ -49,15 +49,15 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
dap-exp.cnf
dop-exp.cnf
dsp-exp.cnf
x509af-exp.cnf
x509if-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../dap/dap-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../dop/dop-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../dsp/dsp-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
)
set( EXPORT_DEPENDS
dop-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../dop/dop-exp.cnf"
)
ASN2WRS()

View File

@ -49,12 +49,12 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
dap-exp.cnf
dsp-exp.cnf
crmf-exp.cnf
x509af-exp.cnf
x509if-exp.cnf
x509sat-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../dap/dap-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../dsp/dsp-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../crmf/crmf-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509sat/x509sat-exp.cnf"
)
ASN2WRS()

View File

@ -49,10 +49,10 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
dap-exp.cnf
x509af-exp.cnf
x509if-exp.cnf
x509sat-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../dap/dap-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509sat/x509sat-exp.cnf"
)
ASN2WRS()

View File

@ -45,9 +45,9 @@ set( SRC_FILES
set( A2W_FLAGS -b -k -C )
set( EXTRA_CNF
cms-exp.cnf
x509af-exp.cnf
x509ce-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../cms/cms-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509ce/x509ce-exp.cnf"
)
ASN2WRS()

View File

@ -49,7 +49,7 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
acse-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../acse/acse-exp.cnf"
)
ASN2WRS()

View File

@ -51,7 +51,7 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
gsm_map-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../gsm_map/gsm_map-exp.cnf"
)
ASN2WRS()

View File

@ -49,8 +49,8 @@ set( SRC_FILES
set( A2W_FLAGS )
set( EXTRA_CNF
h235-exp.cnf
h245-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../h235/h235-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../h245/h245-exp.cnf"
)
ASN2WRS()

View File

@ -50,7 +50,7 @@ set( SRC_FILES
set( A2W_FLAGS )
set( EXTRA_CNF
h225-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../h225/h225-exp.cnf"
)
ASN2WRS()

View File

@ -46,7 +46,7 @@ set( SRC_FILES
set( A2W_FLAGS )
set( EXTRA_CNF
h225-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../h225/h225-exp.cnf"
)
ASN2WRS()

View File

@ -67,8 +67,8 @@ set( SRC_FILES
set( A2W_FLAGS )
set( EXTRA_CNF
h225-exp.cnf
h450-ros-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../h225/h225-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../h450-ros/h450-ros-exp.cnf"
)
ASN2WRS()

View File

@ -54,9 +54,9 @@ set( SRC_FILES
set( A2W_FLAGS )
set( EXTRA_CNF
h225-exp.cnf
h235-exp.cnf
h245-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../h225/h225-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../h235/h235-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../h245/h245-exp.cnf"
)
ASN2WRS()

View File

@ -44,8 +44,8 @@ set( SRC_FILES
set( A2W_FLAGS )
set( EXTRA_CNF
h225-exp.cnf
h235-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../h225/h225-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../h235/h235-exp.cnf"
)
ASN2WRS()

View File

@ -50,8 +50,8 @@ set( SRC_FILES
set( A2W_FLAGS -b -L )
set( EXTRA_CNF
x509af-exp.cnf
x509ce-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509ce/x509ce-exp.cnf"
)
ASN2WRS()

View File

@ -78,8 +78,8 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
dap-exp.cnf
dsp-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../dap/dap-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../dsp/dsp-exp.cnf"
)
ASN2WRS()

View File

@ -54,7 +54,7 @@ set( SRC_FILES
set( A2W_FLAGS )
set( EXTRA_CNF
x509if-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
)
ASN2WRS()

View File

@ -45,7 +45,7 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
x509af-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
)
ASN2WRS()

View File

@ -44,7 +44,7 @@ set( SRC_FILES
set( A2W_FLAGS )
set( EXTRA_CNF
lpp-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../lpp/lpp-exp.cnf"
)
ASN2WRS()

View File

@ -45,7 +45,7 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
acse-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../acse/acse-exp.cnf"
)
ASN2WRS()

View File

@ -45,8 +45,8 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
x509af-exp.cnf
x509ce-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509ce/x509ce-exp.cnf"
)
ASN2WRS()

View File

@ -53,16 +53,16 @@ set( SRC_FILES
set( A2W_FLAGS -b -C )
set( EXTRA_CNF
x509af-exp.cnf
x509ce-exp.cnf
x509if-exp.cnf
x509sat-exp.cnf
ros-exp.cnf
rtse-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509ce/x509ce-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509sat/x509sat-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../ros/ros-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../rtse/rtse-exp.cnf"
)
set ( EXPORT_DEPENDS
x509af-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
)
ASN2WRS()

View File

@ -58,16 +58,16 @@ set( SRC_FILES
set( A2W_FLAGS -b -C )
set( EXTRA_CNF
acse-exp.cnf
ftam-exp.cnf
p7-exp.cnf
p1-exp.cnf
x509af-exp.cnf
x509ce-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../acse/acse-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../ftam/ftam-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../p7/p7-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../p1/p1-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509ce/x509ce-exp.cnf"
)
set( EXPORT_DEPENDS
p1-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../p1/p1-exp.cnf"
)
ASN2WRS()

View File

@ -52,13 +52,13 @@ set( SRC_FILES
set( A2W_FLAGS -b -L -C )
set( EXTRA_CNF
p1-exp.cnf
ros-exp.cnf
rtse-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../p1/p1-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../ros/ros-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../rtse/rtse-exp.cnf"
)
set( EXPORT_DEPENDS
p1-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../p1/p1-exp.cnf"
)
ASN2WRS()

View File

@ -52,8 +52,8 @@ set( SRC_FILES
set( A2W_FLAGS -b -C )
set( EXTRA_CNF
p1-exp.cnf
p22-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../p1/p1-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../p22/p22-exp.cnf"
)
ASN2WRS()

View File

@ -45,7 +45,7 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
x509af-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
)
ASN2WRS()

View File

@ -45,9 +45,9 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
x509if-exp.cnf
x509af-exp.cnf
cms-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../cms/cms-exp.cnf"
)
ASN2WRS()

View File

@ -45,7 +45,7 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
cms-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../cms/cms-exp.cnf"
)
ASN2WRS()

View File

@ -45,8 +45,8 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
x509af-exp.cnf
x509ce-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509ce/x509ce-exp.cnf"
)
ASN2WRS()

View File

@ -47,8 +47,8 @@ set( A2W_FLAGS -b )
set( EXTRA_CNF
../pkix1explicit/pkix1explicit_exp.cnf
../pkix1implicit/pkix1implicit_exp.cnf
x509af-exp.cnf
x509ce-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509ce/x509ce-exp.cnf"
)
ASN2WRS()

View File

@ -45,9 +45,9 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
x509af-exp.cnf
x509ce-exp.cnf
x509sat-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509ce/x509ce-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509sat/x509sat-exp.cnf"
)
ASN2WRS()

View File

@ -45,7 +45,7 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
cms-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../cms/cms-exp.cnf"
)
ASN2WRS()

View File

@ -46,7 +46,7 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
rtse-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../rtse/rtse-exp.cnf"
)
ASN2WRS()

View File

@ -49,9 +49,9 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
x509ce-exp.cnf
x509if-exp.cnf
x509sat-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509ce/x509ce-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509sat/x509sat-exp.cnf"
)
ASN2WRS()

View File

@ -50,14 +50,14 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
p1-exp.cnf
x509af-exp.cnf
x509if-exp.cnf
x509sat-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../p1/p1-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../x509sat/x509sat-exp.cnf"
)
set( EXPORT_DEPENDS
x509af-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509af/x509af-exp.cnf"
)
ASN2WRS()

View File

@ -50,7 +50,7 @@ set( SRC_FILES
set( A2W_FLAGS -b )
set( EXTRA_CNF
x509sat-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509sat/x509sat-exp.cnf"
)
ASN2WRS()

View File

@ -49,8 +49,8 @@ set( SRC_FILES
set( A2W_FLAGS -b -r Syntax )
set( EXTRA_CNF
x509if-exp.cnf
p1-exp.cnf
"${CMAKE_CURRENT_BINARY_DIR}/../x509if/x509if-exp.cnf"
"${CMAKE_CURRENT_BINARY_DIR}/../p1/p1-exp.cnf"
)
ASN2WRS()

View File

@ -1,58 +1,88 @@
# - Convert ASN.1 file into C source and header files that can be used to create a wireshark dissector
#
# A2W_OUTPUT_DIR - directory where the generated packet-${PROTOCOL_NAME}.c is
# saved. The default location is meant for the Wireshark
# source tree. For external dissectors, set it to the
# absolute path (e.g. "${CMAKE_CURRENT_SOURCE_DIR}").
MACRO(ASN2WRS)
function(ASN2WRS)
include(LocatePythonModule)
locate_python_module(asn2wrs REQUIRED PATHS ${CMAKE_SOURCE_DIR}/tools)
locate_python_module(asn2wrs REQUIRED PATHS "${CMAKE_SOURCE_DIR}/tools")
set( DISSECTOR ${CMAKE_SOURCE_DIR}/epan/dissectors/packet-${PROTOCOL_NAME}.c )
if ( NOT PROTO_OPT )
set( PROTO_OPT -p ${PROTOCOL_NAME} )
elseif ( PROTO_OPT STREQUAL "_EMPTY_" )
set( PROTO_OPT )
if(NOT PROTO_OPT)
set(PROTO_OPT -p ${PROTOCOL_NAME})
elseif(PROTO_OPT STREQUAL "_EMPTY_")
set(PROTO_OPT)
endif()
# Backwards compability for build in dissectors,
# set to '_EMPTY_' for out of source dissector builds
if ( NOT A2W_OUTPUT_DIR )
set (A2W_OUTPUT_DIR -O ${CMAKE_SOURCE_DIR}/epan/dissectors)
elseif ( A2W_OUTPUT_DIR STREQUAL "_EMPTY_" )
set( A2W_OUTPUT_DIR )
if(NOT A2W_OUTPUT_DIR)
set(A2W_OUTPUT_DIR "${CMAKE_SOURCE_DIR}/epan/dissectors")
endif()
# Don't use packet-${PROTOCOL_NAME}.c instead of generate_dissector, it will
# cause EXCLUDE_FROM_ALL to be ignored.
ADD_CUSTOM_TARGET(generate_dissector-${PROTOCOL_NAME} ALL
COMMAND ${PYTHON_EXECUTABLE}
${PY_ASN2WRS}
${A2W_FLAGS}
${PROTO_OPT}
-c ${CMAKE_CURRENT_SOURCE_DIR}/${PROTOCOL_NAME}.cnf
-s ${CMAKE_CURRENT_SOURCE_DIR}/packet-${PROTOCOL_NAME}-template
-D ${CMAKE_CURRENT_SOURCE_DIR}
${A2W_OUTPUT_DIR}
${EXT_ASN_FILE_LIST} ${ASN_FILE_LIST} ${EXT_ASN_FILE_LIST_LATE}
set(DISSECTOR "${A2W_OUTPUT_DIR}/packet-${PROTOCOL_NAME}.c")
# Besides the file dependency (for timestamp comparison), add a target such
# that other directories can request it to be built (ordering dependency).
foreach(_v EXTRA_CNF EXPORT_DEPENDS)
set(${_v}_targets)
foreach(entry IN LISTS ${_v})
string(REGEX MATCH "[^/]+-exp\\.cnf$" _exp_cnf_filename "${entry}")
if(_exp_cnf_filename)
list(APPEND ${_v}_targets generate-${_exp_cnf_filename})
endif()
endforeach()
endforeach()
# Creates a dissector in the source directory and store the timestamp.
add_custom_command(
OUTPUT packet-${PROTOCOL_NAME}-stamp
COMMAND "${PYTHON_EXECUTABLE}"
${PY_ASN2WRS}
${A2W_FLAGS}
${PROTO_OPT}
-c "${CMAKE_CURRENT_SOURCE_DIR}/${PROTOCOL_NAME}.cnf"
-s "${CMAKE_CURRENT_SOURCE_DIR}/packet-${PROTOCOL_NAME}-template"
-D "${CMAKE_CURRENT_SOURCE_DIR}"
-O "${A2W_OUTPUT_DIR}"
${EXT_ASN_FILE_LIST} ${ASN_FILE_LIST} ${EXT_ASN_FILE_LIST_LATE}
COMMAND
"${PYTHON_EXECUTABLE}" -c
"import shutil, sys; x,s,d=sys.argv; open(d, 'w'); shutil.copystat(s, d)"
"${A2W_OUTPUT_DIR}/packet-${PROTOCOL_NAME}.c"
packet-${PROTOCOL_NAME}-stamp
DEPENDS
${PY_ASN2WRS}
${SRC_FILES}
${EXTRA_CNF}
"${PY_ASN2WRS}"
${SRC_FILES}
${EXTRA_CNF_targets}
${EXTRA_CNF}
VERBATIM
)
foreach( _asn2wrs_export_file IN LISTS EXPORT_FILES )
ADD_CUSTOM_TARGET( ${_asn2wrs_export_file}
WORKING_DIRECTORY .
COMMAND ${PYTHON_EXECUTABLE}
${PY_ASN2WRS}
-E
${A2W_FLAGS}
${PROTO_OPT}
-c ${CMAKE_CURRENT_SOURCE_DIR}/${PROTOCOL_NAME}.cnf
-D ${CMAKE_CURRENT_SOURCE_DIR}
${EXT_ASN_FILE_LIST} ${ASN_FILE_LIST} ${EXT_ASN_FILE_LIST_LATE}
add_custom_target(generate_dissector-${PROTOCOL_NAME} ALL
DEPENDS packet-${PROTOCOL_NAME}-stamp
)
foreach(_asn2wrs_export_file IN LISTS EXPORT_FILES)
add_custom_command(
OUTPUT ${_asn2wrs_export_file}
COMMAND "${PYTHON_EXECUTABLE}"
"${PY_ASN2WRS}"
-E
${A2W_FLAGS}
${PROTO_OPT}
-c "${CMAKE_CURRENT_SOURCE_DIR}/${PROTOCOL_NAME}.cnf"
-D "${CMAKE_CURRENT_SOURCE_DIR}"
${EXT_ASN_FILE_LIST} ${ASN_FILE_LIST} ${EXT_ASN_FILE_LIST_LATE}
DEPENDS
${PY_ASN2WRS}
${SRC_FILES}
${EXPORT_DEPENDS}
"${PY_ASN2WRS}"
${SRC_FILES}
${EXPORT_DEPENDS_targets}
${EXPORT_DEPENDS}
)
# This target enables other dissectors to trigger the -exp cnf build
add_custom_target(generate-${_asn2wrs_export_file}
DEPENDS ${_asn2wrs_export_file}
)
endforeach()
ENDMACRO()
endfunction()