When asn1c is not found, allow to download and use asn1c in build tree
This simplifies dependancies management Co-authored-by: Robert Schmidt <robert.schmidt@openairinterface.org>
This commit is contained in:
co-authored by
Robert Schmidt
parent
5fcd456a46
commit
3a935bc9f7
+28
-13
@@ -83,25 +83,40 @@ option(PACKAGING_COMMON "Will produce a package containing common target, config
|
|||||||
option(PACKAGING_USRP "Will produce a package containing usrp target, configuration files and docs" OFF)
|
option(PACKAGING_USRP "Will produce a package containing usrp target, configuration files and docs" OFF)
|
||||||
option(PACKAGING_PHYSIM "Will produce a package containing physim target, configuration files and docs" OFF)
|
option(PACKAGING_PHYSIM "Will produce a package containing physim target, configuration files and docs" OFF)
|
||||||
|
|
||||||
|
|
||||||
# Check if asn1c is installed, and check if it supports all options we need
|
# Check if asn1c is installed, and check if it supports all options we need
|
||||||
# a user can provide ASN1C_EXEC to override an asn1c to use (e.g., parallel
|
# a user can provide ASN1C_EXEC to override an asn1c to use (e.g., parallel
|
||||||
# installation)
|
# installation)
|
||||||
find_program(ASN1C_EXEC_PATH asn1c HINTS /opt/asn1c/bin)
|
find_program(ASN1C_EXEC_PATH asn1c HINTS /opt/asn1c/bin)
|
||||||
set(ASN1C_EXEC ${ASN1C_EXEC_PATH} CACHE FILEPATH "path to asn1c executable")
|
set(ASN1C_EXEC ${ASN1C_EXEC_PATH} CACHE FILEPATH "path to asn1c executable")
|
||||||
if(NOT ASN1C_EXEC)
|
option(AUTO_DOWNLOAD_ASN1C "Automatically download asn1c if not found" OFF)
|
||||||
message(FATAL_ERROR "No asn1c found!
|
if (ASN1C_EXEC)
|
||||||
You might want to re-run ./build_oai -I
|
check_option(${ASN1C_EXEC} -gen-APER ASN1C_EXEC)
|
||||||
Or provide a path to asn1c using
|
check_option(${ASN1C_EXEC} -no-gen-UPER ASN1C_EXEC)
|
||||||
./build_oai ... --cmake-opt -DASN1C_EXEC=/path/to/asn1c
|
check_option(${ASN1C_EXEC} -no-gen-JER ASN1C_EXEC)
|
||||||
")
|
check_option(${ASN1C_EXEC} -no-gen-BER ASN1C_EXEC)
|
||||||
|
check_option(${ASN1C_EXEC} -no-gen-OER ASN1C_EXEC)
|
||||||
|
add_custom_target(asn1c DEPENDS ${ASN1C_EXEC})
|
||||||
|
else ()
|
||||||
|
if (NOT AUTO_DOWNLOAD_ASN1C)
|
||||||
|
message(FATAL_ERROR "asn1c not found. Install it globally or activate AUTO_DOWNLOAD_ASN1C")
|
||||||
|
endif()
|
||||||
|
message(STATUS "Downloading and compile asn1c local in this build tree")
|
||||||
|
include(ExternalProject)
|
||||||
|
ExternalProject_Add(
|
||||||
|
asn1c_gen
|
||||||
|
GIT_REPOSITORY https://github.com/mouse07410/asn1c
|
||||||
|
GIT_TAG 940dd5fa9f3917913fd487b13dfddfacd0ded06e
|
||||||
|
GIT_REMOTE_UPDATE_STRATEGY CHECKOUT
|
||||||
|
BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/bin/asn1c
|
||||||
|
BUILD_IN_SOURCE True
|
||||||
|
CONFIGURE_COMMAND autoreconf -i
|
||||||
|
BUILD_COMMAND ./configure --prefix ${CMAKE_BINARY_DIR}
|
||||||
|
COMMAND make -j8 CFLAGS=-fno-strict-aliasing -Wmisleading-indentation
|
||||||
|
STEP_TARGETS build
|
||||||
|
)
|
||||||
|
set(ASN1C_EXEC ${CMAKE_BINARY_DIR}/bin/asn1c)
|
||||||
|
add_custom_target(asn1c DEPENDS asn1c_gen)
|
||||||
endif()
|
endif()
|
||||||
check_option(${ASN1C_EXEC} -gen-APER ASN1C_EXEC)
|
|
||||||
check_option(${ASN1C_EXEC} -no-gen-UPER ASN1C_EXEC)
|
|
||||||
check_option(${ASN1C_EXEC} -no-gen-JER ASN1C_EXEC)
|
|
||||||
check_option(${ASN1C_EXEC} -no-gen-BER ASN1C_EXEC)
|
|
||||||
check_option(${ASN1C_EXEC} -no-gen-OER ASN1C_EXEC)
|
|
||||||
|
|
||||||
#########################################################
|
#########################################################
|
||||||
# Base directories, compatible with legacy OAI building #
|
# Base directories, compatible with legacy OAI building #
|
||||||
#########################################################
|
#########################################################
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ function(run_asn1c ASN1C_GRAMMAR ASN1C_PREFIX)
|
|||||||
set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${GRAMMAR_FILE}.log")
|
set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${GRAMMAR_FILE}.log")
|
||||||
add_custom_command(OUTPUT ${ASN1C_OUTPUT}
|
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} && false )
|
COMMAND ASN1C_PREFIX=${ASN1C_PREFIX} ${ASN1C_EXEC} ${ASN1C_OPTIONS} -D ${CMAKE_CURRENT_BINARY_DIR} ${ASN1C_GRAMMAR} > ${LOGFILE} 2>&1 || ( cat ${LOGFILE} && false )
|
||||||
DEPENDS ${ASN1C_GRAMMAR}
|
DEPENDS ${ASN1C_GRAMMAR} asn1c
|
||||||
COMMENT "Generating ${ASN1C_COMMENT} from ${GRAMMAR_FILE}"
|
COMMENT "Generating ${ASN1C_COMMENT} from ${GRAMMAR_FILE}"
|
||||||
)
|
)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
Reference in New Issue
Block a user