Skip to content

Commit

Permalink
Add mo2_configure_extension().
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Aug 9, 2024
1 parent 673e4ea commit afbc50f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions mo2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ set(QT_TARGETS_FOLDER autogen)

include(${CMAKE_CURRENT_LIST_DIR}/mo2_cpp.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/mo2_python.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/mo2_extension.cmake)

# mark as included
set(MO2_DEFINED true)
7 changes: 1 addition & 6 deletions mo2_cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,7 @@ endfunction()
function(mo2_install_plugin TARGET)
cmake_parse_arguments(MO2 "FOLDER" "" "" ${ARGN})

if (${MO2_FOLDER})
install(TARGETS ${TARGET} RUNTIME DESTINATION ${MO2_INSTALL_BIN}/plugins/$<TARGET_FILE_BASE_NAME:${TARGET}>)
else()
install(TARGETS ${TARGET} RUNTIME DESTINATION bin/extensions/${CMAKE_PROJECT_NAME}/plugins)
endif()

install(TARGETS ${TARGET} RUNTIME DESTINATION ${MO2_INSTALL_BIN}/extensions/${MO2_EXTENSION_ID}/plugins)
if (NOT MO2_INSTALL_IS_BIN)
install(TARGETS ${TARGET} ARCHIVE DESTINATION lib)
# install PDB if possible
Expand Down
25 changes: 25 additions & 0 deletions mo2_extension.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.16)

#! mo2_configure_extension : configure a MO2 extension
#
# this function read the extension identifier from the metadata.json file and
# expose it as a ${extension_identifier} variable
#
# this function also trigger the installation of the metadata file to the
# extension directory
#
function(mo2_configure_extension)
set(METADATA_FILE ${CMAKE_CURRENT_SOURCE_DIR}/metadata.json)

if(NOT (EXISTS ${METADATA_FILE}))
message(ERROR "metadata file ${METADATA_FILE} not found")
endif()

file(READ ${METADATA_FILE} JSON_METADATA)
string(JSON extension_identifier GET ${JSON_METADATA} id)

set(MO2_EXTENSION_ID ${extension_identifier} PARENT_SCOPE)

install(FILES ${METADATA_FILE}
DESTINATION ${MO2_INSTALL_BIN}/extensions/${extension_identifier}/)
endfunction()
2 changes: 1 addition & 1 deletion mo2_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function(mo2_configure_python_module TARGET)
FILES "${PROJECT_SOURCE_DIR}/plugin-requirements.txt")
endif()

set(install_dir "${MO2_INSTALL_BIN}/plugins/${TARGET}")
set(install_dir "${MO2_INSTALL_PATH}/bin/extensions/${MO2_EXTENSION_ID}/plugins/${TARGET}")

# directories that go in bin/plugins/${name}
install(
Expand Down

0 comments on commit afbc50f

Please sign in to comment.