Changeset View
Changeset View
Standalone View
Standalone View
cmake/modules/NativeExecutable.cmake
Show All 11 Lines | |||||
# It is imperative that NATIVE_BUILD_DIR be in the cache. | # It is imperative that NATIVE_BUILD_DIR be in the cache. | ||||
set(NATIVE_BUILD_DIR "${CMAKE_BINARY_DIR}/native" CACHE PATH "The path of the native build directory") | set(NATIVE_BUILD_DIR "${CMAKE_BINARY_DIR}/native" CACHE PATH "The path of the native build directory") | ||||
function(add_native_executable NAME) | function(add_native_executable NAME) | ||||
if(__IS_NATIVE_BUILD) | if(__IS_NATIVE_BUILD) | ||||
add_executable(${NAME} EXCLUDE_FROM_ALL ${ARGN}) | add_executable(${NAME} EXCLUDE_FROM_ALL ${ARGN}) | ||||
else() | else() | ||||
set(NATIVE_TARGET "${NAME}") | |||||
file(RELATIVE_PATH RELATIVE_PATH "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") | file(RELATIVE_PATH RELATIVE_PATH "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") | ||||
set(NATIVE_TARGET "${RELATIVE_PATH}/${NAME}") | if(RELATIVE_PATH) | ||||
string(PREPEND NATIVE_TARGET "${RELATIVE_PATH}/") | |||||
endif() | |||||
set(NATIVE_BINARY "${NATIVE_BUILD_DIR}/${NATIVE_TARGET}") | set(NATIVE_BINARY "${NATIVE_BUILD_DIR}/${NATIVE_TARGET}") | ||||
# We create a symlink because cmake craps itself if the imported | # We create a symlink because cmake craps itself if the imported | ||||
# executable has the same name as the executable itself. | # executable has the same name as the executable itself. | ||||
# https://cmake.org/pipermail/cmake/2019-May/069480.html | # https://cmake.org/pipermail/cmake/2019-May/069480.html | ||||
add_custom_command( | add_custom_command( | ||||
OUTPUT "native-${NAME}" | OUTPUT "native-${NAME}" | ||||
COMMENT "Building native ${NATIVE_TARGET}" | COMMENT "Building native ${NATIVE_TARGET}" | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |