Skip to content

Commit fce34ad

Browse files
committed
CMake: clearer sep. between the library and executable code
1 parent fd8983a commit fce34ad

File tree

6 files changed

+159
-157
lines changed

6 files changed

+159
-157
lines changed

src/CMakeLists.txt

Lines changed: 2 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,5 @@
11
add_subdirectory(QR-Code-scanner)
22
add_subdirectory(openpgp)
33
add_subdirectory(zxcvbn-c)
4-
5-
qt5_add_resources(RESOURCES ../qml.qrc)
6-
7-
# Compile source files (.h/.cpp)
8-
file(GLOB SOURCE_FILES
9-
"*.h"
10-
"*.cpp"
11-
"main/*.h"
12-
"main/*.cpp"
13-
"libwalletqt/WalletManager.cpp"
14-
"libwalletqt/WalletListenerImpl.cpp"
15-
"libwalletqt/Wallet.cpp"
16-
"libwalletqt/PassphraseHelper.cpp"
17-
"libwalletqt/PendingTransaction.cpp"
18-
"libwalletqt/TransactionHistory.cpp"
19-
"libwalletqt/TransactionInfo.cpp"
20-
"libwalletqt/QRCodeImageProvider.cpp"
21-
"libwalletqt/AddressBook.cpp"
22-
"libwalletqt/Subaddress.cpp"
23-
"libwalletqt/SubaddressAccount.cpp"
24-
"libwalletqt/UnsignedTransaction.cpp"
25-
"libwalletqt/WalletManager.h"
26-
"libwalletqt/Wallet.h"
27-
"libwalletqt/PassphraseHelper.h"
28-
"libwalletqt/PendingTransaction.h"
29-
"libwalletqt/TransactionHistory.h"
30-
"libwalletqt/TransactionInfo.h"
31-
"libwalletqt/QRCodeImageProvider.h"
32-
"libwalletqt/Transfer.h"
33-
"libwalletqt/AddressBook.h"
34-
"libwalletqt/Subaddress.h"
35-
"libwalletqt/SubaddressAccount.h"
36-
"libwalletqt/UnsignedTransaction.h"
37-
"daemon/*.h"
38-
"daemon/*.cpp"
39-
"model/*.h"
40-
"model/*.cpp"
41-
"qt/*.h"
42-
"qt/*.cpp"
43-
)
44-
if(APPLE)
45-
list(APPEND SOURCE_FILES "qt/macoshelper.mm")
46-
endif()
47-
48-
set(EXECUTABLE_FLAG)
49-
if(MINGW)
50-
set(EXECUTABLE_FLAG WIN32)
51-
52-
set(ICON ${PROJECT_SOURCE_DIR}/images/appicon.ico)
53-
set(ICON_RC ${CMAKE_CURRENT_BINARY_DIR}/icon.rc)
54-
set(ICON_RES ${CMAKE_CURRENT_BINARY_DIR}/icon.o)
55-
file(WRITE ${ICON_RC} "IDI_ICON1 ICON DISCARDABLE \"${ICON}\"")
56-
find_program(Qt5_WINDRES_EXECUTABLE NAMES windres x86_64-w64-mingw32-windres REQUIRED CMAKE_FIND_ROOT_PATH_BOTH)
57-
add_custom_command(OUTPUT ${ICON_RES} COMMAND ${Qt5_WINDRES_EXECUTABLE} ${ICON_RC} ${ICON_RES} MAIN_DEPENDENCY ${ICON_RC})
58-
list(APPEND RESOURCES ${ICON_RES})
59-
endif()
60-
61-
if(APPLE)
62-
set(ICON ${PROJECT_SOURCE_DIR}/images/appicon.icns)
63-
set_source_files_properties(${ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
64-
list(APPEND RESOURCES ${ICON})
65-
endif()
66-
67-
set(monero_wallet_gui_sources
68-
${SOURCE_FILES}
69-
${RESOURCES}
70-
)
71-
72-
if(NOT ANDROID)
73-
add_executable(monero-wallet-gui ${EXECUTABLE_FLAG} ${monero_wallet_gui_sources})
74-
else()
75-
add_library(monero-wallet-gui SHARED ${monero_wallet_gui_sources})
76-
set_target_properties(monero-wallet-gui PROPERTIES COMPILE_DEFINITIONS "ANDROID")
77-
endif()
78-
79-
set_target_properties(monero-wallet-gui PROPERTIES
80-
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
81-
MACOSX_BUNDLE TRUE
82-
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/share/Info.plist"
83-
)
84-
85-
# OpenGL
86-
target_include_directories(monero-wallet-gui PUBLIC ${OPENGL_INCLUDE_DIR})
87-
message(STATUS "OpenGL: include dir at ${OPENGL_INCLUDE_DIR}")
88-
message(STATUS "OpenGL: libraries at ${OPENGL_LIBRARIES}")
89-
90-
target_include_directories(monero-wallet-gui PUBLIC ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
91-
92-
target_include_directories(monero-wallet-gui PUBLIC
93-
${CMAKE_SOURCE_DIR}/monero/include
94-
${CMAKE_SOURCE_DIR}/monero/src
95-
${CMAKE_SOURCE_DIR}/monero/external/easylogging++
96-
${CMAKE_SOURCE_DIR}/monero/contrib/epee/include
97-
${CMAKE_SOURCE_DIR}/monero/external/qrcodegen
98-
${CMAKE_CURRENT_SOURCE_DIR}
99-
${CMAKE_CURRENT_SOURCE_DIR}/daemon
100-
${CMAKE_CURRENT_SOURCE_DIR}/libwalletqt
101-
${CMAKE_CURRENT_SOURCE_DIR}/model
102-
${CMAKE_CURRENT_SOURCE_DIR}/QR-Code-scanner
103-
${CMAKE_CURRENT_SOURCE_DIR}/zxcvbn-c
104-
${X11_INCLUDE_DIR}
105-
)
106-
107-
target_compile_definitions(monero-wallet-gui
108-
PUBLIC
109-
${Qt5Widgets_DEFINITIONS}
110-
${Qt5Qml_DEFINITIONS}
111-
)
112-
113-
if(APPLE)
114-
if(NOT ICU_ROOT)
115-
execute_process(COMMAND brew --prefix icu4c OUTPUT_VARIABLE ICU_ROOT OUTPUT_STRIP_TRAILING_WHITESPACE)
116-
endif()
117-
find_package(ICU REQUIRED COMPONENTS data i18n uc)
118-
target_link_directories(monero-wallet-gui PRIVATE ${ICU_ROOT}/lib)
119-
endif()
120-
121-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
122-
123-
target_link_libraries(monero-wallet-gui
124-
epee
125-
common
126-
net
127-
wallet_api
128-
qrcodegen
129-
easylogging
130-
${QT5_LIBRARIES}
131-
${EXTRA_LIBRARIES}
132-
openpgp
133-
qrdecoder
134-
translations
135-
zxcvbn
136-
)
137-
138-
if(X11_FOUND)
139-
target_link_libraries(monero-wallet-gui ${X11_LIBRARIES})
140-
endif()
141-
142-
if(WITH_SCANNER)
143-
target_link_libraries(monero-wallet-gui qrscanner)
144-
if(LINUX AND NOT ANDROID)
145-
target_link_libraries(monero-wallet-gui
146-
jpeg
147-
v4l2
148-
v4lconvert
149-
rt
150-
)
151-
endif()
152-
endif()
153-
154-
add_custom_command(TARGET monero-wallet-gui POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:daemon> $<TARGET_FILE_DIR:monero-wallet-gui>)
155-
156-
include(Deploy)
157-
158-
install(TARGETS monero-wallet-gui
159-
DESTINATION bin
160-
)
4+
add_subdirectory(libwalletqt)
5+
add_subdirectory(main)

src/libwalletqt/CMakeLists.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
set(PROJECT walletqt)
2+
3+
file(GLOB_RECURSE SOURCE_FILES *.cpp)
4+
file(GLOB_RECURSE HEADER_FILES *.h)
5+
6+
if(APPLE)
7+
list(APPEND SOURCE_FILES "../qt/macoshelper.mm")
8+
endif()
9+
10+
file(GLOB SOURCES_FOREIGN
11+
"../qt/*.cpp"
12+
"../daemon/*.cpp"
13+
"../model/*.cpp"
14+
)
15+
16+
file(GLOB FOREIGN_FOREIGN
17+
"../qt/*.h"
18+
"../daemon/*.h"
19+
"../model/*.h"
20+
)
21+
22+
add_library(${PROJECT}
23+
${SOURCE_FILES}
24+
${HEADER_FILES}
25+
${SOURCES_FOREIGN}
26+
${HEADERS_FOREIGN}
27+
)
28+
29+
target_include_directories(${PROJECT} PUBLIC
30+
${CMAKE_SOURCE_DIR}/monero/include
31+
${CMAKE_SOURCE_DIR}/monero/src
32+
${CMAKE_SOURCE_DIR}/monero/external/qrcodegen
33+
${CMAKE_SOURCE_DIR}/monero/external/easylogging++
34+
${CMAKE_SOURCE_DIR}/src
35+
${CMAKE_CURRENT_SOURCE_DIR}
36+
${CMAKE_SOURCE_DIR}/monero/contrib/epee/include
37+
${CMAKE_CURRENT_SOURCE_DIR}/QR-Code-scanner
38+
${CMAKE_CURRENT_SOURCE_DIR}/zxcvbn-c
39+
${X11_INCLUDE_DIR}
40+
)
41+
42+
target_link_libraries(${PROJECT}
43+
PUBLIC
44+
epee
45+
common
46+
net
47+
qrcodegen
48+
easylogging
49+
wallet_api
50+
${QT5_LIBRARIES}
51+
${EXTRA_LIBRARIES}
52+
openpgp
53+
qrdecoder
54+
translations
55+
zxcvbn
56+
)
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/main/CMakeLists.txt

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
2+
qt5_add_resources(RESOURCES ../../qml.qrc)
3+
4+
# Compile source files (.h/.cpp)
5+
file(GLOB SOURCE_FILES
6+
"*.h"
7+
"*.cpp"
8+
)
9+
10+
set(EXECUTABLE_FLAG)
11+
if(MINGW)
12+
set(EXECUTABLE_FLAG WIN32)
13+
14+
set(ICON ${PROJECT_SOURCE_DIR}/images/appicon.ico)
15+
set(ICON_RC ${CMAKE_CURRENT_BINARY_DIR}/icon.rc)
16+
set(ICON_RES ${CMAKE_CURRENT_BINARY_DIR}/icon.o)
17+
file(WRITE ${ICON_RC} "IDI_ICON1 ICON DISCARDABLE \"${ICON}\"")
18+
find_program(Qt5_WINDRES_EXECUTABLE NAMES windres x86_64-w64-mingw32-windres REQUIRED CMAKE_FIND_ROOT_PATH_BOTH)
19+
add_custom_command(OUTPUT ${ICON_RES} COMMAND ${Qt5_WINDRES_EXECUTABLE} ${ICON_RC} ${ICON_RES} MAIN_DEPENDENCY ${ICON_RC})
20+
list(APPEND RESOURCES ${ICON_RES})
21+
endif()
22+
23+
if(APPLE)
24+
set(ICON ${PROJECT_SOURCE_DIR}/images/appicon.icns)
25+
set_source_files_properties(${ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
26+
list(APPEND RESOURCES ${ICON})
27+
endif()
28+
29+
set(monero_wallet_gui_sources
30+
${SOURCE_FILES}
31+
${RESOURCES}
32+
)
33+
34+
if(NOT ANDROID)
35+
add_executable(monero-wallet-gui ${EXECUTABLE_FLAG} ${monero_wallet_gui_sources})
36+
else()
37+
add_library(monero-wallet-gui SHARED ${monero_wallet_gui_sources})
38+
set_target_properties(monero-wallet-gui PROPERTIES COMPILE_DEFINITIONS "ANDROID")
39+
endif()
40+
41+
set_target_properties(monero-wallet-gui PROPERTIES
42+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
43+
MACOSX_BUNDLE TRUE
44+
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/share/Info.plist"
45+
)
46+
47+
# OpenGL
48+
target_include_directories(monero-wallet-gui PUBLIC ${OPENGL_INCLUDE_DIR})
49+
message(STATUS "OpenGL: include dir at ${OPENGL_INCLUDE_DIR}")
50+
message(STATUS "OpenGL: libraries at ${OPENGL_LIBRARIES}")
51+
52+
target_include_directories(monero-wallet-gui PUBLIC ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
53+
54+
target_include_directories(monero-wallet-gui PUBLIC
55+
${CMAKE_CURRENT_SOURCE_DIR}
56+
)
57+
58+
target_compile_definitions(monero-wallet-gui
59+
PUBLIC
60+
${Qt5Widgets_DEFINITIONS}
61+
${Qt5Qml_DEFINITIONS}
62+
)
63+
64+
if(APPLE)
65+
if(NOT ICU_ROOT)
66+
execute_process(COMMAND brew --prefix icu4c OUTPUT_VARIABLE ICU_ROOT OUTPUT_STRIP_TRAILING_WHITESPACE)
67+
endif()
68+
find_package(ICU REQUIRED COMPONENTS data i18n uc)
69+
target_link_directories(monero-wallet-gui PRIVATE ${ICU_ROOT}/lib)
70+
endif()
71+
72+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
73+
74+
target_link_libraries(monero-wallet-gui
75+
walletqt
76+
${EXTRA_LIBRARIES}
77+
)
78+
79+
if(X11_FOUND)
80+
target_link_libraries(monero-wallet-gui ${X11_LIBRARIES})
81+
endif()
82+
83+
if(WITH_SCANNER)
84+
target_link_libraries(monero-wallet-gui qrscanner)
85+
if(LINUX AND NOT ANDROID)
86+
target_link_libraries(monero-wallet-gui
87+
jpeg
88+
v4l2
89+
v4lconvert
90+
rt
91+
)
92+
endif()
93+
endif()
94+
95+
add_custom_command(TARGET monero-wallet-gui POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:daemon> $<TARGET_FILE_DIR:monero-wallet-gui>)
96+
97+
include(Deploy)
98+
99+
install(TARGETS monero-wallet-gui
100+
DESTINATION bin
101+
)

0 commit comments

Comments
 (0)