-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
112 lines (96 loc) · 3.71 KB
/
Copy pathCMakeLists.txt
File metadata and controls
112 lines (96 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Copyright (c) 2016 John Biddiscombe
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 3.14)
#--------------------------------------------------
# project declaration
#--------------------------------------------------
project(tutorial_examples CXX)
#--------------------------------------------------
# setup Output directories
#--------------------------------------------------
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Executables."
)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/lib CACHE PATH "Single Directory for all Libraries"
)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/lib CACHE PATH "Single Directory for all static libraries."
)
#------------------------------------------------------------------------------
# Detect which machine we are running on to setup defaults for convenience
#------------------------------------------------------------------------------
SITE_NAME(hostname)
if(hostname MATCHES "unknown" OR hostname MATCHES "No")
message("unknown hostname \"${hostname}\", using ENV$ $ENV{HOSTNAME} instead")
set(hostname $ENV{HOSTNAME})
endif()
if(hostname MATCHES daint)
set(TBB_ROOT "/opt/intel/compilers_and_libraries_2017.4.196/linux/tbb/")
message("Running on Daint")
endif()
message("CMAKE_SYSTEM is ${CMAKE_SYSTEM} with hostname ${hostname} and processor ${CMAKE_SYSTEM_PROCESSOR}" )
#--------------------------------------------------
# Option to download and build HPX as a sub project
#--------------------------------------------------
option(HPX_DOWNLOAD_AS_SUBPROJECT OFF)
if (HPX_DOWNLOAD_AS_SUBPROJECT)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(hpx_download)
add_subproject(HPX hpx)
endif()
#--------------------------------------------------
# Find HPX, disable searching in user builds
#--------------------------------------------------
find_package(HPX 1.7.0 REQUIRED NO_CMAKE_PACKAGE_REGISTRY)
message("\n-------\nTutorial using HPX from ${HPX_DIR}\n-------\n")
#--------------------------------------------------
# Check we are using the same build type as HPX
#--------------------------------------------------
if (NOT "${HPX_BUILD_TYPE}" STREQUAL "${CMAKE_BUILD_TYPE}")
message(WARNING "CMAKE_BUILD_TYPE does not match ${HPX_BUILD_TYPE} :\n"
"this project uses ${CMAKE_BUILD_TYPE}, hpx uses ${HPX_BUILD_TYPE}\n"
"Please add -DCMAKE_BUILD_TYPE=${HPX_BUILD_TYPE} to your cmake command"
)
endif()
#--------------------------------------------------
# On the cray we need the following flags
#--------------------------------------------------
if (NOT WIN32)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -dynamic")
endif()
#--------------------------------------------------
# Each example goes into its own subdir
#--------------------------------------------------
set(TUTORIAL_DIRS
00_exercises
01_hello_world
02_overhead
03_stencil
04_fibonacci
05_saxpy
06_named_pool_executor
)
#if (HPX_WITH_CUDA)
# message("CUDA_LIBRARIES ${CUDA_LIBRARIES}")
# set(TUTORIAL_DIRS ${TUTORIAL_DIRS}
# 07_cuda_futures
# )
# link_directories(${HPX_LIBRARY_DIR})
# include_directories(${CUDA_TOOLKIT_INCLUDE})
#endif()
if (HPX_WITH_APEX)
set(TUTORIAL_DIRS ${TUTORIAL_DIRS}
# 03_apex_stencil_1d
)
endif()
add_hpx_pseudo_target(tutorial)
foreach(subdir ${TUTORIAL_DIRS})
string(REGEX REPLACE "[0-9]+_" "" RESULT "${subdir}")
add_hpx_pseudo_target(tutorial.${RESULT})
add_subdirectory(${subdir})
add_hpx_pseudo_dependencies(tutorial tutorial.${RESULT})
endforeach()