FindRadius.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. find_package(PkgConfig)
  2. # TODO: Discuss if other libraries are still used
  3. # - radiusclient library (probaly yes)
  4. # - radiusclient-ng library (probaly not)
  5. # Old makefile just defined the compile definitions whithout checking for
  6. # the library.
  7. # Modern cmake should check for the library and define the compile
  8. # definitions if the library is found.
  9. # Latest OS (Ubuntu) only offer radcli from package managemnt
  10. # Mutually exclusive options
  11. set(RADIUSCLIENTS FREERADIUS RADCLI RADIUSCLIENT_NG)
  12. set(RADIUSCLIENT
  13. RADCLI
  14. CACHE STRING "Locking method to use"
  15. )
  16. set_property(CACHE RADIUSCLIENT PROPERTY STRINGS ${RADIUSCLIENTS})
  17. # option(FREERADIUS "Use freeradius-client library" OFF)
  18. # option(RADCLI "Use radcli library" ON)
  19. # option(RADIUSCLIENT_NG "Use radiusclient-ng library" OFF)
  20. # if(FREERADIUS AND RADCLI)
  21. # message(FATAL_ERROR "Only one of FREERADIUS or RADCLI can be enabled")
  22. # endif()
  23. # Verify that the user-defined RADIUSCLIENT is valid
  24. if(NOT RADIUSCLIENT IN_LIST RADIUSCLIENTS)
  25. message(
  26. FATAL_ERROR
  27. "Invalid RADIUSCLIENT specified: ${RADIUSCLIENT}. Available options are: ${RADIUSCLIENTS}."
  28. )
  29. endif()
  30. if(${RADIUSCLIENT} STREQUAL "FREERADIUS")
  31. # - freeradius-client library
  32. set(RADIUSCLIENT_LIB "freeradius-client")
  33. pkg_check_modules(RADIUS REQUIRED IMPORTED_TARGET freeradius)
  34. elseif(${RADIUSCLIENT} STREQUAL "RADCLI")
  35. # - radcli library
  36. set(RADIUSCLIENT_LIB USE_RADCLI)
  37. pkg_check_modules(RADIUS REQUIRED IMPORTED_TARGET radcli)
  38. # Check for radiusclient-ng version
  39. # elseif(NOT radiusclient_ng STREQUAL "4")
  40. # # - radiusclient-ng v5 or v4 library
  41. # set(RADIUSCLIENT_LIB "radiusclient-ng")
  42. # Uncomment if needed
  43. # target_compile_definitions(MyModule PRIVATE RADIUSCLIENT_NG_5P)
  44. endif()