[CMake] Problems to find xmlrpc_server_abyss++.so on FreeBSD

Michael Hertling mhertling at online.de
Tue Nov 30 20:21:57 EST 2010


On 11/30/2010 12:27 AM, Renato Botelho wrote:
> On Mon, Nov 29, 2010 at 9:20 PM, Renato Botelho <rbgarga at gmail.com> wrote:
>> Hi,
>>
>> It's the first project i'm migrating from autotools to cmake,
>> and it's going really well, in 4 days it's almost done. \o/
>>
>> The only issue I have now is following, i have this code
>> on my CMakeLists.txt:
>>
>> find_package (XMLRPC REQUIRED abyss-server c++2)
> 
> It's always the same, one entire day trying to figure it out and
> 5 seconds after sending this email i found, i just changed the
> order of components (c++2 abyss-server) and it detected my
> xmlrpc fine. It's fixed now. The other problem below still persists.
> 
>> Ah, since i'm talking about FindXMLRPC, I used REQUIRED
>> param, like i showed above, but if it doesn't find xmlrpc
>> it shows an error message but don't stop, i needed to add
>> this:
>>
>> if (NOT XMLRPC_FOUND)
>>  message (FATAL_ERROR "XMLRPC-C not found")
>> endif (NOT XMLRPC_FOUND)
>>
>> Is it the expected behavior?
> 
> It persists

AFAICS, this is due to the last code snippet in FindXMLRPC.cmake:

# Report the results.
IF(NOT XMLRPC_FOUND)
  SET(XMLRPC_DIR_MESSAGE
    "XMLRPC was not found. Make sure the entries XMLRPC_* are set.")
  IF(NOT XMLRPC_FIND_QUIETLY)
    MESSAGE(STATUS "${XMLRPC_DIR_MESSAGE}")
  ELSE(NOT XMLRPC_FIND_QUIETLY)
    IF(XMLRPC_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "${XMLRPC_DIR_MESSAGE}")
    ENDIF(XMLRPC_FIND_REQUIRED)
  ENDIF(NOT XMLRPC_FIND_QUIETLY)
ENDIF(NOT XMLRPC_FOUND)

If XMLRPC_FOUND is FALSE the MESSAGE(FATAL_ERROR ...) is emitted only
if XMLRPC_FIND_REQUIRED is TRUE - that's OK - and XMLRPC_FIND_QUIETLY
is TRUE also - which is wrong. IMO, the REQUIRED flag must absolutely
take precedence over the QUIET flag, e.g.:

IF(NOT XMLRPC_FOUND)
    IF(XMLRPC_FIND_REQUIRED)
        MESSAGE(FATAL_ERROR ...)
    ELSEIF(NOT XMLRPC_FIND_QUIETLY)
        MESSAGE(STATUS ...)
    ENDIF()
ENDIF()

This is the pattern used by FIND_PACKAGE_HANDLE_STANDARD_ARGS(), too.
As it's done currently in FindXMLRPC.cmake, you must enable REQUIRED
*and* QUIET to make the find module bail out *with* a message if the
package hasn't been found.

As a general interpretation of the REQUIRED flag, the user does not
want to check whether the package has been found if FIND_PACKAGE()
returns, or vice versa: If there is any need to check whether the
requested stuff is actually present, the REQUIRED flag is useless.
In particular, this should apply also to the components of multi-
component packages.

Feel encouraged to file a bug report.

Regards,

Michael


More information about the CMake mailing list