mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-29 20:14:01 +00:00
Unify handling of public headers in onnxruntime.cmake. (#17779)
The changes in PR #8919 overwrote the PUBLIC_HEADER property value of the `onnxruntime` target with a list that did not include EP-specific headers. We should probably be using a consistent set of header files across packages anyway.
This commit is contained in:
parent
a05580ed5b
commit
1bc115719c
1 changed files with 21 additions and 36 deletions
|
|
@ -18,35 +18,21 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
|
|||
set(OUTPUT_STYLE xcode)
|
||||
endif()
|
||||
|
||||
set(ONNXRUNTIME_PUBLIC_HEADERS
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_c_api.h"
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_cxx_api.h"
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_float16.h"
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_cxx_inline.h"
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h"
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_run_options_config_keys.h"
|
||||
)
|
||||
|
||||
if (onnxruntime_ENABLE_TRAINING_APIS)
|
||||
list(APPEND ${_HEADERS} "${REPO_ROOT}/orttraining/orttraining/training_api/include/onnxruntime_training_c_api.h")
|
||||
list(APPEND ${_HEADERS} "${REPO_ROOT}/orttraining/orttraining/training_api/include/onnxruntime_training_cxx_api.h")
|
||||
list(APPEND ${_HEADERS} "${REPO_ROOT}/orttraining/orttraining/training_api/include/onnxruntime_training_cxx_inline.h")
|
||||
endif()
|
||||
|
||||
# This macro is to get the path of header files for mobile packaging, for iOS and Android
|
||||
macro(get_mobile_api_headers _HEADERS)
|
||||
# include both c and cxx api
|
||||
set(${_HEADERS}
|
||||
# Gets the public C/C++ API header files
|
||||
function(get_c_cxx_api_headers HEADERS_VAR)
|
||||
set(_headers
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_c_api.h"
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_cxx_api.h"
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_float16.h"
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_cxx_inline.h"
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_float16.h"
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_run_options_config_keys.h"
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h"
|
||||
)
|
||||
|
||||
if (onnxruntime_ENABLE_TRAINING_APIS)
|
||||
list(APPEND ${_HEADERS} "${REPO_ROOT}/orttraining/orttraining/training_api/include/onnxruntime_training_c_api.h")
|
||||
list(APPEND ${_HEADERS} "${REPO_ROOT}/orttraining/orttraining/training_api/include/onnxruntime_training_cxx_api.h")
|
||||
list(APPEND ${_HEADERS} "${REPO_ROOT}/orttraining/orttraining/training_api/include/onnxruntime_training_cxx_inline.h")
|
||||
list(APPEND _headers "${REPO_ROOT}/orttraining/orttraining/training_api/include/onnxruntime_training_c_api.h")
|
||||
list(APPEND _headers "${REPO_ROOT}/orttraining/orttraining/training_api/include/onnxruntime_training_cxx_api.h")
|
||||
list(APPEND _headers "${REPO_ROOT}/orttraining/orttraining/training_api/include/onnxruntime_training_cxx_inline.h")
|
||||
endif()
|
||||
|
||||
# need to add header files for enabled EPs
|
||||
|
|
@ -54,10 +40,13 @@ macro(get_mobile_api_headers _HEADERS)
|
|||
file(GLOB _provider_headers CONFIGURE_DEPENDS
|
||||
"${REPO_ROOT}/include/onnxruntime/core/providers/${f}/*.h"
|
||||
)
|
||||
list(APPEND ${_HEADERS} "${_provider_headers}")
|
||||
unset(_provider_headers)
|
||||
list(APPEND _headers ${_provider_headers})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
set(${HEADERS_VAR} ${_headers} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
get_c_cxx_api_headers(ONNXRUNTIME_PUBLIC_HEADERS)
|
||||
|
||||
#If you want to verify if there is any extra line in symbols.txt, run
|
||||
# nm -C -g --defined libonnxruntime.so |grep -v '\sA\s' | cut -f 3 -d ' ' | sort
|
||||
|
|
@ -84,11 +73,9 @@ if(WIN32)
|
|||
"${ONNXRUNTIME_ROOT}/core/dll/onnxruntime.rc"
|
||||
)
|
||||
elseif(onnxruntime_BUILD_APPLE_FRAMEWORK)
|
||||
get_mobile_api_headers(APPLE_FRAMEWORK_HEADERS)
|
||||
|
||||
# apple framework requires the header file be part of the library
|
||||
onnxruntime_add_shared_library(onnxruntime
|
||||
${APPLE_FRAMEWORK_HEADERS}
|
||||
${ONNXRUNTIME_PUBLIC_HEADERS}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/generated_source.c"
|
||||
)
|
||||
|
||||
|
|
@ -107,10 +94,9 @@ elseif(onnxruntime_BUILD_APPLE_FRAMEWORK)
|
|||
set_target_properties(onnxruntime PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION A
|
||||
PUBLIC_HEADER "${APPLE_FRAMEWORK_HEADERS}"
|
||||
MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist
|
||||
VERSION ${ORT_VERSION}
|
||||
SOVERSION ${ORT_VERSION}
|
||||
MACOSX_FRAMEWORK_INFO_PLIST ${INFO_PLIST_PATH}
|
||||
SOVERSION ${ORT_VERSION}
|
||||
# Note: The PUBLIC_HEADER and VERSION properties for the 'onnxruntime' target will be set later in this file.
|
||||
)
|
||||
else()
|
||||
onnxruntime_add_shared_library(onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/generated_source.c)
|
||||
|
|
@ -180,11 +166,10 @@ endif()
|
|||
|
||||
# we need to copy C/C++ API headers to be packed into Android AAR package
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND onnxruntime_BUILD_JAVA)
|
||||
get_mobile_api_headers(ANDROID_AAR_HEADERS)
|
||||
set(ANDROID_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/android/headers)
|
||||
file(MAKE_DIRECTORY ${ANDROID_HEADERS_DIR})
|
||||
# copy the header files one by one
|
||||
foreach(h_ ${ANDROID_AAR_HEADERS})
|
||||
foreach(h_ ${ONNXRUNTIME_PUBLIC_HEADERS})
|
||||
get_filename_component(HEADER_NAME_ ${h_} NAME)
|
||||
add_custom_command(TARGET onnxruntime POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${h_} ${ANDROID_HEADERS_DIR}/${HEADER_NAME_})
|
||||
endforeach()
|
||||
|
|
@ -328,7 +313,7 @@ if(onnxruntime_BUILD_APPLE_FRAMEWORK)
|
|||
file(MAKE_DIRECTORY ${STATIC_FRAMEWORK_HEADER_DIR})
|
||||
|
||||
# copy the header files one by one, and the Info.plist
|
||||
foreach(h_ ${APPLE_FRAMEWORK_HEADERS})
|
||||
foreach(h_ ${ONNXRUNTIME_PUBLIC_HEADERS})
|
||||
get_filename_component(HEADER_NAME_ ${h_} NAME)
|
||||
add_custom_command(TARGET onnxruntime POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${h_} ${STATIC_FRAMEWORK_HEADER_DIR}/${HEADER_NAME_})
|
||||
endforeach()
|
||||
|
|
|
|||
Loading…
Reference in a new issue