diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cb8657..121c0fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,4 +56,21 @@ endif() add_subdirectory(src) set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER}) -set_target_properties(obfuscator obfuscator-lib obfuscator-tests zasm Zydis Zycore PROPERTIES VS_GLOBAL_VcpkgEnabled false) +function(get_all_targets var) + set(targets) + get_all_targets_recursive(targets ${CMAKE_CURRENT_SOURCE_DIR}) + set(${var} ${targets} PARENT_SCOPE) +endfunction() + +macro(get_all_targets_recursive targets dir) + get_property(subdirectories DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) + foreach(subdir ${subdirectories}) + get_all_targets_recursive(${targets} ${subdir}) + endforeach() + + get_property(current_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) + list(APPEND ${targets} ${current_targets}) +endmacro() + +get_all_targets(all_targets) +set_target_properties(${all_targets} PROPERTIES VS_GLOBAL_VcpkgEnabled false) diff --git a/cmake.toml b/cmake.toml index dfee0a0..56496c6 100644 --- a/cmake.toml +++ b/cmake.toml @@ -18,5 +18,22 @@ build-tests = "OBFUSCATOR_BUILD_TESTS" # Ugly fix for Zydis collisions :/ cmake-after = """ -set_target_properties(obfuscator obfuscator-lib obfuscator-tests zasm Zydis Zycore PROPERTIES VS_GLOBAL_VcpkgEnabled false) +function(get_all_targets var) + set(targets) + get_all_targets_recursive(targets ${CMAKE_CURRENT_SOURCE_DIR}) + set(${var} ${targets} PARENT_SCOPE) +endfunction() + +macro(get_all_targets_recursive targets dir) + get_property(subdirectories DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) + foreach(subdir ${subdirectories}) + get_all_targets_recursive(${targets} ${subdir}) + endforeach() + + get_property(current_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) + list(APPEND ${targets} ${current_targets}) +endmacro() + +get_all_targets(all_targets) +set_target_properties(${all_targets} PROPERTIES VS_GLOBAL_VcpkgEnabled false) """