-
Notifications
You must be signed in to change notification settings - Fork 16
/
CMakeLists.txt
141 lines (107 loc) · 3.82 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
set( EXCHCXX_SOURCES
xc_kernel.cxx
xc_functional.cxx
libxc.cxx
boilerplate.cxx
builtin.cxx
builtin_interface.cxx
builtin_kernel.cxx
)
add_library( exchcxx ${EXCHCXX_SOURCES} )
# TARGET properties
target_compile_features( exchcxx PUBLIC cxx_std_17 )
target_link_libraries( exchcxx PUBLIC Libxc::xc )
# Generate exchcxx_config.hpp
configure_file(
${PROJECT_SOURCE_DIR}/include/exchcxx/exchcxx_config.hpp.in
${PROJECT_BINARY_DIR}/include/exchcxx/exchcxx_config.hpp
)
target_compile_definitions( exchcxx PUBLIC "EXCHCXX_HAS_CONFIG_H=1" )
# Device specific
if( EXCHCXX_ENABLE_CUDA )
include( cuda/exchcxx_cuda.cmake )
endif()
if( EXCHCXX_ENABLE_HIP )
include( hip/exchcxx_hip.cmake )
endif()
if( EXCHCXX_ENABLE_SYCL )
include( sycl/exchcxx_sycl.cmake )
endif()
target_include_directories( exchcxx
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
)
include( CheckCXXCompilerFlag )
check_cxx_compiler_flag( -Wall EXCHCXX_CXX_HAS_WALL )
check_cxx_compiler_flag( -Wextra EXCHCXX_CXX_HAS_WEXTRA )
check_cxx_compiler_flag( -Wpedantic EXCHCXX_CXX_HAS_WPEDANTIC )
check_cxx_compiler_flag( -Wnon-virtual-dtor EXCHCXX_CXX_HAS_WNON_VIRTUAL_DTOR )
check_cxx_compiler_flag( -Wshadow EXCHCXX_CXX_HAS_WSHADOW )
if( EXCHCXX_CXX_HAS_WALL )
target_compile_options( exchcxx PRIVATE $<$<COMPILE_LANGUAGE:CXX>: -Wall> )
endif()
if( EXCHCXX_CXX_HAS_WEXTRA )
target_compile_options( exchcxx PRIVATE $<$<COMPILE_LANGUAGE:CXX>: -Wextra> )
endif()
if( EXCHCXX_CXX_HAS_WPEDANTIC )
target_compile_options( exchcxx PRIVATE $<$<COMPILE_LANGUAGE:CXX>: -Wpedantic> )
endif()
if( EXCHCXX_CXX_HAS_WNON_VIRTUAL_DTOR )
target_compile_options( exchcxx PRIVATE $<$<COMPILE_LANGUAGE:CXX>: -Wnon-virtual-dtor -Werror=non-virtual-dtor> )
endif()
if( EXCHCXX_CXX_HAS_WSHADOW )
target_compile_options( exchcxx PRIVATE $<$<COMPILE_LANGUAGE:CXX>: -Wshadow -Werror=shadow> )
endif()
# INSTALL rules
add_library( ExchCXX::ExchCXX ALIAS exchcxx )
include( GNUInstallDirs )
set( INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/ExchCXX )
# Targets
install(TARGETS exchcxx
EXPORT exchcxx-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
set_target_properties( exchcxx PROPERTIES EXPORT_NAME ExchCXX )
# Install Headers
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.hpp" )
install(DIRECTORY ${PROJECT_BINARY_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.hpp" )
# Export target to script
install(EXPORT exchcxx-targets
FILE
ExchCXXTargets.cmake
NAMESPACE
ExchCXX::
DESTINATION
${INSTALL_CONFIGDIR}
)
# Export build-tree targets also (to be usable by e.g. FetchContent)
export(EXPORT exchcxx-targets
NAMESPACE ExchCXX::
FILE "${PROJECT_BINARY_DIR}/ExchCXXTargets.cmake")
#Create a ConfigVersion.cmake file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/ExchCXXConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
# Setup ExchCXXConfig.cmake
configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/ExchCXXConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ExchCXXConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
#Install the config, configversion and custom find modules
#install(DIRECTORY
# ${PROJECT_SOURCE_DIR}/cmake/
# DESTINATION ${INSTALL_CONFIGDIR}
# FILES_MATCHING PATTERN "*.cmake"
#)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/ExchCXXConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/ExchCXXConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)