From 4556059c90e5e4909158dfb67722b78652611616 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 13 Nov 2019 15:19:48 -0700 Subject: [PATCH] CMake: Use find_program to detect host tools when cross-compiling In the future, we should also try to do find_package(Panda3D) to use the host tools even if Panda3D isn't in a system path. --- dtool/src/interrogate/CMakeLists.txt | 20 ++++++++++++++++++++ panda/src/downloadertools/CMakeLists.txt | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/dtool/src/interrogate/CMakeLists.txt b/dtool/src/interrogate/CMakeLists.txt index 96f01c2218..1ecba4623d 100644 --- a/dtool/src/interrogate/CMakeLists.txt +++ b/dtool/src/interrogate/CMakeLists.txt @@ -95,6 +95,26 @@ target_link_libraries(interrogate_module p3cppParser p3interrogatedb if(NOT CMAKE_CROSSCOMPILING) add_executable(host_interrogate ALIAS interrogate) add_executable(host_interrogate_module ALIAS interrogate_module) + +else() + # When cross-compiling, we must find the host Interrogate. + # TODO: We should also try to find_package(Panda3D ...) before falling back + # to searching manually. + find_program(HOST_PATH_INTERROGATE interrogate) + find_program(HOST_PATH_INTERROGATE_MODULE interrogate_module) + + add_executable(host_interrogate IMPORTED GLOBAL) + if(HOST_PATH_INTERROGATE) + set_target_properties(host_interrogate PROPERTIES + IMPORTED_LOCATION "${HOST_PATH_INTERROGATE}") + endif() + + add_executable(host_interrogate_module IMPORTED GLOBAL) + if(HOST_PATH_INTERROGATE_MODULE) + set_target_properties(host_interrogate_module PROPERTIES + IMPORTED_LOCATION "${HOST_PATH_INTERROGATE_MODULE}") + endif() + endif() if(WANT_INTERROGATE) diff --git a/panda/src/downloadertools/CMakeLists.txt b/panda/src/downloadertools/CMakeLists.txt index 6946c9667e..47abcb727f 100644 --- a/panda/src/downloadertools/CMakeLists.txt +++ b/panda/src/downloadertools/CMakeLists.txt @@ -22,6 +22,15 @@ if(HAVE_ZLIB) if(NOT CMAKE_CROSSCOMPILING) add_executable(host_pzip ALIAS pzip) + else() + find_program(HOST_PATH_PZIP pzip) + + add_executable(host_pzip IMPORTED GLOBAL) + if(HOST_PATH_PZIP) + set_target_properties(host_pzip PROPERTIES + IMPORTED_LOCATION "${HOST_PATH_PZIP}") + endif() + endif() add_executable(punzip punzip.cxx)