Skip to content

Commit

Permalink
CMake: Set OUTPUT_NAME on plugin libraries to the correct language name
Browse files Browse the repository at this point in the history
Work around CMake's handling of @ inside argument names that then end up
getting defined as variable names in language_plugin as well. We also need
to set the OUTPUT_NAME of these plugins back to the unmodified language
value, so that the plugins can be properly loaded by the keyboard.
  • Loading branch information
dobey committed Feb 8, 2022
1 parent 93566a5 commit 1fc4cce
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,29 @@ target_include_directories(westernsupport PUBLIC src/lib/logic plugins/westernsu
target_compile_definitions(westernsupport PRIVATE ${maliit-keyboard-definitions})

function(language_plugin _language _full_language _ebook)
# To support layout style variations such as en@dv we need to avoid using
# the @ character in variables, so split and replace it with _
set(_target ${_language})
if(${_language} MATCHES "^(.*)\@(.*)$")
set(_target ${CMAKE_MATCH_1}_${CMAKE_MATCH_2})
endif()

set(PLUGIN_SOURCES
plugins/${_language}/src/${_full_language}plugin.h
plugins/${_language}/src/${_full_language}plugin.json)
if(enable-presage)
add_ngram(TEXT plugins/${_language}/src/${_ebook} DATABASE database_${_language}.db)
list(APPEND PLUGIN_SOURCES database_${_language}.db)
endif()
add_library(${_language}plugin MODULE ${PLUGIN_SOURCES})
target_link_libraries(${_language}plugin maliit-keyboard-common westernsupport)
add_library(${_target}plugin MODULE ${PLUGIN_SOURCES})
set_target_properties(${_target}plugin PROPERTIES OUTPUT_NAME ${_language}plugin)
target_link_libraries(${_target}plugin maliit-keyboard-common westernsupport)
install(FILES plugins/${_language}/qml/Keyboard_${_language}.qml
plugins/${_language}/qml/Keyboard_${_language}_email.qml
plugins/${_language}/qml/Keyboard_${_language}_url.qml
plugins/${_language}/qml/Keyboard_${_language}_url_search.qml
DESTINATION ${MALIIT_KEYBOARD_LANGUAGES_DIR}/${_language})
install(TARGETS ${_language}plugin
install(TARGETS ${_target}plugin
LIBRARY DESTINATION ${MALIIT_KEYBOARD_LANGUAGES_DIR}/${_language})
if(enable-presage)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/database_${_language}.db
Expand Down Expand Up @@ -277,6 +285,7 @@ function(abstract_language_plugin _language _full_language)
list(APPEND PLUGIN_SOURCES database_${_language}.db)
endif()
add_library(${_target}plugin MODULE ${PLUGIN_SOURCES})
set_target_properties(${_target}plugin PROPERTIES OUTPUT_NAME ${_language}plugin)
target_link_libraries(${_target}plugin Qt5::Core Maliit::Plugins maliit-keyboard-common ${abstract_language_plugin_LIBRARIES})
target_include_directories(${_target}plugin PRIVATE src/lib/logic ${abstract_language_plugin_INCLUDE_DIRS})
target_compile_definitions(${_target}plugin PRIVATE ${abstract_language_plugin_DEFINITIONS})
Expand Down

0 comments on commit 1fc4cce

Please sign in to comment.