mutationpp / Mutationpp

The MUlticomponent Thermodynamic And Transport library for IONized gases in C++
GNU Lesser General Public License v3.0
108 stars 58 forks source link

Installation issues #79

Closed VincentFitzgeraldGiangaspero closed 5 years ago

VincentFitzgeraldGiangaspero commented 5 years ago

Dear all,

I'm having troubles installing the latest release of mutationpp both on Mac OSX and Linux. I think some new informations are missing from the installation instructions guide.

I think the issue is related to Eigen3 and the install dependencies file ( install_dependencies.py) that is now missing from the package.

Eigen3_DIR Eigen3_DIR-NOTFOUND
Eigen3_INCLUDE_DIR $MPP_DIRECTORY/thirdparty/eigen

The effect is that I can't find most of the headers I need under $MPP_DIRECTORY/install/include/mutation++

I post this issue here as @rubendibattista suggested

Thank you

rdbisme commented 5 years ago

Sorry for getting back to you late.

I imagine you already read the coupling short doc. (@jbscoggi shouldn't this be in the Wiki? I cannot find it).

The problem with Eigen3 dependency is that it's a PUBLIC dependency of mutation++ that needs to be propagated downstream when you include mutation++ in another project since this project needs to be able to locate Eigen3 headers. I did not find a smarter way of covering this and cmake does not provide a way of automatically propagating it (yet?).

So long story short, you need to provide a FindEigen3.cmake file in your cmake modules of your project in order to find Eigen3 again when linking your project against mutation++.

This is what we're using in our solver:

# Distributed under the BSD 2-clause License

# FindEigen
# --------
#
# Find Eigen header-only library
#
# This module tries before to search for cmake-exported configuration files
# using the standard 
#
# This module sets the following variables:
#
# ::
#
#   Eigen_FOUND - set to true if a library implementing the BLAS interface
#     is found
#
#   Eigen_INCLUDE_DIRS - the directory containing the Eigen header files
#
# 
# To give an hint for the directory to look for the user must set Eigen3_DIR
#
#
# Author: Ruben Di Battista <rubendibattista@gmail.com>

message(STATUS "Searching for Eigen3...")

set(Eigen3_CHECK_PATHS 
    "/usr/local/include"
    "/usr/local/homebrew/include" # Mac OS X
    "/opt/local/var/macports/software" # Mac OS X.
    "/opt/local/include"
    "/usr/include"
    "$ENV{CPLUS_INCLUDE_PATH}"
    "$ENV{CPATH}"
    "${CMAKE_SOURCE_DIR}/thirdparty/eigen"
    )

# First try to use the standard find_package that should be able to find the
# .cmake configuration files if installed in standard directories. 

# Saveup Eigen3_DIR since the CONFIG overwrites it
set(TEMP_Eigen3_DIR ${Eigen3_DIR})
find_package(Eigen3 QUIET CONFIG)

if (NOT Eigen3_FOUND)
    # Restore
    set(Eigen3_DIR ${TEMP_Eigen3_DIR})
    # Standard stuff did not work, so we try to locate Eigen3 in include paths
    find_path(Eigen3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
        HINTS 
            ${Eigen3_DIR}
            ${Eigen3_DIR}/include
        PATHS ${Eigen3_CHECK_PATHS}
        PATH_SUFFIXES eigen3 Eigen eigen Eigen3
    )

    if (Eigen3_INCLUDE_DIR)
        # We found the include dir, we add it to the standard variable
        # ${<library>_INCLUDE_DIRS}
        set (EIGEN3_INCLUDE_DIRS ${Eigen3_INCLUDE_DIR})
    endif (Eigen3_INCLUDE_DIR)
endif (NOT Eigen3_FOUND)

# Handle REQUIRED/QUIET optional arguments
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen3
    REQUIRED_VARS 
        EIGEN3_INCLUDE_DIRS
)

if(Eigen3_FOUND AND NOT TARGET Eigen3::Eigen)
    add_library(Eigen3::Eigen INTERFACE IMPORTED)
    set_target_properties(Eigen3::Eigen PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES "${EIGEN3_INCLUDE_DIRS}"
    )
endif()

Please let me know if it does fix your problem.

I'll try to see if I can somehow insert at configuration time inside the mutation++Config.cmake the path of the already found Eigen3 in order to allow downstream projects to not require to find it back.

Let me know if you succeed.

rdbisme commented 5 years ago

To add additional details: Eigen is an header-only library, but new versions of it install correctly a Eigen3config.cmake file in the system. So if you compile mutation++ against a system-wide installed version of Eigen, you should not encounter any problems since cmake should be able to locate it correctly.

Now, if you install mutation++ using its own version of Eigen (stored in the thirdparty folder), then you don't have a way of locating Eigen automatically and that's why you need the FindEigen3.cmake module. The FindEigen3.cmake package I posted before should be able to cope with this different situations.

If you have any suggestion on how to handle this better, feel free to comment down below.

jbscoggi commented 5 years ago

Hey @vincentfitz, is this problem solved for you? If so, I will close the issue.

VincentFitzgeraldGiangaspero commented 5 years ago

Yes at the moment is partially solved. I’m able to install and plug Mutation++ to my CFD solver but I had to manually set the CMAKE_INSTALL_PREFIXl path to something different from /usr/local and manually move the Eigen folder to install/include/mutation++ I understand that this issue is due to an out-of-date configuration script of COOLFluiD that doesn’t automatically detect Eigen location.

Sorry for the late answer

Cheers

Vincent

On 9 Jul 2019, at 09:18, J.B. Scoggins notifications@github.com wrote:

Hey @vincentfitz https://github.com/vincentfitz, is this problem solved for you? If so, I will close the issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mutationpp/Mutationpp/issues/79?email_source=notifications&email_token=AJT45KNEPQ4CDLI6A2ZZ723P6Q3VHA5CNFSM4HS4YZW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZPK6RY#issuecomment-509521735, or mute the thread https://github.com/notifications/unsubscribe-auth/AJT45KIC6YKSTSYFZ3AXZE3P6Q3VHANCNFSM4HS4YZWQ.