Linux あれこれ

Linux 関連(一部 Windows11 )の備忘録です。

Lubuntu 20.04 LTS (Beta) ログイン画面の設定ツール「C++ 版」を試しました 2〈H18〉

登録日: 2020-04-09 更新日: 2020-04-25

公開直前の「Lubuntu 20.04 LTS」の未公開版(ベータ版)をUSB メモリにインストールしました。

「SDDM」の設定ツール「C++ 版」のインストールを試している、その続きです。 Cmake を少し学んでからトライしました。その備忘録です。

-

「目次」

-


ダウンロードしたファイルの先頭の構成:
$ ls -1 ~/ダウンロード/sdd-cnf/sddm-config-editor-master/

CMakeLists.txt
LICENSE
README.md
cmake_uninstall.cmake.in
cpp
data
ruby
ui

→「CMakeLists.txt」があるということは「Cmake を使ってのビルドが前提」だということです。こちらは頭だけに置いてあります。

README.md には、「Ruby 版」と「C++ 版」が入っているという説明ぐらいで、CMake を使ってのビルドのやり方の説明は書かれていません。知っていて当然ということかな。

-


ruby」フォルダ

ツールの「Ruby 版」のソースが入っています。 個別のREADME.md があります。

-


「cpp」フォルダ

ツールの「C++ 版」のソースが入っています。 個別のREADME.md があります。

-


data ファイルの内容:
../data

Makefile の「data/」のパス合わせ。

-


ui ファイルの内容:
../ui

Makefile の「ui/」のパス合わせ。

-


ファイルの先頭で、cmake にトライ:

C++ 版」と「Ruby 版」のソースが入っていますが、「C++ 版」が選ばれました。

-

cmake が入っているかの確認:

$ cmake --version

Command 'cmake' not found, but can be installed with:

sudo snap install cmake  # version 3.17.0, or
sudo apt  install cmake  # version 3.16.3-1ubuntu1

See 'snap info cmake' for additional versions.

-


入っていないので、cmake をインストール:

$ sudo apt update

$ sudo apt install cmake
:
提案パッケージ:
  cmake-doc ninja-build
以下のパッケージが新たにインストールされます:
  cmake cmake-data libjsoncpp1 librhash0

-

$ cmake --version
cmake version 3.16.3

-


ビルド用のフォルダを準備:

これを作っておくと、やり直しが楽です。

$ cd ~/ダウンロード/sdd-cnf/sddm-config-editor-master/

$ mkdir build
$ ls
CMakeLists.txt  LICENSE  README.md  build  cmake_uninstall.cmake.in  cpp  data  ruby  ui

-


CMakeLists.txt の確認:

トップにしかCMakeLists.txt は置かれていませんでした。

$ cd ~/ダウンロード/sdd-cnf/sddm-config-editor-master/
$ featherpad CMakeLists.txt

内容:

cmake_minimum_required(VERSION 3.1.0)

include(GNUInstallDirs)

project(SDDMConfigEditor)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

find_package(Qt5 COMPONENTS Qml Quick Widgets LinguistTools REQUIRED)

set(SRC
    cpp/configuration.cpp
    cpp/controller.cpp
    cpp/main.cpp
    cpp/section.cpp
    cpp/setting.cpp
)

set(RCC cpp/qml.qrc)

set(TS
    cpp/sddm-config-editor_it.ts
    cpp/sddm-config-editor_ru.ts
    cpp/sddm-config-editor_zh_CN.ts
)

set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM true)

qt5_add_translation(TRANSLATIONS ${TS})

add_executable(sddm-config-editor ${SRC} ${RCC} ${TRANSLATIONS})
target_link_libraries(sddm-config-editor Qt5::Qml Qt5::Quick Qt5::Widgets)

install(
    FILES data/sddm-config-editor.desktop
    DESTINATION "${CMAKE_INSTALL_DATADIR}/applications"
)

install(TARGETS sddm-config-editor RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

# uninstall target
if(NOT TARGET uninstall)
    configure_file(
        "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
        "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
        IMMEDIATE @ONLY)

        add_custom_target(uninstall
            COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()

-


cmake を実行:

$ cd ~/ダウンロード/sdd-cnf/sddm-config-editor-master/build/

$ cmake ..

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done

CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake:28 (find_package):
  Could not find a package configuration file provided by "Qt5LinguistTools"
  with any of the following names:

    Qt5LinguistToolsConfig.cmake
    qt5linguisttools-config.cmake

  Add the installation prefix of "Qt5LinguistTools" to CMAKE_PREFIX_PATH or
  set "Qt5LinguistTools_DIR" to a directory containing one of the above
  files.  If "Qt5LinguistTools" provides a separate development package or
  SDK, be sure it has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:13 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/ubn/ダウンロード/sdd-cnf/sddm-config-editor-master/build/CMakeFiles/CMakeOutput.log".

→「Qt5LinguistTools」が別個の開発パッケージまたはSDKを提供する場合は、それがインストールされていることを確認してください。というガイドが表示されました。

-


対策:
$ apt search qttools
:
qttools5-dev/focal 5.12.5-2build1 amd64
  Qt 5 tools development files

qttools5-dev-tools/focal,now 5.12.5-2build1 amd64 [インストール済み]
  Qt 5 development tools

→インストールされていない方も、インストール:

$ sudo apt install qttools5-dev
:
以下のパッケージが新たにインストールされます:
  qttools5-dev

-


cmake を再度実行:

「build」フォルダ (~/ダウンロード/sdd-cnf/sddm-config-editor-master/build/ ) 内の中のファイルを消してから、再トライ。

-

$ cd ~/ダウンロード/sdd-cnf/sddm-config-editor-master/build/

$ cmake ..

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubn/ダウンロード/sdd-cnf/sddm-config-editor-master/build

→成功。

$ ls
CMakeCache.txt  CMakeFiles  Makefile  cmake_install.cmake  cmake_uninstall.cmake

→「build」フォルダ内に、Makefile が作られています。

-


make を実行:

$ make

Scanning dependencies of target sddm-config-editor_autogen
[  7%] Automatic MOC and UIC for target sddm-config-editor
[  7%] Built target sddm-config-editor_autogen
make[2]: *** 'sddm-config-editor_autogen/SVODSI3R2M/qrc_qml.cpp' に必要なターゲット '../cpp/data/config-schema.json' を make するルールがありません.  中止.
make[1]: *** [CMakeFiles/Makefile2:104: CMakeFiles/sddm-config-editor.dir/all] エラー 2
make: *** [Makefile:130: all] エラー 2

→表示は少し違うけど、やっぱり、前回と同じところ(qrc_qml.cpp)で、同じようなエラー(make するルールがありません)です。やっぱり、Makefile がらみですね。

-

$ ls -l ~/ダウンロード/sdd-cnf/sddm-config-editor-master/build/
合計 52
-rw-rw-r-- 1 ubn ubn 17870  4月  8 07:06 CMakeCache.txt
drwxrwxr-x 8 ubn ubn  4096  4月  8 07:20 CMakeFiles  ←(追加されました)
-rw-rw-r-- 1 ubn ubn 14756  4月  8 07:06 Makefile
-rw-rw-r-- 1 ubn ubn  2743  4月  8 07:06 cmake_install.cmake
-rw-rw-r-- 1 ubn ubn  1202  4月  8 07:06 cmake_uninstall.cmake
drwxrwxr-x 4 ubn ubn  4096  4月  8 07:20 sddm-config-editor_autogen ←(追加されました)

-

  • ビルドの手順を間違えているのかは、説明もないしスキルも不足しているので不明。

-


まとめ

Makefile が原因?でビルドできませんでした。

しかし、「cmake」を使ったことで、依存関係の問題を指摘してくれたので、パッケージの漏れがないかを確認できました。初期段階に、もっと早く使っていれば、依存関係の解決は早くできたかもしれません。

今回は、1つのプロジェクトに、プログラムが複数存在してフォルダ分けされており、個別のビルドのやり方は各々のREADME.md に書かれていました。しかし、親フォルダにあるREADME.md には各々のREADME.md を確認しなさいとだけ書かれていました。

使ってもいいし、使わなくてもいいということで「cmake」の説明は書かれていないのか、単なる漏れなのか。説明が不十分なケースもあるようなので、注意したほうが良さそう。

-

-


目次

先頭

-


-