I tested 2 options with name and no NAMES and with NAMES name 1 and no name and both work fine with name /name1 not having not only extension .jar but even with just a firts several characters in the name. Then find_jar finds full path to ext.jar ok. So I suggest documentation is updated.
Still the following questions remain:
- How do I find all instances of .jar files under the PATHS when multiple .jar files are there and form/fill a list variable
- In case .jar file is not built with cmake (e.g. built with maven), but need to be installed and therefore install(PROGRAMS is being used for installation, how to ensure the downstream consumers of my library and the jar file be able to find it ? How to ensure the myprojConfigure.cmake file I generate during cmake build has appropriate path for jar file not my own host path to .jar
Attempt to
find_jar(extJar …
add_custom_target(extJartarget ALL
DEPENDS ${extJar} # File level dep-y so must b file not target
)
set_property(TARGET extJartarget PROPERTY
INSTALL_FILES
${CMAKE_SOURCE_DIR}/mvngened/ext.jar
)
install(TARGETS extJartarget
EXPORT extJartargetExpname
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT RunTimeJar
)
gives error
install TARGETS given target “extJartarget” which is not an executable,
library, or module. <-yes itis .jar, so?>
Alternative installation works with install(PROGRAMS ${extJar} … installs file ok, but it does not create target statement in the myprojConfigure.cmake as my other libraries installed with install(TARGETS , install(EXPORT do.
adding set_target_properties(extJartarget
PROPERTIES EXPORT_NAME myOtherExpedTargets) does not help
install_jar does install .jar despite there call to add_jar (contradictory to documentation?) However I wish it would be possible to add external .jar to target list as with any executable.
Here is relevant post: How to install custom target - What is controlling enablement of the set(CMAKE_FIND_DEBUG_MODE TRUE) . I observe it is working on a fresh install-build but then it stop generating debug output for find_jar /fin_path