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: make conan optional #999

Merged
merged 30 commits into from
Nov 4, 2020
Merged

Conversation

vvilpas
Copy link
Contributor

@vvilpas vvilpas commented Oct 20, 2020

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

drewrisinger and others added 18 commits August 11, 2020 09:37
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%
@vvilpas vvilpas changed the title [WIP] CMake: make conan optional Cmake: make conan optional Oct 26, 2020
@vvilpas
Copy link
Contributor Author

vvilpas commented Oct 26, 2020

Ready for review. I can build now on linux and macos without conan.

@chriseclectic chriseclectic added this to the Aer 0.8 milestone Oct 30, 2020
Copy link
Member

@atilag atilag left a 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)
Copy link
Member

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)
Copy link
Member

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?

Copy link
Member

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?.

Copy link
Contributor Author

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)
Copy link
Member

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?

Copy link
Contributor Author

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)
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? :(

Copy link
Member

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 :(

Copy link
Contributor Author

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. :(

@chriseclectic chriseclectic merged commit 721fcb4 into Qiskit:master Nov 4, 2020
@mtreinish mtreinish mentioned this pull request Dec 6, 2020
chriseclectic pushed a commit to chriseclectic/qiskit-aer that referenced this pull request Dec 11, 2020
chriseclectic pushed a commit to chriseclectic/qiskit-aer that referenced this pull request Dec 11, 2020
@chriseclectic chriseclectic added the Changelog: New Feature Include in the Added section of the changelog label Dec 11, 2020
chriseclectic pushed a commit to chriseclectic/qiskit-aer that referenced this pull request Jan 25, 2021
chriseclectic pushed a commit to chriseclectic/qiskit-aer that referenced this pull request Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the Added section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to build without conan and document it
4 participants