-
Notifications
You must be signed in to change notification settings - Fork 372
/
Copy pathCMakeLists.txt
127 lines (109 loc) · 4.03 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
# Copyright (c) 2019, QuantStack and Mamba Contributors
#
# Distributed under the terms of the BSD 3-Clause License.
#
# The full license is in the file LICENSE, distributed with this software.
cmake_minimum_required(VERSION 3.16)
cmake_policy(SET CMP0025 NEW) # Introduced in cmake 3.0
cmake_policy(SET CMP0077 NEW) # Introduced in cmake 3.13
project(micromamba)
# Source files
# ============
set(
MICROMAMBA_SRCS
longpath.manifest
${CMAKE_CURRENT_SOURCE_DIR}/src/activate.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/clean.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/common_options.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/completer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/constructor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/create.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/env.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/info.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/install.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/list.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/login.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/package.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/remove.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/repoquery.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/run.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/shell.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/umamba.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/update.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/version.cpp
)
set(
MICROMAMBA_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/common_options.hpp
${CMAKE_CURRENT_SOURCE_DIR}/src/constructor.hpp
${CMAKE_CURRENT_SOURCE_DIR}/src/umamba.hpp
${CMAKE_CURRENT_SOURCE_DIR}/src/version.hpp
)
# Targets and link
# ================
find_package(Threads REQUIRED)
find_package(reproc REQUIRED)
find_package(reproc++ REQUIRED)
macro(mambaexe_create_target target_name linkage output_name)
string(TOUPPER "${linkage}" linkage_upper)
if(NOT ${linkage_upper} MATCHES "^(SHARED|STATIC)$")
message(FATAL_ERROR "Invalid library linkage: ${linkage}")
endif()
# Output
# ======
add_executable(${target_name} ${MICROMAMBA_SRCS} ${MICROMAMBA_HEADERS})
mamba_target_add_compile_warnings(${target_name} WARNING_AS_ERROR ${MAMBA_WARNING_AS_ERROR})
mamba_target_set_lto(${target_name} MODE ${MAMBA_LTO})
set_property(TARGET ${target_name} PROPERTY CXX_STANDARD 17)
target_link_libraries(${target_name} PRIVATE Threads::Threads reproc reproc++)
# Static build
# ============
if(${linkage_upper} STREQUAL "STATIC")
if(NOT (TARGET mamba::libmamba-static))
find_package(libmamba REQUIRED)
endif()
target_link_libraries(${target_name} PRIVATE mamba::libmamba-static)
if(APPLE)
target_link_options(${target_name} PRIVATE -nostdlib++)
endif()
# Dynamic build
# =============
else()
if(NOT (TARGET mamba::libmamba-dyn))
find_package(libmamba REQUIRED)
endif()
target_link_libraries(${target_name} PRIVATE mamba::libmamba-dyn)
endif()
list(APPEND mambaexe_targets ${target_name})
endmacro()
set(mambaexe_targets "")
if(BUILD_SHARED)
message(STATUS "Adding executable mamba")
mambaexe_create_target(mamba SHARED mamba)
endif()
if(BUILD_STATIC)
message(STATUS "Adding executable micromamba")
mambaexe_create_target(micromamba STATIC micromamba)
endif()
# Installation
# ============
# This profile script is only needed for mamba on Unix systems.
if(BUILD_SHARED AND UNIX)
message(STATUS "Generating profile script for mamba (i.e. `etc/profile.d/mamba.sh`)")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/etc/profile.d/mamba.sh.in"
"${CMAKE_CURRENT_BINARY_DIR}/etc/profile.d/mamba.sh"
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/etc/profile.d/mamba.sh
DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/profile.d/
)
endif()
install(
TARGETS ${mambaexe_targets}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)