Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Adam <dev@robert-adam.de>2020-08-10 21:55:44 +0300
committerRobert Adam <dev@robert-adam.de>2020-08-10 21:57:39 +0300
commite0a27b1e7afea9318bb3c98e166f4952ea0113b0 (patch)
tree2a445c9125d126c87fde58c809bce1d51e0fb110 /cmake/project-utils.cmake
parente563b1f2a4683fd904f3c69bb1774549a1596359 (diff)
MAINT(cmake): Only return compilable targets
Without this change it could happen that get_targets returned non-compilable targets (e.g. install or uninstall targets) and this could lead to errors when e.g. trying to set compile options on those targets.
Diffstat (limited to 'cmake/project-utils.cmake')
-rw-r--r--cmake/project-utils.cmake11
1 files changed, 10 insertions, 1 deletions
diff --git a/cmake/project-utils.cmake b/cmake/project-utils.cmake
index 0991dfc08..8e1213264 100644
--- a/cmake/project-utils.cmake
+++ b/cmake/project-utils.cmake
@@ -28,6 +28,7 @@ endfunction()
# This function gets all defined targets in the given DIR or any of its
# subdirectories as returned by get_subdirectories. The found targets are
# written into DEFINED_TARGETS.
+# Note: Only return compilable targets
function(get_targets DEFINED_TARGETS DIR)
# First get all defined subdirectories
get_subdirectories(SUBDIRS "${DIR}")
@@ -43,7 +44,15 @@ function(get_targets DEFINED_TARGETS DIR)
# respective directory property.
foreach(CURRENT_SUBDIR IN LISTS SUBDIRS)
get_directory_property(NEW_TARGETS DIRECTORY "${CURRENT_SUBDIR}" BUILDSYSTEM_TARGETS)
- list(APPEND DEFINED_TARGETS ${NEW_TARGETS})
+
+ foreach(CURRENT_TARGET IN LISTS NEW_TARGETS)
+ get_target_property(TARGET_TYPE "${CURRENT_TARGET}" TYPE)
+
+ # Only add the target if it is compilable
+ if("${TARGET_TYPE}" MATCHES "STATIC_LIBRARY|MODULE_LIBRARY|SHARED_LIBRARY|EXECUTABLE")
+ list(APPEND DEFINED_TARGETS ${CURRENT_TARGET})
+ endif()
+ endforeach()
endforeach()
# "Return" DEFINED_TARGETS