Menu

assimp-config-version.cmake not processing versions correctly.

Vinnie
2017-04-05
2017-04-05
  • Vinnie

    Vinnie - 2017-04-05

    Hi Guys

    When I specify the find package version as 3.3 for assimp in cmake, it complain that a compatible version of the library can not be found. The exact line is:

    find_package(assimp 3.3 CONFIG REQUIRED PATH_SUFFIXES "/cmake/assimp-3.3")

    The cmake output is:

    CMake Error at CMakeLists.txt:6 (find_package):
      Could not find a configuration file for package "assimp" that is compatible
      with requested version "3.3".
    
      The following configuration files were considered but not accepted:
    
        C:/Development/Libraries/lib64/cmake/assimp-3.3/assimp-config.cmake, version: 3.3.1
    

    It seems that there is a check for exact required version (which include patch number), i.e. 3.3.1. A check for compatible version, where the required version must be < 3.3 (but does not include version 3.3). However there is no check for just the current Major.Minover version, i.e. version 3.3.

    On line 9 of the assimp-config-version.cmake.in file there is a check that reads:

    if( ${PACKAGE_FIND_VERSION_MINOR} LESS @ASSIMP_VERSION_MINOR@ )

    Without any other checks, this does not allow for the case where only the major and minor version is specified. (It seems rare that someone will also specify a patch version unless a very specific bug has been fixed.) I believe the line should be changed to:

    if( ${PACKAGE_FIND_VERSION_MINOR} EQUAL @ASSIMP_VERSION_MINOR@ OR ${PACKAGE_FIND_VERSION_MINOR} LESS @ASSIMP_VERSION_MINOR@ )

    This result in compatibility checks where minimum compatible required version is <= 3.3 instead of < 3.3. With this change, when a user specify 3.3.1 for the version, then PACKAGE_VERSION_EXACT is set to 1. If the user specify the version 3.3, then the PACKAGE_VERSION_COMPATIBLE is set to 1. (With this modification cmake is able to find assimp 3.3 and the program compile and run.)

    I believe the modded version of line 9 is how it should behave?

    Cheers
    -Vinnie

     
  • Vinnie

    Vinnie - 2017-04-06

    I've noticed there is actually a check on line 5 of assimp-config-version.cmake.in that reads:

    if( "${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}" EQUAL "@ASSIMP_SOVERSION@" )
    

    This seems like it should be populated with 3.3 which should also resolve the issue as decribed above. It is however just populated with 3. Tracing the ASSIMP_SOVERSION variable back to the main CMakeLists.txt file, you can see it being set on line 52 with:

    SET (ASSIMP_SOVERSION 3)
    

    I'm guessing that this should perhaps be:

    SET (ASSIMP_SOVERSION 3.3)
    

    or a more automatic version:

    SET (ASSIMP_SOVERSION "${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}")
    

    This also fixes the issue for me with correctly identifying compatible assimp versions.

    Based on the cmake documentation regarding SOVERSION it seems like what was intended from the start:

    For shared libraries and executables on Windows the VERSION attribute is parsed to extract a “major.minor” version number.

     
  • Kim Kulling

    Kim Kulling - 2017-04-06

    Thank you very much for figuring this out! The bug should be fixed on the latest master now.

    Kimmi

     
  • Vinnie

    Vinnie - 2017-04-06

    no worries. :)

     

Log in to post a comment.