-
Notifications
You must be signed in to change notification settings - Fork 44
/
CMakeLists.txt
134 lines (119 loc) · 4.31 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
#--------------------------------------------*-cmake-*---------------------------------------------#
# file draco/CMakeLists.txt
# author Kelly Thompson <kgt@lanl.gov>
# date 2010 April 28
# brief Instructions for building root level Makefile.
# note Copyright (C) 2010-2024 Triad National Security, LLC., All rights reserved.
#
# Build notes:
#
# * https://re-git.lanl.gov/draco/draco/-/wikis/home
# * https://re-git.lanl.gov/draco/draco/-/wiki/Common_Configure_Options
#--------------------------------------------------------------------------------------------------#
cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR)
string(CONCAT ddesc "An object-oriented component library supporting radiation transport "
"applications.")
project(
Draco
DESCRIPTION ${ddesc}
VERSION 7.19.0
LANGUAGES CXX C)
# Export compile commands for compiler tools
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
# Do not look for Fortran/CUDA/HIP for
#
# 1. XCode based Generators, or
# 2. Visual Studio IDE or NMake Generators (MSYS or CYGWIN environments will look for Fortran).
# 3. Ninja, Codeblocks or Eclipse CDT4 generators.
# 4. Unix Makefile generator when:
#
# * Fortran only: $ENV{FC} is not set (e.g. clang on Linux)
# * Cuda only : $ENV{CUDADIR} is not set (e.g. cuda module not loaded)
if((${CMAKE_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_GENERATOR} MATCHES "Ninja") AND NOT MSVC)
# For non-MSVC builds, always look for Fortran. If $ENV{FC} or ${CMAKE_Fortran_COMPILER} are
# defined, they will be used. Otherwise cmake will search for a Fortran compiler based on its
# internal rules. Normally, it will look for gfortran first.
enable_language(Fortran OPTIONAL)
if(DEFINED ENV{CUDADIR}
OR DEFINED ENV{CUDACXX}
OR DEFINED ENV{CUDA_HOME})
if((DEFINED USE_GPU AND USE_GPU) OR NOT DEFINED USE_GPU)
enable_language(CUDA OPTIONAL)
endif()
elseif(
"$ENV{LOADEDMODULES}" MATCHES "rocmcc"
OR DEFINED ENV{HIPCXX}
OR DEFINED CMAKE_HIP_COMPILER)
if((DEFINED USE_GPU AND USE_GPU) OR NOT DEFINED USE_GPU)
enable_language(HIP OPTIONAL)
if(CMAKE_HIP_COMPILER MATCHES "CC")
set(CMAKE_HIP_FLAGS "-x hip")
endif()
endif()
endif()
endif()
# Build system configuration files are located here.
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/config)
# Debug cmake scripts:
#
# 1. Review macros defined at config/debug_macros.cmake and config/print_target_properties.cmake.
# 2. Uncomment this feature to tell CMake to print include paths during target registration
# set(CMAKE_DEBUG_TARGET_PROPERTIES INCLUDE_DIRECTORIES)
# 3. Optionally use --trace
#
# The Draco version number.
#
include(dracoVersion)
set_ccs2_software_version(Draco)
#
# Unit Test Setup
#
include(dracoTesting)
# Set default compile environment:
# Setup defaults, value checks, etc.
include(buildEnv)
# set defaults for BUILD_TYPE and INSTALL_PREFIX, DRACO_ROUNDOFF_MODE
dbssetdefaults()
# Initialize fields that define the exported target files (draco-config.cmake)
dbsinitexporttargets("Draco")
# Save config info
dbsconfiginfo()
# Platform Checks: Is HOST_NAME_MAX defined? Is WinSock2.h available? Is gethostname() available?
include(platform_checks)
set_draco_uname()
query_have_gethostname()
query_have_maxpathlen()
query_have_sys_headers() #< sets HAVE_UNISTD_H, etc.
query_fma_on_hardware()
provide_ctest_resources_spec() # creates ctest_resource_spec.json in the build dir.
# Find any globally required libraries
include(FeatureSummary)
include(vendor_libraries)
setupvendorlibraries()
# Set compiler options
include(compilerEnv)
dbssetupcompilers()
dbssetupcxx()
dbssetupfortran()
dbssetupcuda()
dbssetupprofilertools()
dbssetupstaticanalyzers()
dbssetupstdtargetprops()
#
# Build Draco components:
#
add_subdirectory(src)
if(TARGET Exe_draco_info)
add_subdirectory(autodoc) #< This must be processed after 'src'
endif()
add_subdirectory(config) #< This must be processed after 'src'
# install top level documents
install(FILES ChangeLog LICENSE.md README.md DESTINATION ${CMAKE_INSTALL_PREFIX})
# Export targets
install(
EXPORT draco-targets
DESTINATION cmake
EXPORT_LINK_INTERFACE_LIBRARIES)
# ------------------------------------------------------------------------------------------------ #
# End of CMakeLists.txt
# ------------------------------------------------------------------------------------------------ #