diff --git a/Documentation/Examples/Pointers/CMakeLists.txt b/Documentation/Examples/Pointers/CMakeLists.txt index ef7a5f6150c600bcc016ccad02c099052afd1ec4..2b08ac329958d7d1f7b95ccaf876fce45def420f 100644 --- a/Documentation/Examples/Pointers/CMakeLists.txt +++ b/Documentation/Examples/Pointers/CMakeLists.txt @@ -1,15 +1,26 @@ -IF( BUILD_CUDA ) - CUDA_ADD_EXECUTABLE(UniquePointerExampleCuda UniquePointerExample.cu) - ADD_CUSTOM_COMMAND( COMMAND UniquePointerExampleCuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/UniquePointerExample.out OUTPUT UniquePointerExample.out ) - CUDA_ADD_EXECUTABLE(SharedPointerExampleCuda SharedPointerExample.cu) - ADD_CUSTOM_COMMAND( COMMAND SharedPointerExampleCuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SharedPointerExample.out OUTPUT SharedPointerExample.out ) - CUDA_ADD_EXECUTABLE(DevicePointerExampleCuda DevicePointerExample.cu) - ADD_CUSTOM_COMMAND( COMMAND DevicePointerExampleCuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/DevicePointerExample.out OUTPUT DevicePointerExample.out ) +set( COMMON_EXAMPLES + UniquePointerExample + SharedPointerExample + DevicePointerExample +) -ADD_CUSTOM_TARGET( RunPointersExamples ALL DEPENDS - UniquePointerExample.out - SharedPointerExample.out - DevicePointerExample.out - ) +if( BUILD_CUDA ) + foreach( target IN ITEMS ${COMMON_EXAMPLES} ) + cuda_add_executable( ${target}-cuda ${target}.cu OPTIONS ) + add_custom_command( COMMAND ${target}-cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/${target}.out OUTPUT ${target}.out ) + set( CUDA_OUTPUTS ${CUDA_OUTPUTS} ${target}.out ) + endforeach() +else() + foreach( target IN ITEMS ${COMMON_EXAMPLES} ) + add_executable( ${target} ${target}.cpp ) + add_custom_command( COMMAND ${target} > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/${target}.out OUTPUT ${target}.out ) + set( HOST_OUTPUTS ${HOST_OUTPUTS} ${target}.out ) + endforeach() +endif() +IF( BUILD_CUDA ) + ADD_CUSTOM_TARGET( RunPointersExamples-cuda ALL DEPENDS ${CUDA_OUTPUTS} ) +ELSE() + ADD_CUSTOM_TARGET( RunPointersExamples ALL DEPENDS ${HOST_OUTPUTS} ) ENDIF() +