Repository: free-audio/clap-wrapper (language: cpp)

Issue:
CPM causes issues when using multiple project subdirectories
CPM seems to populate in the binary directory of the first target added, when it should perhaps go in a more general directory. This seems to be causing that target to ignore DEBUG_POSTFIX, making it more difficult to switch between release & debug builds.


Discussion / hints:
OK, this is caused by how rtaudio and rtmidi CMake is written, combined with our guarantee strategy

They both set DEBUG_POSTFIX
https://github.com/thestk/rtaudio/blob/0cee8ed34dcb10a29416a0cdc4d652c158abd2a2/CMakeLists.txt#L44
https://github.com/thestk/rtmidi/blob/53809fc1869a9789c4631a11081c1840b6db1527/CMakeLists.txt#L35

We don't call guarantee_rtaudio/guarantee_rtmidi so this doesn't apply until *after* the first target_add_standalone_wrapper call. Therefore, the first target you set up will have different settings.

Will have to ponder the correct solution here for a bit.
ugh
can we just re-cache set it after we include those?

Fix patch:
diff --git a/cmake/base_sdks.cmake b/cmake/base_sdks.cmake
index f538ca64..3c55446e 100644
--- a/cmake/base_sdks.cmake
+++ b/cmake/base_sdks.cmake
@@ -241,6 +241,7 @@ function(guarantee_rtaudio)
         return()
     endif()
 
+    set(RTAUDIO_INITIAL_DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX} CACHE STRING "Initial CMAKE_DEBUG_POSTFIX value")
     set(RTAUDIO_TARGETNAME_UNINSTALL "rtaudio-uninstall" CACHE STRING "Name of 'uninstall' build target")
     set(RTAUDIO_BUILD_STATIC_LIBS TRUE CACHE BOOL "static rdmidi")
     set(RTAUDIO_BUILD_TESTING OFF CACHE BOOL "don't eject test targets")
@@ -281,6 +282,9 @@ function(guarantee_rtaudio)
     add_library(base-sdk-rtaudio INTERFACE)
     target_link_libraries(base-sdk-rtaudio INTERFACE rtaudio)
     set_target_properties(rtaudio PROPERTIES UNITY_BUILD FALSE)
+    
+    unset(CMAKE_DEBUG_POSTFIX CACHE)
+    set(CMAKE_DEBUG_POSTFIX ${RTAUDIO_INITIAL_DEBUG_POSTFIX} CACHE STRING "Reset CMAKE_DEBUG_POSTFIX value")
 endfunction(guarantee_rtaudio)
 
 
@@ -294,6 +298,7 @@ function(guarantee_rtmidi)
         set(RTMIDI_API_JACK FALSE CACHE BOOL "skip jack")
     endif()
 
+    set(RTMIDI_INITIAL_DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX} CACHE STRING "Initial CMAKE_DEBUG_POSTFIX value")
     set(RTMIDI_TARGETNAME_UNINSTALL "rtmidi-uninstall" CACHE STRING "Name of 'uninstall' build target")
     set(RTMIDI_BUILD_STATIC_LIBS TRUE CACHE BOOL "static rdmidi")
     set(RTMIDI_BUILD_TESTING OFF CACHE BOOL "don't eject test targets")
@@ -325,6 +330,9 @@ function(guarantee_rtmidi)
     target_link_libraries(base-sdk-rtmidi INTERFACE rtmidi)
 
     set_target_properties(rtmidi PROPERTIES UNITY_BUILD FALSE)
+
+    unset(CMAKE_DEBUG_POSTFIX CACHE)
+    set(CMAKE_DEBUG_POSTFIX ${RTMIDI_INITIAL_DEBUG_POSTFIX} CACHE STRING "Reset CMAKE_DEBUG_POSTFIX value")
 endfunction(guarantee_rtmidi)
 
 function(guarantee_wil)


Test patch: