尝试使用 cmake 在 windows 上构建 mbedtls

trying to build mbedtls on windows using cmake

我正在使用 cmake 尝试构建 mbedtls。我从 github 获得了 .zip,解压它,然后我“cd”进入 mbedtls 目录。

我遇到了这样的错误,无论我在 subdirectory/directory 中输入什么,我都无法成功构建它。 命令: cmake Visual Studio 10 .

CMake Error at CMakeLists.txt:172 (add_library):
  Cannot find source file:

    error.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx


CMake Error at CMakeLists.txt:172 (add_library):
  No SOURCES given to target: mbedcrypto

这是我所在的目录。所有 subdirectories/cmake 文件都在那里。我的问题是...如何在 windows 上构建 mbedtls?

获取 release 而不是开发分支的快照。

或者,在 3.0+ 开发分支中,根据 readme:

The source code of Mbed TLS includes some files that are automatically generated by scripts and whose content depends only on the Mbed TLS source, not on the platform or on the library configuration. These files are not included in the development branch of Mbed TLS, but the generated files are included in official releases. (…)

之前 运行 cmake,

On Windows, run scripts\make_generated_files.bat to generate all the configuration-independent files.

这需要 perlpython 和 C 编译器。您可能需要将 CC 环境变量设置为从 Visual Studio.

cl.exe 的路径

这个序列对我有用 Windows:

D:\>git clone git@github.com:ARMmbed/mbedtls.git
D:\>cd mbedtls
D:\mbedtls>scripts\make_generated_files.bat
...
D:\mbedtls>cd ..
D:\>cmake -G "Visual Studio 16 2019" -S mbedtls -B mbedtls-build
...
D:\>cmake --build mbedtls-build --config Release
...
D:\>cmake --install mbedtls-build --config Release --prefix mbedtls-install
...

这里唯一的非标准步骤是 scripts\make_generated_files.bat(或 Linux 上的 /tests/scripts/check-generated-files.sh -u)。有人想知道为什么他们不包括将这些文件构建为 CMake 自定义命令的步骤.../shrug