Skip to content

Commit

Permalink
refactor: 不嵌入rc资源,仅link
Browse files Browse the repository at this point in the history
  • Loading branch information
GengGode committed Aug 27, 2024
1 parent 650574d commit 93be619
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(BUILD_TARGET_NAME libocr CACHE STRING "Build target_name" FORCE)
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libs" FORCE)
set(BUILD_TEST OFF CACHE BOOL "Build test")
set(ENABLE_RC OFF CACHE BOOL "embed rc file")
set(ENABLE_LINKEDRESOURCE "not embed file" CACHE STRING "embed file status")
#=======================================================================================================================
set(include_dir ${CMAKE_SOURCE_DIR}/include)
set(resource_dir ${CMAKE_SOURCE_DIR}/resource)
Expand Down Expand Up @@ -81,6 +83,8 @@ message(STATUS " BUILD_TARGET_NAME : ${BUILD_TARGET_NAME}")
message(STATUS " BUILD_SHARED_LIBS : ${BUILD_SHARED_LIBS}")
message(STATUS " BUILD_TEST : ${BUILD_TEST}")
message(STATUS "Model : ")
message(STATUS " enable rc : ${ENABLE_RC}")
message(STATUS " enable linked resource : ${ENABLE_LINKEDRESOURCE}")
message(STATUS " model_rec_file : ${model_rec_file}")
message(STATUS " model_cls_file : ${model_cls_file}")
message(STATUS " model_det_file : ${model_det_file}")
Expand Down
4 changes: 3 additions & 1 deletion resource/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(resource_target_name ${BUILD_TARGET_NAME}_resource)
add_library(${resource_target_name} STATIC)
add_library(${BUILD_TARGET_NAME}::resource ALIAS ${resource_target_name})

target_compile_options(${resource_target_name} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/utf-8>)
set_target_properties(${resource_target_name} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_compile_options(${resource_target_name} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/MP>)
Expand Down Expand Up @@ -50,6 +50,8 @@ target_compile_definitions(embed_utils PRIVATE list_of_resources=${list_of_resou

add_dependencies(${resource_target_name} embed_utils)

set(ENABLE_LINKEDRESOURCE "static link embed" CACHE INTERNAL "static link embed")

# 生成后事件
add_custom_command(
TARGET ${resource_target_name}
Expand Down
2 changes: 1 addition & 1 deletion resource/version.ver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.98
0.3.123
2 changes: 1 addition & 1 deletion resource/version_hash.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dea260c
650574d
7 changes: 5 additions & 2 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ target_compile_options(${BUILD_TARGET_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/M
# rc文件
set(version_rc_file "${CMAKE_BINARY_DIR}/resource_version.rc")
configure_file("${CMAKE_SOURCE_DIR}/resource/resource_version.rc.in" "${version_rc_file}")
set(model_rc_file "${CMAKE_SOURCE_DIR}/resource/resource_model.rc")
list(APPEND resource_files "${version_rc_file}" "${model_rc_file}")
if (BUILD_SHARED_LIBS)
set(model_rc_file "${CMAKE_SOURCE_DIR}/resource/resource_model.rc")
list(APPEND resource_files "${version_rc_file}" "${model_rc_file}")
set(ENABLE_RC ON CACHE INTERNAL "embed rc file")
endif()

# cpp文件
file(GLOB_RECURSE source_files "*.cpp" "*.h" "*.hpp" "*.c" "*.cc" "*.cxx" "*.hxx")
Expand Down
4 changes: 2 additions & 2 deletions source/onnx/onnx.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace libocr::onnx
auto res_data = libocr::from_resource_load_file(file_name);
return { res_data.data, res_data.size };
}

#ifndef _LIB
res_data_ptr from_resource_load_onnx(int idr)
{
// Initialize session from Resource idr
Expand Down Expand Up @@ -108,7 +108,7 @@ namespace libocr::onnx

return { lp_data, dw_size };
}

#endif
private:
std::string get_input_name(Ort::Session* session)
{
Expand Down

0 comments on commit 93be619

Please sign in to comment.