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

CMake Build scripts and MSVC support #2045

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft

Conversation

Ryex
Copy link

@Ryex Ryex commented Mar 27, 2023

This PR adds CMake build scripts that mostly mirror the existing autotools build system.

It also contains some patches to support building under MSVC which was the reason the CMake build system was necessary.

This PR is initially marked as Draft because the build scripts could use some polishing. additionally they need testing across multiple systems and configurations to really validate their correctness.

For now I've tested them under Linux and windows 11 in a VM

Ryex added 22 commits March 24, 2023 10:08
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
generate config.h

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
aria2c now compiles under cmake (atleast under linux)

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
pullin the CRT equivalents for some things
ensure gai_strerror and getaddrinfo play nice
- MSVC needs a return value even with unreachable code
properly deal with extraldflags

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
checking for c functions with check_cxx_* can cause check to fail do to overloads
add static lib target

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
fix: set proper include dirs for static target
fix: cache all needed build vars so that a reconfig doesn't lose them
@kc991229
Copy link

kc991229 commented May 4, 2023

Hello, I built using cmake in Visual Studio, but unfortunately, it did not compile properly. The following error appears to be missing cx11_ Override.cc file:
CMakeLists. txt: 130 (try_compile): CMake Error:
The source directory "cx11_override.cc" does not exist

@Ryex
Copy link
Author

Ryex commented May 4, 2023

Hello, I built using cmake in Visual Studio, but unfortunately, it did not compile properly. The following error appears to be missing cx11_ Override.cc file: CMakeLists. txt: 130 (try_compile): CMake Error: The source directory "cx11_override.cc" does not exist

this appears to be a problem with your cmake install or your file permissions. the relevant lines in the cmake list

message(STATUS "Checking whether the C++ compiler supports `override` keyword")
set(_tmp_src
  "\
struct Base {
virtual void f() = 0;
};
struct Derived : Base {
virtual void f() override {}
};
int main(int argc, char* argv[]) {
  Derived x;
}
")
try_compile(CXX11_OVERRIDE
  SOURCE_FROM_VAR cx11_override.cc _tmp_src
)
unset(_tmp_src)

writes the file cx11_override.cc and tries to compile it to check the override keyword support.

you can pass --debug-trycompile to cmake to debug why that is failing

@zjq609177738
Copy link

Windows10 LSTC2019 : libgnutls libxml2 ...等几个依赖库 怎么配置 才能成功编译?
我使用cmake-gui 程序 构建项目时 ,总是在依赖库上出现问题,例如
CMake Error at cmake/FindCPPUNIT.cmake:52 (file):
file STRINGS file
"C:/Users/Administrator/Desktop/aria2-msvc-build/cppunit/include/cppunit/config-auto.h"
cannot be read.
还有这个
CMake Error at cmake/FindCPPUNIT.cmake:53 (string):
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
command.
.......
是我从github下载的依赖库不正确吗?
能否给个完整过程的cmake教程?

@ckJust
Copy link

ckJust commented May 16, 2024

image

@zjq609177738
Copy link

zjq609177738 commented May 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants