-
Notifications
You must be signed in to change notification settings - Fork 380
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: make conan optional #877
Conversation
4e6635e
to
e932625
Compare
Thanks for the PR!! |
@atilag the use case is in the PR summary. Both distro packaging and assuming an internet connection (both concerns I have outlined before). There are all also platforms where conan doesn't work like emscripten (which is why I opened #757 ), and systems where conan doesn't behave as expected like gcc 10 on my laptop. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a quick glance this lgtm, the only thing I think would be useful here is to add an env var that exposes this option too. There are some build envs (looking at pip mostly) where passing in the cmake flags directly isn't available and enabling this via an env var is useful for those situations.
e932625
to
7aa36d8
Compare
Precedence of environment variable is enforced by CMake policy CMP0077.
7aa36d8
to
33e2f11
Compare
@mtreinish added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drewrisinger Thanks for the PR!!
Some things:
-
Be aware that not all dependencies are needed depending on what you compile. For example muparserx is not needed if you compile the satandalone version, llvm-openmp is only needed for clang on macos if i recall correctly, etc.
-
Given a build path, Cmake should fail if some library is not found, to avoid failing later at compilation time.
-
We need to think of a mechanism to collect all the dependencies needed (with conan or not) and then use them avoiding if possible all the if(USE_CONAN) constructs.
-
If a package does not provide its own FindLIB.cmake, it's gonna fail, but I think it's ok. The user should be responsible for providing all external things. For example,I think, TBB didn't provide one.
-
I think there are also things to change in test/CMakeLists.txt
-
Right now, in Linux, I haven't been able to compile any of the
Thrust
backends. In Cuda I remember some problems withnvcc
unable to compile modernnlohmann
libraries. I haven't tried yet Windows or Macos
These are things to consider, we have to see how to solve, but again, thanks for contributing with this PR!!!
CMakeLists.txt
Outdated
find_package(muparserx REQUIRED) | ||
find_package(nlohmann_json REQUIRED) | ||
find_package(spdlog REQUIRED) | ||
|
||
# Multiprocessing/Thrust libraries | ||
find_package(llvm-openmp) | ||
find_package(tbb) | ||
|
||
# for tests only | ||
find_package(catch2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these dependencies are only needed for certain build paths. For example, muparserx
is only needed for the python addon, but not for the standalone version. llvm-openmp
is only needed in Macos , etc. Ideally we should define which dependencies we really need depending on the build and then find them with conan or without it.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CONAN_CXX_FLAGS_LLVM-OPENMP}") | ||
set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_LLVM-OPENMP}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Careful, here we are setting some flags and include dirs coming from Conan
I'm concerned about the approach taken here.
@drewrisinger thank you very much for jumping in into this! I really do appreciate it. If you want to try implementing this approach, I'll be glad to mentor you during the process. @vvilpas Thoughts? |
Thanks for your comments regarding a better, less hacky approach @atilag.
I haven't tried that myself. I've mostly tried to get the base python package compiling. Based on comments above, I see the TODO list as:
|
I agree. That's what I meant, although I didn't go into detail, with this:
I think we should do it in two steps in that
The build system is kind of complex so maybe a total isolation is not possible, but let's try. |
I think this is the only CMakeLists.txt file that we don't need to change.
Yes, just to clarify. We may not need to actually change conan_utils.cmake, but adding two new files:
|
Env variable usage come after option declaration.
First pass, still has some bugs on non-Conan.
Uses shared AER_DEPENDENCY_PKGs, instead of solely from Conan. Remove explicit USE_CONAN language.
Found it's better to use IMPORTED INTERFACE vs ALIAS. ALIAS would sometimes fail on packages unexpectedly.
Macro makes it a lot clearer to understand what's happening.
Allow disabling conan import checks entirely with environment variable USE_CONAN. Allows conan not to be installed at all.
Required packages for setup should really be handled by pyproject.toml and setup_requirements. This removes the default calls to ``pip install MODULE``, which are unintuitive and potentially undesired for modifying your environment without prompting.
I will rebase and squash before this is ready to merge, but it's mostly done, and I wanted to get some feedback. TODO:
|
Fix reversion that wasn't 100%
@drewrisinger Thanks for pushing this! |
Hi @drewrisinger! I am making some progress on this. Let me know if you want to keep going with this or you are busy with other things. |
@vvilpas feel free. I pushed the most recent changes I made (lastest ~1 month ago), I've been busy with other higher-priority projects recently. thanks for taking this up! |
ok. I'm closing this one and keep working on #999 (with all changes on this PR). Thanks for all the work @drewrisinger ! |
Summary
This allows Conan to be an optional dependency. Conan requires an internet connection to build, and is meant for replicating development environments and not for downstream packaging. It also does not allow using the existing libraries in your system, e.g.
muparserx
(https://aur.archlinux.org/packages/muparserx/).Details and comments
This is useful for having a single option for disabling Conan in the build system, instead of patching CMakeLists.txt.
This isn't the prettiest solution, and I'm not super familiar with CMake files, so I'm open to suggestions. The downside of this is that it doesn't do any version checking on the packages that it finds, which is probably not a great practice.
Fixes #757