Skip to content

Commit e63de61

Browse files
build(cmake): fix the bug that the no lib version does not contain config and plugins
1 parent 6760b30 commit e63de61

File tree

1 file changed

+44
-39
lines changed

1 file changed

+44
-39
lines changed

cmake/PluginCommon.cmake

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -64,50 +64,55 @@ function(configure_plugin plugin_name src_files)
6464
set_target_properties(${plugin_name} PROPERTIES SUFFIX ".dll")
6565
endif()
6666

67-
# Conditionally install the plugin based on CPACK_INCLUDE_LIBS setting
67+
# Install the plugin to bin/plugins (always install plugins)
68+
install(TARGETS ${plugin_name}
69+
RUNTIME DESTINATION bin/plugins
70+
LIBRARY DESTINATION bin/plugins
71+
)
72+
73+
# automatically generate tools.json - always do this for runtime configs
74+
set(json_source_file "${CMAKE_CURRENT_SOURCE_DIR}/tools.json")
75+
set(json_target_file "${plugin_name}_tools.json")
76+
77+
if(EXISTS ${json_source_file})
78+
# Create configs directory if not exists
79+
file(MAKE_DIRECTORY ${CONFIGS_OUTPUT_DIR})
80+
81+
configure_file(
82+
${json_source_file}
83+
${CONFIGS_OUTPUT_DIR}/${json_target_file}
84+
COPYONLY
85+
)
86+
87+
# build when the plugin is built
88+
add_custom_command(
89+
OUTPUT ${CONFIGS_OUTPUT_DIR}/${json_target_file}
90+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
91+
${json_source_file}
92+
${CONFIGS_OUTPUT_DIR}/${json_target_file}
93+
DEPENDS ${json_source_file}
94+
COMMENT "Copying ${plugin_name} tools.json file to configs directory"
95+
)
96+
97+
add_custom_target(${plugin_name}_json ALL
98+
DEPENDS ${CONFIGS_OUTPUT_DIR}/${json_target_file}
99+
)
100+
101+
add_dependencies(${plugin_name} ${plugin_name}_json)
102+
103+
# Install configs to bin/configs (always install configs)
104+
install(FILES ${json_source_file}
105+
DESTINATION bin/configs
106+
RENAME ${json_target_file}
107+
)
108+
endif()
109+
110+
# Conditionally install development files based on CPACK_INCLUDE_LIBS setting
68111
if(CPACK_INCLUDE_LIBS)
69112
install(TARGETS ${plugin_name}
70-
RUNTIME DESTINATION bin/plugins
71-
LIBRARY DESTINATION lib/plugins
72113
ARCHIVE DESTINATION lib/plugins
73114
)
74115

75-
# automatically generate tools.json
76-
set(json_source_file "${CMAKE_CURRENT_SOURCE_DIR}/tools.json")
77-
set(json_target_file "${plugin_name}_tools.json")
78-
79-
if(EXISTS ${json_source_file})
80-
# Create configs directory if not exists
81-
file(MAKE_DIRECTORY ${CONFIGS_OUTPUT_DIR})
82-
83-
configure_file(
84-
${json_source_file}
85-
${CONFIGS_OUTPUT_DIR}/${json_target_file}
86-
COPYONLY
87-
)
88-
89-
# build when the plugin is built
90-
add_custom_command(
91-
OUTPUT ${CONFIGS_OUTPUT_DIR}/${json_target_file}
92-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
93-
${json_source_file}
94-
${CONFIGS_OUTPUT_DIR}/${json_target_file}
95-
DEPENDS ${json_source_file}
96-
COMMENT "Copying ${plugin_name} tools.json file to configs directory"
97-
)
98-
99-
add_custom_target(${plugin_name}_json ALL
100-
DEPENDS ${CONFIGS_OUTPUT_DIR}/${json_target_file}
101-
)
102-
103-
add_dependencies(${plugin_name} ${plugin_name}_json)
104-
105-
install(FILES ${json_source_file}
106-
DESTINATION bin/configs
107-
RENAME ${json_target_file}
108-
)
109-
endif()
110-
111116
if(extra_libs)
112117
foreach(lib ${extra_libs})
113118
install(FILES ${lib}

0 commit comments

Comments
 (0)