diff options
author | Matthew Woehlke <matthew.woehlke@kitware.com> | 2016-05-09 18:59:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-06-07 12:50:35 (GMT) |
commit | 5341c0d84af50c2ac5e4041885ab96f8d157ddfe (patch) | |
tree | 8ea8229c3c841426982556af557b8dada321a87e /Modules/javaTargets.cmake.in | |
parent | d91ec04402bce94cb29662e0de548438876d86d5 (diff) | |
download | CMake-5341c0d84af50c2ac5e4041885ab96f8d157ddfe.zip CMake-5341c0d84af50c2ac5e4041885ab96f8d157ddfe.tar.gz CMake-5341c0d84af50c2ac5e4041885ab96f8d157ddfe.tar.bz2 |
UseJava: Add infrastructure to export targets
Add additional functions to UseJava.cmake to create "exported" targets,
similar to those of C/C++ libraries. In support of this, ensure that the
JAR_FILE property of jar targets is always an absolute path.
Diffstat (limited to 'Modules/javaTargets.cmake.in')
-rw-r--r-- | Modules/javaTargets.cmake.in | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Modules/javaTargets.cmake.in b/Modules/javaTargets.cmake.in new file mode 100644 index 0000000..c5f9c78 --- /dev/null +++ b/Modules/javaTargets.cmake.in @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 2.8) +cmake_policy(PUSH) +cmake_policy(VERSION 2.8) + +#---------------------------------------------------------------- +# Generated CMake Java target import file. +#---------------------------------------------------------------- + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget @__targets__@) + list(APPEND _expectedTargets ${_expectedTarget}) + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + else() + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() +endforeach() +if("%${_targetsDefined}" STREQUAL "%${_expectedTargets}") + unset(_targetsDefined) + unset(_targetsNotDefined) + unset(_expectedTargets) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR + "Some (but not all) targets in this export set were already defined.\n" + "Targets Defined: ${_targetsDefined}\n" + "Targets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + +@__targetdefs__@ +cmake_policy(POP) |