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.
This commit is contained in:
Sam Edwards 2019-11-13 15:19:48 -07:00
parent f377bdfb29
commit 4556059c90
2 changed files with 29 additions and 0 deletions

View File

@ -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)

View File

@ -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)