ardupilot/cmake/arkcmake/MacroFindOrBuild.cmake

19 lines
709 B
CMake
Raw Normal View History

2011-09-29 15:16:36 -03:00
macro(MacroFindOrBuild PACKAGE PACKAGE_PATH IS_GIT_SUBMODULE)
add_custom_target(${PACKAGE})
if (NOT ${PACKAGE}_BUILD_FROM_SOURCE)
find_package(${PACKAGE})
endif()
if (NOT ${PACKAGE}_FOUND)
set(${PACKAGE}_BUILD_FROM_SOURCE TRUE)
message(STATUS "could not find package ${PACKAGE}, building from source")
add_custom_target(${PACKAGE}_BUILD DEPENDS ${PACKAGE}_BUILD.stamp)
add_dependencies(${PACKAGE} ${PACKAGE}_BUILD)
set(${PACKAGE}_FOUND TRUE)
if (${IS_GIT_SUBMODULE})
message(STATUS "${PACKAGE} detected as git submodule, will attempt to initialize it")
list(APPEND GIT_SUBMODULES ${PACKAGE_PATH})
add_dependencies(${PACKAGE}_BUILD GIT)
endif()
endif()
endmacro(MacroFindOrBuild)