Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the target to be run automatically #2

Open
flagarde opened this issue Jan 13, 2022 · 1 comment
Open

Allow the target to be run automatically #2

flagarde opened this issue Jan 13, 2022 · 1 comment

Comments

@flagarde
Copy link

It would be nice to add an option to add the ALL keyword on the target options to allow it to be run automatically and maybe add an install path relative '${CMAKE_INSTALL_DOCDIR}'.

Something like this pseudo-code?

function(cpm_licenses_create_disclaimer_target TARGET_NAME FILE_NAME PACKAGES)
  cmake_parse_arguments(ARGS "ALL" "PATH" "" ${ARGN})
  set(PACKAGE_SOURCES "")
  foreach(package ${PACKAGES})
    cpm_get_fetch_properties(${package})
    list(APPEND PACKAGE_SOURCES "-D${package}_SOURCE_DIR=\"${${package}_SOURCE_DIR}\"")
  endforeach()

  if(ARGS_ALL)
  add_custom_target(
    ${TARGET_NAME} ALL
    COMMAND
      ${CMAKE_COMMAND} -DPRINT_license_FILE_NAME=${FILE_NAME}
      "-DPRINT_license_PACKAGES=\"${PACKAGES}\"" ${PACKAGE_SOURCES} -P ${CPMlicenses_SCRIPT_PATH}
  )
else()
  add_custom_target(
    ${TARGET_NAME} ALL
    COMMAND
      ${CMAKE_COMMAND} -DPRINT_license_FILE_NAME=${FILE_NAME}
      "-DPRINT_license_PACKAGES=\"${PACKAGES}\"" ${PACKAGE_SOURCES} -P ${CPMlicenses_SCRIPT_PATH}
  )
endif()
INSTALL(FILES ${FILE_NAME} DESTINATION "${CMAKE_INSTALL_DOCDIR}/${ARGS_PATH}")
endfunction()
@TheLartians
Copy link
Member

Hey thanks for the issue, I agree that would be a useful addition!
I think in the second branch we should omit the ALL, but feel free to open a PR for a thorough review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants