Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio 2022でのCMakeの警告に対応 #1848

Merged
merged 2 commits into from Jun 11, 2022

Conversation

dep5
Copy link
Contributor

@dep5 dep5 commented May 31, 2022

PR の目的

2>CMake Warning (dev) in CMakeLists.txt:
2>  No project() command is present.  The top-level CMakeLists.txt file must
2>  contain a literal, direct call to the project() command.  Add a line of
2>  code such as
2>
2>    project(ProjectName)
2>
2>  near the top of the file, but after cmake_minimum_required().
2>
2>  CMake is pretending there is a "project(Project)" command on the first
2>  line.
2>This warning is for project developers.  Use -Wno-dev to suppress it.

ビルド・リビルド時にこのような警告が出るので対応します。

2>  Manually-specified variables were not used by the project:
2>
2>    CMAKE_C_COMPILER

新たに別の警告が出るので
これにも対応します。

カテゴリ

  • 不具合修正
  • ビルド関連
    • ビルド手順
    • ローカルビルド

PR の背景

Visual Studio 2017では警告は出ませんが、Visual Studio 2022だと出るようになりました。
2019でも出ていたような気がします…

PR のメリット

PR のデメリット (トレードオフとかあれば)

仕様・動作説明

https://cmake.org/cmake/help/latest/command/project.html
警告の内容に従って、project() -Wno-devを使っています。

PR の影響範囲

Visual Studio 2017でも問題ないようです。

ビルドしてテストしてみました。

テスト内容

テスト1

手順

関連 issue, PR

参考資料

@dep5
Copy link
Contributor Author

dep5 commented May 31, 2022

この警告の有無でVSがどのバージョンか見分けていましたが、
対応することにしました。

サクラエディタ全体のCMakeではないと思うので、関数名を書いておきましたが
PROJECT_NAMEはこれでいいのでしょうか?

"-DCMAKE_C_COMPILER=%CL_COMPILER%"
は残しておいたほうがいいのでしょうか?

@AppVeyorBot
Copy link

Build sakura 1.0.4138 failed (commit 1a043c6d51 by @dep5)

@sanomari
Copy link
Contributor

sanomari commented Jun 1, 2022

対処方法が誤っているように見えました。

2>CMake Warning (dev) in CMakeLists.txt:
2> No project() command is present. The top-level CMakeLists.txt file must
2> contain a literal, direct call to the project() command. Add a line of
2> code such as
2>
2> project(ProjectName)
2>
2> near the top of the file, but after cmake_minimum_required().
2>
2> CMake is pretending there is a "project(Project)" command on the first
2> line.
2>This warning is for project developers. Use -Wno-dev to suppress it.

正しい対処は最後の一文「Use -Wno-dev to suppress it.」です。

ここのCMakeLists.txtは成果物を作らないので、projectを呼ばなくてもよいです。
「呼ばなくても良い」を分かったうえでprojectしたい場合、格納フォルダ名を指定してprojectします。
このPRでは違う名前を付けようとしてるので、そこも違う気がします。

バッチの修正は、明らかに使ってないので問題ないです。

@dep5
Copy link
Contributor Author

dep5 commented Jun 9, 2022

sanomari さん
コメントありがとうございます。
アドバイスに従って書き直してみたところ、
"-DCMAKE_C_COMPILER=%CL_COMPILER%"があっても警告が出なくなったので
元に戻しておきました。
必要な警告まで消えてしまうのではないかと心配ですが、
もともと警告を消したいというPRでしたね…

@AppVeyorBot
Copy link

Build sakura 1.0.4143 completed (commit 973d463a08 by @dep5)

@sonarcloud
Copy link

sonarcloud bot commented Jun 9, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@dep5 dep5 marked this pull request as ready for review June 10, 2022 12:32
Copy link
Contributor

@beru beru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beru beru merged commit cac7829 into sakura-editor:master Jun 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants