diff --git a/cmake_targets/macros.cmake b/cmake_targets/macros.cmake index 25ba5cb2b8..eafee3a0c1 100644 --- a/cmake_targets/macros.cmake +++ b/cmake_targets/macros.cmake @@ -107,3 +107,18 @@ or directly with ") endif() endfunction() + +function(run_asn1c ASN1C_GRAMMAR ASN1C_PREFIX) + set(options "") + set(oneValueArgs COMMENT) + set(multiValueArgs OUTPUT OPTIONS) + cmake_parse_arguments(ASN1C "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + get_filename_component(GRAMMAR_FILE ${ASN1C_GRAMMAR} NAME) + set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${GRAMMAR_FILE}.log") + add_custom_command(OUTPUT ${ASN1C_OUTPUT} + COMMAND ASN1C_PREFIX=${ASN1C_PREFIX} ${ASN1C_EXEC} ${ASN1C_OPTIONS} -D ${CMAKE_CURRENT_BINARY_DIR} ${ASN1C_GRAMMAR} > ${LOGFILE} 2>&1 || cat ${LOGFILE} + DEPENDS ${ASN1C_GRAMMAR} + COMMENT "Generating ${ASN1C_COMMENT} from ${GRAMMAR_FILE}" + ) +endfunction() diff --git a/openair2/E1AP/MESSAGES/CMakeLists.txt b/openair2/E1AP/MESSAGES/CMakeLists.txt index 0657740e93..5d79f8dc3d 100644 --- a/openair2/E1AP/MESSAGES/CMakeLists.txt +++ b/openair2/E1AP/MESSAGES/CMakeLists.txt @@ -9,10 +9,11 @@ else() message(FATAL_ERROR "unknown E1AP_RELEASE ${E1AP_RELEASE}") endif() -add_custom_command(OUTPUT ${e1ap_source} ${e1ap_headers} - COMMAND ASN1C_PREFIX=E1AP_ ${ASN1C_EXEC} -gen-APER -gen-UPER -no-gen-JER -no-gen-BER -no-gen-OER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps -D ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${E1AP_GRAMMAR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${E1AP_GRAMMAR} - COMMENT "Generating E1AP source files from ${CMAKE_CURRENT_SOURCE_DIR}/${E1AP_GRAMMAR}" +run_asn1c(${CMAKE_CURRENT_SOURCE_DIR}/${E1AP_GRAMMAR} + "E1AP_" + OUTPUT ${e1ap_source} ${e1ap_headers} + OPTIONS -gen-APER -gen-UPER -no-gen-JER -no-gen-BER -no-gen-OER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps + COMMENT "E1AP source files" ) add_library(asn1_e1ap ${e1ap_source}) diff --git a/openair2/F1AP/MESSAGES/CMakeLists.txt b/openair2/F1AP/MESSAGES/CMakeLists.txt index 2b17d09ddd..0274b3a6cc 100644 --- a/openair2/F1AP/MESSAGES/CMakeLists.txt +++ b/openair2/F1AP/MESSAGES/CMakeLists.txt @@ -8,10 +8,11 @@ else() message(FATAL_ERROR "unknown F1AP_RELEASE ${F1AP_RELEASE}") endif() -add_custom_command(OUTPUT ${f1ap_source} ${f1ap_headers} - COMMAND ASN1C_PREFIX=F1AP_ ${ASN1C_EXEC} -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps -D ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${F1AP_GRAMMAR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${F1AP_GRAMMAR} - COMMENT "Generating F1AP source files from ${CMAKE_CURRENT_SOURCE_DIR}/${F1AP_GRAMMAR}" +run_asn1c(${CMAKE_CURRENT_SOURCE_DIR}/${F1AP_GRAMMAR} + "F1AP_" + OUTPUT ${f1ap_source} ${f1ap_headers} + OPTIONS -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps + COMMENT "F1AP source files" ) add_library(asn1_f1ap ${f1ap_source}) diff --git a/openair2/M2AP/MESSAGES/CMakeLists.txt b/openair2/M2AP/MESSAGES/CMakeLists.txt index 2142655ac2..5a436a06e6 100644 --- a/openair2/M2AP/MESSAGES/CMakeLists.txt +++ b/openair2/M2AP/MESSAGES/CMakeLists.txt @@ -18,10 +18,11 @@ else() message(FATAL_ERROR "unknown M2AP_RELEASE ${M2AP_RELEASE}") endif() -add_custom_command(OUTPUT ${m2ap_source} ${m2ap_headers} - COMMAND ASN1C_PREFIX=M2AP_ ${ASN1C_EXEC} -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -fcompound-names -no-gen-example -fno-include-deps -D ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${M2AP_GRAMMAR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${M2AP_GRAMMAR} - COMMENT "Generating M2AP source files from ${CMAKE_CURRENT_SOURCE_DIR}/${M2AP_GRAMMAR}" +run_asn1c(${CMAKE_CURRENT_SOURCE_DIR}/${M2AP_GRAMMAR} + "M2AP_" + OUTPUT ${m2ap_source} ${m2ap_headers} + OPTIONS -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -fcompound-names -no-gen-example -fno-include-deps + COMMENT "M2AP source files" ) add_library(asn1_m2ap ${m2ap_source}) diff --git a/openair2/RRC/LTE/MESSAGES/CMakeLists.txt b/openair2/RRC/LTE/MESSAGES/CMakeLists.txt index 162463dc46..776983068a 100644 --- a/openair2/RRC/LTE/MESSAGES/CMakeLists.txt +++ b/openair2/RRC/LTE/MESSAGES/CMakeLists.txt @@ -10,10 +10,11 @@ else() message(FATAL_ERROR "unknown LTE_RRC_RELEASE ${LTE_RRC_RELEASE}") endif() -add_custom_command(OUTPUT ${lte_rrc_source} ${lte_rrc_headers} - COMMAND ASN1C_PREFIX=LTE_ ${ASN1C_EXEC} -pdu=all -fcompound-names -gen-UPER -no-gen-BER -no-gen-JER -no-gen-OER -gen-APER -no-gen-example -D ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${LTE_RRC_GRAMMAR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${LTE_RRC_GRAMMAR} - COMMENT "Generating LTE RRC source file from ${CMAKE_CURRENT_SOURCE_DIR}/${LTE_RRC_GRAMMAR}" +run_asn1c(${CMAKE_CURRENT_SOURCE_DIR}/${LTE_RRC_GRAMMAR} + "LTE_" + OUTPUT ${lte_rrc_source} ${lte_rrc_headers} + OPTIONS -pdu=all -fcompound-names -gen-UPER -no-gen-BER -no-gen-JER -no-gen-OER -gen-APER -no-gen-example + COMMENT "LTE RRC source files" ) # Many other targets include LTE RRC ASN.1 headers, without actually needing diff --git a/openair2/RRC/NR/MESSAGES/CMakeLists.txt b/openair2/RRC/NR/MESSAGES/CMakeLists.txt index f85c39bf73..8854801e1c 100644 --- a/openair2/RRC/NR/MESSAGES/CMakeLists.txt +++ b/openair2/RRC/NR/MESSAGES/CMakeLists.txt @@ -10,10 +10,11 @@ else() message(FATAL_ERROR "unknown NR_RRC_RELEASE ${NR_RRC_RELEASE}") endif() -add_custom_command(OUTPUT ${nr_rrc_source} ${nr_rrc_headers} - COMMAND ASN1C_PREFIX=NR_ ${ASN1C_EXEC} -pdu=all -fcompound-names -gen-UPER -no-gen-BER -no-gen-JER -no-gen-OER -gen-APER -no-gen-example -findirect-choice -D ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${NR_RRC_GRAMMAR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${NR_RRC_GRAMMAR} - COMMENT "Generating NR RRC source file from ${CMAKE_CURRENT_SOURCE_DIR}/${NR_RRC_GRAMMAR}" +run_asn1c(${CMAKE_CURRENT_SOURCE_DIR}/${NR_RRC_GRAMMAR} + "NR_" + OUTPUT ${nr_rrc_source} ${nr_rrc_headers} + OPTIONS -pdu=all -fcompound-names -gen-UPER -no-gen-BER -no-gen-JER -no-gen-OER -gen-APER -no-gen-example -findirect-choice + COMMENT "NR RRC source files" ) # Many other targets include NR RRC ASN.1 headers, without actually needing the diff --git a/openair2/X2AP/MESSAGES/CMakeLists.txt b/openair2/X2AP/MESSAGES/CMakeLists.txt index 679ab8aca2..755a13c7c1 100644 --- a/openair2/X2AP/MESSAGES/CMakeLists.txt +++ b/openair2/X2AP/MESSAGES/CMakeLists.txt @@ -9,10 +9,11 @@ else() message(FATAL_ERROR "unknown X2AP_RELEASE ${X2AP_RELEASE}") endif() -add_custom_command(OUTPUT ${x2ap_source} ${x2ap_headers} - COMMAND ASN1C_PREFIX=X2AP_ ${ASN1C_EXEC} -pdu=all -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -fcompound-names -no-gen-example -fno-include-deps -D ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${X2AP_GRAMMAR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${X2AP_GRAMMAR} - COMMENT "Generating X2AP source files from ${CMAKE_CURRENT_SOURCE_DIR}/${X2AP_GRAMMAR}" +run_asn1c(${CMAKE_CURRENT_SOURCE_DIR}/${X2AP_GRAMMAR} + "X2AP_" + OUTPUT ${x2ap_source} ${x2ap_headers} + OPTIONS -pdu=all -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -fcompound-names -no-gen-example -fno-include-deps + COMMENT "X2AP source files" ) add_library(asn1_x2ap ${x2ap_source}) diff --git a/openair2/XNAP/MESSAGES/CMakeLists.txt b/openair2/XNAP/MESSAGES/CMakeLists.txt index 078388e3c0..92528fc73f 100644 --- a/openair2/XNAP/MESSAGES/CMakeLists.txt +++ b/openair2/XNAP/MESSAGES/CMakeLists.txt @@ -9,11 +9,12 @@ else() message(FATAL_ERROR "unknown XNAP_RELEASE ${XNAP_RELEASE}") endif() -add_custom_command(OUTPUT ${xnap_source} ${xnap_headers} - COMMAND ASN1C_PREFIX=XNAP_ ${ASN1C_EXEC} -pdu=all -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -fcompound-names -no-gen-example -fno-include-deps -findirect-choice -D ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${XNAP_GRAMMAR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${XNAP_GRAMMAR} - COMMENT "Generating XNAP source files from ${CMAKE_CURRENT_SOURCE_DIR}/${XNAP_GRAMMAR}" - ) +run_asn1c(${CMAKE_CURRENT_SOURCE_DIR}/${XNAP_GRAMMAR} + "XNAP_" + OUTPUT ${xnap_source} ${xnap_headers} + OPTIONS -pdu=all -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -fcompound-names -no-gen-example -fno-include-deps -findirect-choice + COMMENT "XnAP source files" +) add_library(asn1_xnap ${xnap_source}) target_include_directories(asn1_xnap PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/openair3/LPP/MESSAGES/CMakeLists.txt b/openair3/LPP/MESSAGES/CMakeLists.txt index 0ffdf87113..b340a6ad51 100644 --- a/openair3/LPP/MESSAGES/CMakeLists.txt +++ b/openair3/LPP/MESSAGES/CMakeLists.txt @@ -9,10 +9,11 @@ include(ASN1/37355-g60.cmake) # message(FATAL_ERROR "unknown LPP_RELEASE ${LPP_RELEASE}") #endif() -add_custom_command(OUTPUT ${lpp_source} ${lpp_headers} - COMMAND ASN1C_PREFIX=LPP_ ${ASN1C_EXEC} -gen-UPER -no-gen-BER -no-gen-JER -no-gen-OER -gen-APER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps -D ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${LPP_GRAMMAR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${LPP_GRAMMAR} - COMMENT "Generating LPP source files from ${CMAKE_CURRENT_SOURCE_DIR}/${LPP_GRAMMAR}" +run_asn1c(${CMAKE_CURRENT_SOURCE_DIR}/${LPP_GRAMMAR} + "LPP_" + OUTPUT ${lpp_source} ${lpp_headers} + OPTIONS -gen-UPER -no-gen-BER -no-gen-JER -no-gen-OER -gen-APER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps + COMMENT "LPP source files" ) add_library(asn1_lpp ${lpp_source}) diff --git a/openair3/M3AP/MESSAGES/CMakeLists.txt b/openair3/M3AP/MESSAGES/CMakeLists.txt index 8b5512919d..52007b629d 100644 --- a/openair3/M3AP/MESSAGES/CMakeLists.txt +++ b/openair3/M3AP/MESSAGES/CMakeLists.txt @@ -16,10 +16,11 @@ else() message(FATAL_ERROR "unknown M3AP_RELEASE ${M3AP_RELEASE}") endif() -add_custom_command(OUTPUT ${m3ap_source} ${m3ap_headers} - COMMAND ASN1C_PREFIX=M3AP_ ${ASN1C_EXEC} -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -fcompound-names -no-gen-example -fno-include-deps -D ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${M3AP_GRAMMAR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${M3AP_GRAMMAR} - COMMENT "Generating M3AP source files from ${CMAKE_CURRENT_SOURCE_DIR}/${M3AP_GRAMMAR}" +run_asn1c(${CMAKE_CURRENT_SOURCE_DIR}/${M3AP_GRAMMAR} + "M3AP_" + OUTPUT ${m3ap_source} ${m3ap_headers} + OPTIONS -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -fcompound-names -no-gen-example -fno-include-deps + COMMENT "M3AP source files" ) add_library(asn1_m3ap ${m3ap_source}) diff --git a/openair3/NGAP/MESSAGES/CMakeLists.txt b/openair3/NGAP/MESSAGES/CMakeLists.txt index 06148b6c5a..e5cfe07956 100644 --- a/openair3/NGAP/MESSAGES/CMakeLists.txt +++ b/openair3/NGAP/MESSAGES/CMakeLists.txt @@ -9,10 +9,11 @@ else() message(FATAL_ERROR "unknown NGAP_RELEASE ${NGAP_RELEASE}") endif() -add_custom_command(OUTPUT ${ngap_source} ${ngap_headers} - COMMAND ASN1C_PREFIX=NGAP_ ${ASN1C_EXEC} -pdu=all -fcompound-names -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -no-gen-example -fno-include-deps -findirect-choice -D ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${NGAP_GRAMMAR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${NGAP_GRAMMAR} - COMMENT "Generating NGAP source files from ${CMAKE_CURRENT_SOURCE_DIR}/${NGAP_GRAMMAR}" +run_asn1c(${CMAKE_CURRENT_SOURCE_DIR}/${NGAP_GRAMMAR} + "NGAP_" + OUTPUT ${ngap_source} ${ngap_headers} + OPTIONS -pdu=all -fcompound-names -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -no-gen-example -fno-include-deps -findirect-choice + COMMENT "NGAP source files" ) add_library(asn1_ngap ${ngap_source}) diff --git a/openair3/NRPPA/MESSAGES/CMakeLists.txt b/openair3/NRPPA/MESSAGES/CMakeLists.txt index 840553a62d..997fb70a9c 100644 --- a/openair3/NRPPA/MESSAGES/CMakeLists.txt +++ b/openair3/NRPPA/MESSAGES/CMakeLists.txt @@ -9,10 +9,11 @@ include(ASN1/38455.cmake) # message(FATAL_ERROR "unknown NRPPA_RELEASE ${NRPPA_RELEASE}") #endif() -add_custom_command(OUTPUT ${nrppa_source} ${nrppa_headers} - COMMAND ASN1C_PREFIX=NRPPA_ ${ASN1C_EXEC} -gen-APER -gen-UPER -no-gen-OER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps -D ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${NRPPA_GRAMMAR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${NRPPA_GRAMMAR} - COMMENT "Generating NRPPA source files from ${CMAKE_CURRENT_SOURCE_DIR}/${NRPPA_GRAMMAR}" +run_asn1c(${CMAKE_CURRENT_SOURCE_DIR}/${NRPPA_GRAMMAR} + "NRPPA_" + OUTPUT ${nrppa_source} ${nrppa_headers} + OPTIONS -gen-APER -gen-UPER -no-gen-OER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps + COMMENT "NRPPA source files" ) add_library(asn1_nrppa ${nrppa_source}) diff --git a/openair3/S1AP/MESSAGES/CMakeLists.txt b/openair3/S1AP/MESSAGES/CMakeLists.txt index bb1526b659..f38a3a93a6 100644 --- a/openair3/S1AP/MESSAGES/CMakeLists.txt +++ b/openair3/S1AP/MESSAGES/CMakeLists.txt @@ -9,10 +9,11 @@ else() message(FATAL_ERROR "unknown S1AP_RELEASE ${S1AP_RELEASE}") endif() -add_custom_command(OUTPUT ${s1ap_source} ${s1ap_headers} - COMMAND ASN1C_PREFIX=S1AP_ ${ASN1C_EXEC} -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -fcompound-names -no-gen-example -fno-include-deps -D ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${S1AP_GRAMMAR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${S1AP_GRAMMAR} - COMMENT "Generating S1AP source files from ${CMAKE_CURRENT_SOURCE_DIR}/${S1AP_GRAMMAR}" +run_asn1c(${CMAKE_CURRENT_SOURCE_DIR}/${S1AP_GRAMMAR} + "S1AP_" + OUTPUT ${s1ap_source} ${s1ap_headers} + OPTIONS -gen-APER -no-gen-BER -no-gen-JER -no-gen-OER -gen-UPER -fcompound-names -no-gen-example -fno-include-deps + COMMENT "S1AP source files" ) add_library(asn1_s1ap ${s1ap_source})