db_files.cmake 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Funtion to add db files to the target kamctl/kamdbctl
  2. # It takes the group name, the file name and a boolean to determine if it is for kamctl or kamdbctl
  3. # It processes the file with sed and installs it to the correct location
  4. # Used by the helper function add_kamctl_db_files and add_kamdbctl_db_files
  5. function(add_db_files group_name file kamctl)
  6. # message(WARNING "file name is ${file}")
  7. # message(WARNING "group name is ${group_name}")
  8. # Process the file with sed and install it
  9. add_custom_command(
  10. OUTPUT "${CMAKE_BINARY_DIR}/utils/kamctl/${file}"
  11. COMMAND sed -e "s#/usr/local/sbin#${BIN_DIR}#g" < ${CMAKE_SOURCE_DIR}/utils/kamctl/${file} >
  12. ${CMAKE_BINARY_DIR}/utils/kamctl/${file}
  13. COMMENT "Processed ${file} with sed "
  14. )
  15. # Append to the depependencies list for the target kamctl/kamdbctl respectively
  16. if(kamctl)
  17. add_custom_target(
  18. kamctl_${file}
  19. DEPENDS ${CMAKE_BINARY_DIR}/utils/kamctl/${file}
  20. COMMENT "Generating kamctl_${file}"
  21. )
  22. set_property(GLOBAL APPEND PROPERTY KAMCTL_DEPENDENCIES "kamctl_${file}")
  23. else()
  24. add_custom_target(
  25. kamdbctl_${file}
  26. DEPENDS ${CMAKE_BINARY_DIR}/utils/kamctl/${file}
  27. COMMENT "Generating kamctl_${file}"
  28. )
  29. set_property(GLOBAL APPEND PROPERTY KAMDBCTL_DEPENDENCIES "kamdbctl_${file}")
  30. endif()
  31. install(
  32. PROGRAMS ${CMAKE_BINARY_DIR}/utils/kamctl/${file}
  33. DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MAIN_NAME}/kamctl
  34. COMPONENT ${group_name}
  35. )
  36. endfunction()
  37. # Helper functions to add kamctl releated db files
  38. # Used by utils/kamctl/CMakeLists.txt for the core kamctl files
  39. # and by modules/db_{module_name}/CMakeLists.txt for the module specific kamctl files
  40. function(add_kamctl_db_files group_name file)
  41. add_db_files(${group_name} ${file} 1)
  42. endfunction()
  43. # Helper functions to add kamdbctl releated db files
  44. # Used by utils/kamctl/CMakeLists.txt for the core kamctl files
  45. # and by modules/db_{module_name}/CMakeLists.txt for the module specific kamdbctl files
  46. function(add_kamdbctl_db_files group_name file)
  47. add_db_files(${group_name} ${file} 0)
  48. endfunction()