-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
148 lines (134 loc) · 4.13 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
# ==================
# Target: generate
# ==================
if(CMAKE_CROSSCOMPILING)
find_package(genecpint)
else()
add_executable(generate
generate.cpp
lib/mathutil.cpp
lib/angular.cpp)
target_compile_features(generate PUBLIC cxx_std_11)
target_include_directories(generate
PRIVATE
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/include/libecpint
${CMAKE_CURRENT_BINARY_DIR}/../include/libecpint
)
export(
TARGETS
generate
FILE
"${CMAKE_BINARY_DIR}/genecpintConfig.cmake"
)
endif()
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated")
file(
COPY
"${CMAKE_CURRENT_SOURCE_DIR}/generated/ecpint_gen.part"
"${CMAKE_CURRENT_SOURCE_DIR}/generated/qgen.part"
DESTINATION
"${CMAKE_CURRENT_BINARY_DIR}/generated"
)
find_package (Python COMPONENTS Interpreter)
execute_process(COMMAND ${Python_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/makelist.py" "${LIBECPINT_MAX_L}" "${CMAKE_CURRENT_BINARY_DIR}")
file(READ "${CMAKE_CURRENT_BINARY_DIR}/qlist.txt" GENERATED_SOURCES)
STRING(REGEX REPLACE "\n" ";" GENERATED_SOURCES "${GENERATED_SOURCES}")
add_custom_command(
OUTPUT ${GENERATED_SOURCES}
COMMAND generate "${PROJECT_SOURCE_DIR}/include/libecpint/"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generated/ecpint_gen.part
COMMENT "Generating and unrolling integral code."
)
# ================
# Target: ecpint
# ================
file(GLOB_RECURSE LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/lib/*.cpp")
add_library(ecpint ${LIB_SOURCES} ${GENERATED_SOURCES})
add_library(ECPINT::ecpint ALIAS ecpint)
if(NOT BUILD_SHARED_LIBS)
set_property(TARGET ecpint PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
target_compile_features(ecpint PUBLIC cxx_std_11)
set_target_properties(ecpint PROPERTIES SOVERSION ${API_VERSION})
target_include_directories(ecpint
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/libecpint>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include/libecpint>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libecpint>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if (LIBECPINT_USE_CERF)
find_package(cerf CONFIG REQUIRED) # QUIET) # COMPONENTS C)
if(${cerf_FOUND})
get_property(_loc TARGET cerf::cerf PROPERTY LOCATION)
message(STATUS "${Cyan}Found cerf${ColourReset}: ${_loc}")
else()
if(${CMAKE_INSIST_FIND_PACKAGE_cerf})
message(FATAL_ERROR "Suitable cerf could not be externally located as user insists")
endif()
endif()
target_compile_definitions(ecpint PRIVATE USING_CERF=1)
target_link_libraries(ecpint
PRIVATE
cerf::cerf
)
else()
message(STATUS "${Cyan}Using Faddeeva${ColourReset}: internal")
target_link_libraries(ecpint
PRIVATE
Faddeeva
)
endif()
if(LIBECPINT_USE_PUGIXML)
target_include_directories(ecpint PRIVATE ${PUGIXML_INCLUDE_DIR})
target_link_libraries(ecpint PRIVATE libpugixml)
endif()
# =========
# Install
# =========
install(
TARGETS
ecpint
EXPORT
ecpintTargets
RUNTIME DESTINATION
${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION
${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION
${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}
)
include(CMakePackageConfigHelpers)
# Version file
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/ecpint-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
# Config file
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ecpint-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ecpint
)
# Targets files
export(
EXPORT ecpintTargets
FILE ${CMAKE_CURRENT_BINARY_DIR}/ecpint-targets.cmake
)
install(
EXPORT ecpintTargets
FILE ecpint-targets.cmake
NAMESPACE ECPINT::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ecpint
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/ecpint-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/ecpint-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ecpint
)