forked from LLNL/ygm-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
132 lines (118 loc) · 3.61 KB
/
CMakeLists.txt
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Copyright 2019-2021 Lawrence Livermore National Security, LLC and other YGM
# Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: MIT
cmake_minimum_required(VERSION 3.14)
project(ygm-bench
VERSION 0.1
DESCRIPTION "YGM Benchmarks"
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
include(FetchContent)
#
# MPI
find_package(MPI)
#
# Boost
#
# Disable the boost-cmake feature (BoostConfig.cmake or boost-config.cmake)
# because there is a tricky behavior/issue. We use FetchContent to download
# Boost and find_package to find the location of Boost. As find_package natively
# supports Boost, we do not need to use the boost-cmake feature.
set(Boost_NO_BOOST_CMAKE ON)
find_package(Boost 1.75 QUIET)
if (NOT Boost_FOUND)
FetchContent_Declare(
Boost
URL https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2
)
FetchContent_GetProperties(Boost)
if (Boost_POPULATED)
message(STATUS ${PROJECT_NAME}
" found already populated Boost dependency: "
${boost_SOURCE_DIR}
)
else ()
FetchContent_Populate(Boost)
message(STATUS ${PROJECT_NAME} " cloned Boost dependency: "
${boost_SOURCE_DIR}
)
endif ()
set(BOOST_ROOT ${boost_SOURCE_DIR})
find_package(Boost 1.75)
else ()
message(STATUS ${PROJECT_NAME} " found Boost dependency: "
${Boost_INCLUDE_DIR}
)
endif ()
#
# ygm
find_package(ygm CONFIG)
if(NOT ygm_FOUND)
if(DEFINED ENV{YGM_BENCH_YGM_REPO})
set(YGM_REPO $ENV{YGM_BENCH_YGM_REPO})
else()
set(YGM_REPO "https://github.com/llnl/ygm.git")
endif()
if(DEFINED ENV{YGM_BENCH_YGM_TAG})
set(YGM_TAG $ENV{YGM_BENCH_YGM_TAG})
else()
set(YGM_TAG "develop")
endif()
FetchContent_Declare(
ygm
GIT_REPOSITORY ${YGM_REPO}
GIT_TAG ${YGM_TAG}
)
set(JUST_INSTALL_YGM ON)
FetchContent_MakeAvailable(ygm)
message(STATUS "Cloned ygm dependency " ${ygm_SOURCE_DIR})
else()
message(STATUS "Found ygm dependency " ${ygm_DIR})
endif()
#
# krokee
find_package(krowkee CONFIG)
if(NOT krowkee_FOUND)
if(DEFINED ENV{YGM_BENCH_KROWKEE_REPO})
set(KROWKEE_REPO $ENV{YGM_BENCH_KROWKEE_REPO})
else()
set(KROWKEE_REPO "https://github.com/LLNL/krowkee.git")
endif()
if(DEFINED ENV{YGM_BENCH_KROWKEE_TAG})
set(KROWKEE_TAG $ENV{YGM_BENCH_KROWKEE_TAG})
else()
set(KROWKEE_TAG "v0.1.0")
endif()
FetchContent_Declare(
krowkee
GIT_REPOSITORY ${KROWKEE_REPO}
GIT_TAG ${KROWKEE_TAG}
)
set(JUST_INSTALL_KROWKEE ON)
FetchContent_MakeAvailable(krowkee)
message(STATUS "Cloned krowkee dependency " ${krowkee_SOURCE_DIR})
else()
message(STATUS "Found krowkee dependency " ${krowkee_DIR})
endif()
function(setup_ygm_target exe_name)
add_executable(${exe_name} ${exe_name}.cpp)
target_link_libraries(${exe_name} PRIVATE ygm::ygm)
target_include_directories(${exe_name} PRIVATE "${PROJECT_SOURCE_DIR}/include")
target_include_directories(${exe_name} PRIVATE ${Boost_INCLUDE_DIRS})
endfunction()
function(setup_krowkee_target exe_name)
setup_ygm_target(${exe_name})
target_link_libraries(${exe_name} PRIVATE krowkee::krowkee)
endfunction()
function(setup_mpi_target exe_name)
add_executable(${exe_name} ${exe_name}.cpp)
target_link_libraries(${exe_name} PRIVATE MPI::MPI_CXX)
target_include_directories(${exe_name} PRIVATE "${PROJECT_SOURCE_DIR}/include")
target_include_directories(${exe_name} PRIVATE ${Boost_INCLUDE_DIRS})
endfunction()
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
message(STATUS "CMAKE_BUILD_TYPE is set as Release")
endif ()
add_subdirectory(src)