dacap / vaca

C++ Win32 wrapper to develop GUI apps
https://github.com/dacap/vaca/wiki
MIT License
99 stars 20 forks source link

CMakeLists.txt : target_compile_features no longer work as expected #9

Closed ghost closed 1 year ago

ghost commented 1 year ago

target_compile_features(vaca PUBLIC cxx_std_14) will no longer work as you expected. When you wrote this line C++14 was the latest, but now it's C++17 or even C++20. For example, the GCC 12.2.0 compiler of MSYS2 MINGW64 targets C++17 by default. Since C++17 is greater than C++14 and cxx_std_14 means at least C++14 so -std=c++14 will not be added and it will default to C++17. There will be warning about the register keyword is not allowed on C++17.

https://cmake.org/cmake/help/latest/command/target_compile_features.html

The solution as the document said is explicitly forcing C++14 with:

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)

The target_compile_features line could be removed.

dacap commented 1 year ago

Actually I'm used to CMAKE_CXX_STANDARD and CMAKE_CXX_STANDARD_REQUIRED in other of my libraries (clip) but I'm not sure why I used target_compile_features() here.

Anyway removing the usage of the old register keyword fixed some issues related to this.