-
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 #999
Conversation
Precedence of environment variable is enforced by CMake policy CMP0077.
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.
Fix reversion that wasn't 100%
Ready for review. I can build now on linux and macos without conan. |
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.
LGTM!
Haven't seen any blockers, just left some comments that could be addressed later.
@@ -1,33 +1,46 @@ | |||
include(conan) | |||
|
|||
macro(_rename_conan_lib package) | |||
add_library(AER_DEPENDENCY_PKG::${package} INTERFACE IMPORTED) |
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.
oh! nice hack! :)
|
||
set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} ${CONAN_DEFINES}) | ||
# Cython build is only enabled if building through scikit-build. | ||
if(SKBUILD) # Terra Addon build | ||
set(AER_LIBRARIES ${AER_LIBRARIES} CONAN_PKG::muparserx) | ||
set(AER_LIBRARIES ${AER_LIBRARIES} AER_DEPENDENCY_PKG::muparserx) |
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.
This is probably on me, but I'm wondering if we should be using list()
here instead of set()
, we are using list()
in other places for appending libraries (see AER_CONAN_LIBS
usage), also feels more semantically correct. Thoughts?
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.
BTW, I think I started to use set()
instead of list()
due to some misbehavior in CMake, I just can't recall exactly which one. If list()
works and covers our use-cases then go to list()
. Maybe in another PR with a "Good Fist Issue" tag?.
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.
yeah, i think list is the way to go. We can check that it works and and replace all those sets.
@@ -320,9 +331,9 @@ else() # Standalone build | |||
PRIVATE ${AER_COMPILER_DEFINITIONS}) | |||
if(WIN32 AND NOT BLAS_LIB_PATH) |
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.
Also wondering if we can simplify the BLAS_LIB_PATH
logic now that we have a way to disable Conan.
I'm concerned about the complexity of the build system in general, and having a way to skip over BLAS, and skip over everything else looks confusing, doesn't it?.
What about removing the BLAS_LIB_PATH
and if someone wants to build with their own BLAS, force them to go through the disable Conan path?. Certainly it will require them to have not just BLAS but every dependency installed.
Thoughts?
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.
Not sure, because this was requested in order to use the same BLAS
library as the one Numpy
uses. So probably not in the usual paths where CMake will look for. Not sure if this option is very used, though.
But yeah, I agree, the build system is quite complex.
_rename_conan_lib(${CONAN_LIB}) | ||
endforeach() | ||
|
||
if(APPLE) |
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.
At some point we'll need to review this. Maybe it's been fixed with current versions of Clang?
endif() | ||
|
||
if(APPLE) | ||
# Fix linking. See https://stackoverflow.com/questions/54068035 |
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.
Really? :(
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.
Sometimes MacOS platform is so unpleasant for system devs :(
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.
Maybe there are better ways to do this, but that's the way that I found. :(
Co-authored-by: Drew Risinger <[email protected]>
Co-authored-by: Drew Risinger <[email protected]>
Co-authored-by: Drew Risinger <[email protected]>
Co-authored-by: Drew Risinger <[email protected]>
Quoting original PR creator (#877):
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
Continues work started on #877 by drewrisinger