-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCMakeLists.txt
155 lines (123 loc) · 4.39 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Copyright (c) 2015-2024, Lawrence Livermore National Security, LLC and other
# Apollo project developers. Produced at the Lawrence Livermore National
# Laboratory. See the top-level LICENSE file for details.
# SPDX-License-Identifier: MIT
#
# Apollo
#
project(APOLLO LANGUAGES CXX C)
cmake_minimum_required(VERSION 3.9)
set(CMAKE_CXX_STANDARD 14)
# ####
#
# Options
#
option(ENABLE_MPI "Require and enable MPI for collective training" OFF)
option(ENABLE_OpenCV "Require and enable OpenCV for ML models" OFF)
option(ENABLE_JIT_DTREE "Enable JIT generated DecisionTree eval functions (supported only by Apollo implementation)" OFF)
option(ENABLE_CUDA "Enable CUDA for asynchronous timing of CUDA regions" OFF)
option(ENABLE_HIP "Enable HIP for asynchronous timing of HIP regions" OFF)
option(ENABLE_TESTS "Enable building Apollo tests" OFF)
option(BUILD_SHARED_LIBS "Build Apollo as a shared library instead of static" OFF)
#
# ####
# Version information
set(APOLLO_MAJOR_VERSION 2)
set(APOLLO_MINOR_VERSION 0)
set(APOLLO_PATCH_VERSION 0)
set(APOLLO_VERSION "${APOLLO_MAJOR_VERSION}.${APOLLO_MINOR_VERSION}.${APOLLO_PATCH_VERSION}")
set(APOLLO_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
include(PreventInSourceBuilds)
#
# Setup variables to pass to ApolloConfig.h
#
# Pull in macros
include(ApolloProjectMacros)
# Pull in the GIT repo information
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
# add_definitions("-DAPOLLO_GIT_SHA1=${GIT_SHA1}")
set(APOLLO_GIT_SHA1 "${GIT_SHA1}")
# Set some host information
execute_process(COMMAND uname -n OUTPUT_VARIABLE APOLLO_HOST_NODE_NAME)
string(STRIP ${APOLLO_HOST_NODE_NAME} APOLLO_HOST_NODE_NAME)
if(APPLE)
execute_process(COMMAND uname OUTPUT_VARIABLE APOLLO_HOST_DETAILED_O)
else(APPLE)
execute_process(COMMAND uname -o OUTPUT_VARIABLE APOLLO_HOST_DETAILED_O)
endif(APPLE)
string(STRIP ${APOLLO_HOST_DETAILED_O} APOLLO_HOST_DETAILED_O)
execute_process(COMMAND uname -r OUTPUT_VARIABLE APOLLO_HOST_DETAILED_R)
string(STRIP ${APOLLO_HOST_DETAILED_R} APOLLO_HOST_DETAILED_R)
execute_process(COMMAND uname -m OUTPUT_VARIABLE APOLLO_HOST_DETAILED_M)
string(STRIP ${APOLLO_HOST_DETAILED_M} APOLLO_HOST_DETAILED_M)
set(APOLLO_HOST_KNOWN_AS ${APOLLO_HOST_NODE_NAME})
set(APOLLO_HOST_DETAILED "\"${APOLLO_HOST_DETAILED_O} ${APOLLO_HOST_DETAILED_R} ${APOLLO_HOST_DETAILED_M}\"")
message(STATUS "Building on: ${CMAKE_SYSTEM_NAME}")
# string(TOUPPER ${APOLLO_BUILD_TYPE} CMAKE_BUILD_TYPE)
set(APOLLO_CXX_COMPILER "${CMAKE_CXX_COMPILER} ")
set(APOLLO_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${APOLLO_BUILD_TYPE}} ")
set(APOLLO_LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE}} ")
# Create a config header file
configure_file(
${PROJECT_SOURCE_DIR}/apollo-config.h.in
${PROJECT_BINARY_DIR}/apollo-config.h)
# Create pkg-confic .pc file
set(PKG_CONFIG_INCLUDEDIR "\${prefix}/include")
set(PKG_CONFIG_LIBDIR "\${prefix}/lib")
set(PKG_CONFIG_LIBS "-L\${libdir} -lapollo ")
set(PKG_CONFIG_CFLAGS "-I\${includedir} ")
configure_file(
${PROJECT_SOURCE_DIR}/apollo.pc.in
${PROJECT_BINARY_DIR}/apollo.pc)
# Make apollo findable for cmake
configure_file(
${PROJECT_SOURCE_DIR}/apollo-config.cmake.in
${PROJECT_BINARY_DIR}/apollo-config.cmake
@ONLY)
install(FILES ${PROJECT_BINARY_DIR}/apollo-config.cmake
DESTINATION share/cmake/apollo)
install(EXPORT apollo
DESTINATION share/cmake/apollo)
install(FILES ${PROJECT_BINARY_DIR}/apollo-config.h
DESTINATION include/apollo)
install(FILES ${PROJECT_BINARY_DIR}/apollo.pc
DESTINATION lib/pkgconfig)
# ####
#
# External libraries
#
if(ENABLE_MPI)
find_package(MPI REQUIRED)
add_definitions(-DENABLE_MPI)
endif()
if(ENABLE_OPENCV)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_definitions(-DENABLE_OPENCV)
endif()
if(ENABLE_CUDA)
# TODO: Upgrade to CUDAToolkit for better handling, requires cmake 3.17+
find_package(CUDA REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
endif()
if(ENABLE_HIP)
find_package(hip REQUIRED)
include_directories(${HSA_HEADER})
add_definitions(-D__HIP_PLATFORM_AMD__)
endif()
if(ENABLE_JIT_DTREE)
add_definitions(-DENABLE_JIT_DTREE)
endif()
# ####
#
# Define build targets for Apollo
#
include_directories(./src ./include ${PROJECT_BINARY_DIR}/include)
add_subdirectory(src)
if(ENABLE_TESTS)
add_subdirectory(test)
endif(ENABLE_TESTS)
#
# EOF