-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
115 lines (91 loc) · 3.09 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
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
# Enable out of source builds and source changes
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
if(CMAKE_VERSION VERSION_GREATER 3.22.1 OR CMAKE_VERSION VERSION_EQUAL 3.22.1)
cmake_policy(SET CMP0115 OLD)
endif()
# Make Default Build Type Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
"Release"
CACHE
STRING
"Configuration type (Debug, RelWithDebInfo, Release, MinSizeRel)"
FORCE)
endif()
# Charmlite depends on a valid Charm installation
find_package(Charm REQUIRED)
message(STATUS "Found Charm++ at ${CHARM_ROOT}")
message(STATUS "Switching to Charm CXX Compiler: ${CHARM_ROOT}/bin/charmc")
set(CMAKE_CXX_COMPILER ${CHARM_CXX_COMPILER})
# Make sure correct compiler is set before starting the project
project(CharmLite CXX)
# Make sure all executables go in bin directory and all libraries go in lib
# directory.
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set(CMAKE_CXX_FLAGS "-language converse++ -Wall -Wextra" CACHE STRING "Additional arguments to charmc" FORCE)
# Charmlite requires a conforming C++11 compiler
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# charmc currently appends -std=c++11 so we need to explicitly pass the
# option again
add_compile_options(-c++-option -std=c++17)
# Add cmake to module path
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# Ensure required facilities work
include(CharmLite_TestCXXFeatures)
# Include the testing framework
include(CharmLite_SetupTests)
# Generate libcharmlite.a
add_subdirectory(src)
# Set-up examples
option(CHARMLITE_ENABLE_EXAMPLES "Enable Building Examples" ON)
if(CHARMLITE_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()
# Set-up tests
option(CHARMLITE_ENABLE_TESTS "Enable Testing Framework" OFF)
if(CHARMLITE_ENABLE_TESTS)
add_subdirectory(tests)
endif()
if(CHARMLITE_ENABLE_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
# Configure cmake configs
configure_file(
${CMAKE_SOURCE_DIR}/cmake/templates/CharmLiteConfig.cmake.in
"${CMAKE_BINARY_DIR}/lib/cmake/CharmLite/CharmLiteConfig.cmake"
ESCAPE_QUOTES
@ONLY)
# Setup Installs
include(GNUInstallDirs)
# Install charmlite library
install(
TARGETS charmlite
EXPORT CharmLite
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
# Install cmake targets to be used by CharmLiteConfig.cmake
install(
EXPORT CharmLite
FILE CharmLiteTargets.cmake
NAMESPACE CharmLite::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CharmLite)
# Install header files
install(
DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.hpp")
# Install config file
install(
FILES ${CMAKE_BINARY_DIR}/lib/cmake/CharmLite/CharmLiteConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CharmLite
)
# Install charmrun
install(
PROGRAMS ${CHARM_ROOT}/bin/charmrun
DESTINATION bin
)