OpenVPN / openvpn

OpenVPN is an open source VPN daemon
http://openvpn.net
Other
10.75k stars 2.99k forks source link

MinGW builds (cross-compile on Linux): execute cmake --preset mingw-x64 error #489

Closed fanzhengweiwudi closed 7 months ago

fanzhengweiwudi commented 8 months ago

root@zh-KVM:~/mingw/openvpn# cmake --preset mingw-x64 CMake Error: The source directory "/root/mingw/openvpn/mingw-x64" does not exist. Specify --help for usage, or press the help button on the CMake GUI.

flichtenheld commented 8 months ago

What cmake version is that? That error sounds like it doesn't know about CMakePresets.json, yet...

cmake --version ?

fanzhengweiwudi commented 8 months ago

root@zh-KVM:~# cmake --version cmake version 3.16.3

CMake suite maintained and supported by Kitware (kitware.com/cmake). root@zh-KVM:~#

fanzhengweiwudi commented 8 months ago
root@zh-KVM:~/mingw/openvpn# uname -a
Linux zh-KVM 5.15.0-92-generic #102~20.04.1-Ubuntu SMP Mon Jan 15 13:09:14 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
flichtenheld commented 8 months ago

Hi. According to https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html CMakePreset.json support was added in 3.19. We use a version 3 CMakePreset.json, which further increases the required version to 3.21. Your CMake is just too old.

We definitely should document this in the README file, but other than that I can only recommend to update your CMake (and your Ubuntu, actually). Ubuntu 22.04 has CMake 3.22.1 which works fine.

chipitsine commented 8 months ago

we might add cmake_minimum_required(VERSION 3.21) to CMakeLists.txt

flichtenheld commented 8 months ago

we might add cmake_minimum_required(VERSION 3.21) to CMakeLists.txt

Yes, but CMakeLists.txt doesn't actually require 3.21. I think the current cmake_minimum_required is correct. Only the CMakePreset.json and cmake --preset need 3.21. The real problem here is that old versions of CMake do not seem to have a proper "unknown argument --preset" error message. Newer versions are improved in that area as well.

chipitsine commented 8 months ago

as long as they fail on cmake_minimum_required check, it should be fine.

@fanzhengweiwudi , can you check mentioned change with your cmake ?

flichtenheld commented 8 months ago

Again, I think cmake_minimum_required as it currently is set (3.14) is correct in that cmake can correctly work with the CMakeLists.txt files. So I would just update the documentation for the MSVC and MinGW builds, like so: https://patchwork.openvpn.net/project/openvpn2/patch/20240201123039.174176-1-frank@lichtenheld.com/

flichtenheld commented 7 months ago

I consider this resolved with release of 2.6.9 which includes the documentation updates.