-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
97 lines (78 loc) · 3.01 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
#
# see README.md for copyright and license information
#
cmake_minimum_required(VERSION 3.20)
cmake_policy(SET CMP0042 NEW)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0057 NEW)
if (APPLE)
cmake_policy(SET CMP0025 NEW)
endif()
message(STATUS "Using cmake version ${CMAKE_VERSION}")
project(SNLS LANGUAGES CXX)
# GTest requires a C compiler when running with HIP...
# On other systems this isn't necessarily an issue as CMake will
# just pick-up a valid system C compiler but on our AMD GPU machines
# that doesn't always happen.
if (ENABLE_HIP AND ENABLE_TESTS)
enable_language(C)
endif()
set(CMAKE_CXX_STANDARD 17)
#--------------------------------------------------------------------------------
# BLT
#--------------------------------------------------------------------------------
if (DEFINED BLT_SOURCE_DIR)
# Support having a shared BLT outside of the repository if given a BLT_SOURCE_DIR
if (NOT EXISTS ${BLT_SOURCE_DIR}/SetupBLT.cmake)
message(FATAL_ERROR "Given BLT_SOURCE_DIR does not contain SetupBLT.cmake")
endif()
else()
# Use internal BLT if no BLT_SOURCE_DIR is given
set(BLT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/cmake/blt" CACHE PATH "")
if (NOT EXISTS ${BLT_SOURCE_DIR}/SetupBLT.cmake)
message(FATAL_ERROR
"The BLT submodule is not present. "
"Run the following two commands in your git repository: \n"
" git submodule init\n"
" git submodule update" )
endif()
endif()
set(ENABLE_GTEST OFF CACHE BOOL "")
set(ENABLE_FRUIT OFF CACHE BOOL "")
set(ENABLE_GBENCHMARK OFF CACHE BOOL "")
if(ENABLE_TESTS)
set(ENABLE_GTEST ON CACHE BOOL "" FORCE)
endif(ENABLE_TESTS)
if(ENABLE_BENCHMARKS)
set(ENABLE_BENCHMARKS ON CACHE BOOL "" FORCE)
set(ENABLE_GBENCHMARK ON CACHE BOOL "" FORCE)
endif(ENABLE_BENCHMARKS)
include(${BLT_SOURCE_DIR}/SetupBLT.cmake)
if (${BLT_VERSION} VERSION_GREATER_EQUAL 0.6.0)
blt_install_tpl_setups(DESTINATION share/snls/cmake/)
endif()
# turn off testing if building under MSLib, so that do not have to link ms to have MS_Fail
if (DEFINED MSLIB_SOURCE_DIR)
set(ENABLE_TESTS OFF)
endif (DEFINED MSLIB_SOURCE_DIR)
# turn off testing if building under ECMech, because gtest dependence does not seem to work
if (DEFINED ECMECH_SOURCE_DIR)
set(ENABLE_TESTS OFF)
endif (DEFINED ECMECH_SOURCE_DIR)
################################
# Include standard build system logic and options
################################
include(cmake/CMakeBasics.cmake)
if(ENABLE_CUDA)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -restrict --expt-extended-lambda --expt-relaxed-constexpr")
endif()
#------------------------------------------------------------------------------
# Sources
#------------------------------------------------------------------------------
add_subdirectory(src)
#------------------------------------------------------------------------------
# Testing
#------------------------------------------------------------------------------
if(ENABLE_TESTS)
add_subdirectory(test)
endif(ENABLE_TESTS)