-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt.mako
62 lines (50 loc) · 1.55 KB
/
CMakeLists.txt.mako
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
cmake_minimum_required(VERSION 3.12)
project(gend_libs)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_INCLUDE_HEADERS_IN_COMPILE_COMMANDS ON)
include(GNUInstallDirs)
<%!
def format_sources(sources):
return " ".join(sources)
%>
# Loop over libraries to create shared libraries and set up install rules
% for library in libraries:
add_library(${library['name']} SHARED
${format_sources(library['sources'])}
)
target_include_directories(${library['name']} PUBLIC
<%text>$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/</%text>${library['name']}/include>
<%text>$<INSTALL_INTERFACE</%text>:${library['name']}/include>
)
install(
TARGETS ${library['name']}
<%text> EXPORT codegenTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
</%text>
)
install(
DIRECTORY ${library['name']}/include/
DESTINATION ${library['name']}/include
)
% endfor
<%text>
# Install target export
install(EXPORT codegenTargets
FILE codegenTargets.cmake
NAMESPACE codegen::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/codegen
)
# Configure package configuration file
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/codegenConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/codegenConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/codegen
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/codegenConfig.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/codegen
)
</%text>