From 79ca8bbb00072d5e9b86c7d15aea4054ac00e804 Mon Sep 17 00:00:00 2001 From: Jan Stephan Date: Tue, 23 Jun 2020 09:48:23 +0200 Subject: [PATCH] Enable subdirectories and use alpaka_ROOT (#1022) --- example/bufferCopy/CMakeLists.txt | 12 +++++++++--- example/heatEquation/CMakeLists.txt | 12 +++++++++--- example/helloWorld/CMakeLists.txt | 12 +++++++++--- example/helloWorldLambda/CMakeLists.txt | 12 +++++++++--- example/reduce/CMakeLists.txt | 12 +++++++++--- example/vectorAdd/CMakeLists.txt | 12 +++++++++--- 6 files changed, 54 insertions(+), 18 deletions(-) diff --git a/example/bufferCopy/CMakeLists.txt b/example/bufferCopy/CMakeLists.txt index 287aa3c86ae9..4d8b428c7100 100644 --- a/example/bufferCopy/CMakeLists.txt +++ b/example/bufferCopy/CMakeLists.txt @@ -34,9 +34,15 @@ project(${_TARGET_NAME}) # Find alpaka. if(NOT TARGET alpaka::alpaka) - set(ALPAKA_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../" CACHE STRING "The location of alpakaConfig.cmake") - list(APPEND CMAKE_MODULE_PATH "${ALPAKA_ROOT}") - find_package(alpaka REQUIRED) + option(USE_ALPAKA_SOURCE_TREE "Use alpaka's source tree instead of an alpaka installation" OFF) + + if(USE_ALPAKA_SOURCE_TREE) + # Don't build the examples recursively + set(alpaka_BUILD_EXAMPLES OFF) + add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../.." "${CMAKE_BINARY_DIR}/alpaka") + else() + find_package(alpaka REQUIRED) + endif() endif() #------------------------------------------------------------------------------- diff --git a/example/heatEquation/CMakeLists.txt b/example/heatEquation/CMakeLists.txt index f034713f0acc..819d44892ce1 100644 --- a/example/heatEquation/CMakeLists.txt +++ b/example/heatEquation/CMakeLists.txt @@ -35,9 +35,15 @@ project(${_TARGET_NAME}) # Find alpaka. if(NOT TARGET alpaka::alpaka) - set(ALPAKA_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../" CACHE STRING "The location of the alpaka library") - list(APPEND CMAKE_MODULE_PATH "${ALPAKA_ROOT}") - find_package(alpaka REQUIRED) + option(USE_ALPAKA_SOURCE_TREE "Use alpaka's source tree instead of an alpaka installation" OFF) + + if(USE_ALPAKA_SOURCE_TREE) + # Don't build the examples recursively + set(alpaka_BUILD_EXAMPLES OFF) + add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../.." "${CMAKE_BINARY_DIR}/alpaka") + else() + find_package(alpaka REQUIRED) + endif() endif() #------------------------------------------------------------------------------- diff --git a/example/helloWorld/CMakeLists.txt b/example/helloWorld/CMakeLists.txt index 7ff6067cd559..7911297e06e1 100644 --- a/example/helloWorld/CMakeLists.txt +++ b/example/helloWorld/CMakeLists.txt @@ -34,9 +34,15 @@ project(${_TARGET_NAME}) # Find alpaka. if(NOT TARGET alpaka::alpaka) - set(ALPAKA_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../" CACHE STRING "The location of alpakaConfig.cmake") - list(APPEND CMAKE_MODULE_PATH "${ALPAKA_ROOT}") - find_package(alpaka REQUIRED) + option(USE_ALPAKA_SOURCE_TREE "Use alpaka's source tree instead of an alpaka installation" OFF) + + if(USE_ALPAKA_SOURCE_TREE) + # Don't build the examples recursively + set(alpaka_BUILD_EXAMPLES OFF) + add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../.." "${CMAKE_BINARY_DIR}/alpaka") + else() + find_package(alpaka REQUIRED) + endif() endif() #------------------------------------------------------------------------------- diff --git a/example/helloWorldLambda/CMakeLists.txt b/example/helloWorldLambda/CMakeLists.txt index 11ec8457adcb..8a60a1c07b2e 100644 --- a/example/helloWorldLambda/CMakeLists.txt +++ b/example/helloWorldLambda/CMakeLists.txt @@ -34,9 +34,15 @@ project(${_TARGET_NAME}) # Find alpaka. if(NOT TARGET alpaka::alpaka) - set(ALPAKA_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../" CACHE STRING "The location of alpakaConfig.cmake") - list(APPEND CMAKE_MODULE_PATH "${ALPAKA_ROOT}") - find_package(alpaka REQUIRED) + option(USE_ALPAKA_SOURCE_TREE "Use alpaka's source tree instead of an alpaka installation" OFF) + + if(USE_ALPAKA_SOURCE_TREE) + # Don't build the examples recursively + set(alpaka_BUILD_EXAMPLES OFF) + add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../.." "${CMAKE_BINARY_DIR}/alpaka") + else() + find_package(alpaka REQUIRED) + endif() endif() #------------------------------------------------------------------------------- diff --git a/example/reduce/CMakeLists.txt b/example/reduce/CMakeLists.txt index cc5799c83015..23b7b3e3aaea 100644 --- a/example/reduce/CMakeLists.txt +++ b/example/reduce/CMakeLists.txt @@ -34,9 +34,15 @@ project(${_TARGET_NAME}) # Find alpaka. if(NOT TARGET alpaka::alpaka) - set(ALPAKA_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../" CACHE STRING "The location of alpakaConfig.cmake") - list(APPEND CMAKE_MODULE_PATH "${ALPAKA_ROOT}") - find_package(alpaka REQUIRED) + option(USE_ALPAKA_SOURCE_TREE "Use alpaka's source tree instead of an alpaka installation" OFF) + + if(USE_ALPAKA_SOURCE_TREE) + # Don't build the examples recursively + set(alpaka_BUILD_EXAMPLES OFF) + add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../.." "${CMAKE_BINARY_DIR}/alpaka") + else() + find_package(alpaka REQUIRED) + endif() endif() #------------------------------------------------------------------------------- diff --git a/example/vectorAdd/CMakeLists.txt b/example/vectorAdd/CMakeLists.txt index 636b3935f296..144a25e6daa4 100644 --- a/example/vectorAdd/CMakeLists.txt +++ b/example/vectorAdd/CMakeLists.txt @@ -35,9 +35,15 @@ project(${_TARGET_NAME}) # Find alpaka. if(NOT TARGET alpaka::alpaka) - set(ALPAKA_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../" CACHE STRING "The location of the alpaka library") - list(APPEND CMAKE_MODULE_PATH "${ALPAKA_ROOT}") - find_package(alpaka REQUIRED) + option(USE_ALPAKA_SOURCE_TREE "Use alpaka's source tree instead of an alpaka installation" OFF) + + if(USE_ALPAKA_SOURCE_TREE) + # Don't build the examples recursively + set(alpaka_BUILD_EXAMPLES OFF) + add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../.." "${CMAKE_BINARY_DIR}/alpaka") + else() + find_package(alpaka REQUIRED) + endif() endif() #-------------------------------------------------------------------------------