aboutsummaryrefslogtreecommitdiff
path: root/cmake/scripts
diff options
context:
space:
mode:
authorfuzzard <fuzzard@kodi.tv>2022-05-31 15:43:00 +1000
committerfuzzard <fuzzard@kodi.tv>2022-06-02 10:06:39 +1000
commit644b1d17d7989cca4a7ddd49c844cff686e59951 (patch)
treefc57659a139b746b7f5f37a6830589736a2d8bf6 /cmake/scripts
parent04c47876ae2a1a5220c664697ca1fe58f848600c (diff)
[cmake] refactor BUILD_DEP_TARGET to utilise generator expressions
Diffstat (limited to 'cmake/scripts')
-rw-r--r--cmake/scripts/common/ModuleHelpers.cmake43
1 files changed, 25 insertions, 18 deletions
diff --git a/cmake/scripts/common/ModuleHelpers.cmake b/cmake/scripts/common/ModuleHelpers.cmake
index 7456f6e4b3..e659d6a86d 100644
--- a/cmake/scripts/common/ModuleHelpers.cmake
+++ b/cmake/scripts/common/ModuleHelpers.cmake
@@ -127,13 +127,19 @@ macro(BUILD_DEP_TARGET)
unset(${MODULE}_LIBRARY_RELEASE)
endif()
else()
- # single config generator (ie Make, Ninja)
- if(CMAKE_BUILD_TYPE)
- list(APPEND CMAKE_ARGS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
+ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20")
+ list(APPEND CMAKE_ARGS "-DCMAKE_BUILD_TYPE=$<IF:$<CONFIG:Debug,RelWithDebInfo>,Debug,Release>")
else()
- # Multi-config generators (eg VS, Xcode, Ninja Multi-Config) will not have CMAKE_BUILD_TYPE
- # Use config genex to generate the types
- list(APPEND CMAKE_ARGS "-DCMAKE_BUILD_TYPE=$<CONFIG>")
+ # single config generator (ie Make, Ninja)
+ if(CMAKE_BUILD_TYPE)
+ list(APPEND CMAKE_ARGS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
+ else()
+ # Multi-config generators (eg VS, Xcode, Ninja Multi-Config) will not have CMAKE_BUILD_TYPE
+ # Use config genex to generate the types
+ # Potential issue if Build type isnt supported by lib project
+ # eg lib supports Debug/Release, however users selects RelWithDebInfo in project
+ list(APPEND CMAKE_ARGS "-DCMAKE_BUILD_TYPE=$<CONFIG>")
+ endif()
endif()
endif()
endif()
@@ -189,21 +195,22 @@ macro(BUILD_DEP_TARGET)
if(BUILD_BYPRODUCTS)
set(BUILD_BYPRODUCTS BUILD_BYPRODUCTS ${BUILD_BYPRODUCTS})
else()
- # Single config generator (Unix Makefiles, Ninja)
- if(DEFINED CMAKE_BUILD_TYPE)
- if(NOT CMAKE_BUILD_TYPE STREQUAL "Release" AND DEFINED ${MODULE}_LIBRARY_DEBUG)
- set(BUILD_BYPRODUCTS BUILD_BYPRODUCTS "${${MODULE}_LIBRARY_DEBUG}")
+ if(DEFINED ${MODULE}_LIBRARY_DEBUG)
+ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20")
+ set(BUILD_BYPRODUCTS BUILD_BYPRODUCTS "$<IF:$<CONFIG:Debug,RelWithDebInfo>,${${MODULE}_LIBRARY_DEBUG},${${MODULE}_LIBRARY_RELEASE}>")
else()
- set(BUILD_BYPRODUCTS BUILD_BYPRODUCTS "${${MODULE}_LIBRARY}")
+ if(DEFINED CMAKE_BUILD_TYPE)
+ if(NOT CMAKE_BUILD_TYPE STREQUAL "Release" AND DEFINED ${MODULE}_LIBRARY_DEBUG)
+ set(BUILD_BYPRODUCTS BUILD_BYPRODUCTS "${${MODULE}_LIBRARY_DEBUG}")
+ else()
+ set(BUILD_BYPRODUCTS BUILD_BYPRODUCTS "${${MODULE}_LIBRARY}")
+ endif()
+ else()
+ message(FATAL_ERROR "MultiConfig Generator usage requires CMake >= 3.20.0 - Generator Expressions in BYPRODUCT option")
+ endif()
endif()
else()
- # Multi Config generator (VS, Xcode, Ninja Multi-Config)
- # If no debug library (ie lib has no difference with naming for build type), just set <MODULE>_LIBRARY
- if(DEFINED ${MODULE}_LIBRARY_DEBUG)
- set(BUILD_BYPRODUCTS BUILD_BYPRODUCTS $<$<CONFIG:Debug,RelWithDebInfo>:${MODULE}_LIBRARY_DEBUG>$<$<CONFIG:Release>:${MODULE}_LIBRARY_RELEASE>)
- else()
- set(BUILD_BYPRODUCTS BUILD_BYPRODUCTS ${MODULE}_LIBRARY)
- endif()
+ set(BUILD_BYPRODUCTS BUILD_BYPRODUCTS "${${MODULE}_LIBRARY}")
endif()
endif()