Debian Codegraph @

monero/src/CMakeLists.txt

raw
1 # Copyright (c) 2014-2022, The Monero Project
2 #
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without modification, are
6 # permitted provided that the following conditions are met:
7 #
8 # 1. Redistributions of source code must retain the above copyright notice, this list of
9 # conditions and the following disclaimer.
10 #
11 # 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 # of conditions and the following disclaimer in the documentation and/or other
13 # materials provided with the distribution.
14 #
15 # 3. Neither the name of the copyright holder nor the names of its contributors may be
16 # used to endorse or promote products derived from this software without specific
17 # prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 # THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #
29 # Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30
31 if (WIN32 OR STATIC)
32 add_definitions(-DSTATICLIB)
33 # miniupnp changed their static define
34 add_definitions(-DMINIUPNP_STATICLIB)
35 endif ()
36
37 function (monero_private_headers group)
38 source_group("${group}\\Private"
39 FILES
40 ${ARGN})
41 endfunction ()
42
43 function (monero_install_headers subdir)
44 install(
45 FILES ${ARGN}
46 DESTINATION "include/${subdir}"
47 COMPONENT development)
48 endfunction ()
49
50 function (enable_stack_trace target)
51 if(STACK_TRACE)
52 set_property(TARGET ${target}
53 APPEND PROPERTY COMPILE_DEFINITIONS "STACK_TRACE")
54 if (STATIC)
55 set_property(TARGET "${target}"
56 APPEND PROPERTY LINK_FLAGS "-Wl,--wrap=__cxa_throw")
57 endif()
58 endif()
59 endfunction()
60
61 function (monero_add_executable name)
62 source_group("${name}"
63 FILES
64 ${ARGN})
65
66 add_executable("${name}"
67 ${ARGN})
68 target_link_libraries("${name}"
69 PRIVATE
70 ${EXTRA_LIBRARIES})
71 set_property(TARGET "${name}"
72 PROPERTY
73 FOLDER "prog")
74 set_property(TARGET "${name}"
75 PROPERTY
76 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
77 enable_stack_trace("${name}")
78
79 monero_set_target_no_relink("${name}")
80 monero_set_target_strip ("${name}")
81 endfunction ()
82
83 function (monero_add_library name)
84 monero_add_library_with_deps(NAME "${name}" SOURCES ${ARGN})
85 endfunction()
86
87 function (monero_add_library_with_deps)
88 cmake_parse_arguments(MONERO_ADD_LIBRARY "" "NAME" "DEPENDS;SOURCES" ${ARGN})
89 source_group("${MONERO_ADD_LIBRARY_NAME}" FILES ${MONERO_ADD_LIBRARY_SOURCES})
90
91 # Define a ("virtual") object library and an actual library that links those
92 # objects together. The virtual libraries can be arbitrarily combined to link
93 # any subset of objects into one library archive. This is used for releasing
94 # libwallet, which combines multiple components.
95 set(objlib obj_${MONERO_ADD_LIBRARY_NAME})
96 add_library(${objlib} OBJECT ${MONERO_ADD_LIBRARY_SOURCES})
97 add_library("${MONERO_ADD_LIBRARY_NAME}" $<TARGET_OBJECTS:${objlib}>)
98 if (MONERO_ADD_LIBRARY_DEPENDS)
99 add_dependencies(${objlib} ${MONERO_ADD_LIBRARY_DEPENDS})
100 endif()
101 set_property(TARGET "${MONERO_ADD_LIBRARY_NAME}" PROPERTY FOLDER "libs")
102 target_compile_definitions(${objlib}
103 PRIVATE $<TARGET_PROPERTY:${MONERO_ADD_LIBRARY_NAME},INTERFACE_COMPILE_DEFINITIONS>)
104 if (BUILD_GUI_DEPS)
105 target_compile_definitions(${objlib} PRIVATE BUILD_GUI_DEPS=1)
106 endif()
107 endfunction ()
108
109 include(Version)
110 monero_add_library(version SOURCES ${CMAKE_BINARY_DIR}/version.cpp DEPENDS genversion)
111
112 add_subdirectory(common)
113 add_subdirectory(crypto)
114 add_subdirectory(ringct)
115 add_subdirectory(checkpoints)
116 add_subdirectory(cryptonote_basic)
117 add_subdirectory(cryptonote_core)
118 add_subdirectory(lmdb)
119 add_subdirectory(multisig)
120 add_subdirectory(net)
121 add_subdirectory(hardforks)
122 add_subdirectory(mnemonics)
123 add_subdirectory(rpc)
124 add_subdirectory(wallet)
125
126 if(BUILD_DEBUG_UTILITIES)
127 add_subdirectory(debug_utilities)
128 endif()
129
130 add_subdirectory(device)
131 add_subdirectory(device_trezor)