-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCMakeLists.txt
77 lines (60 loc) · 1.86 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
cmake_minimum_required(VERSION 3.21.2)
# C++20标准
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 导出动态库
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# 导出ninja编译命令
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
string(TIMESTAMP COMPILE_TIME %Y-%m-%d)
set(NEOBOX_BUILD_TIME ${COMPILE_TIME})
set(target_name neobox)
project(${target_name} VERSION 2.4.6 LANGUAGES CXX C)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
add_definitions(-D_DEBUG)
message("====== defined _DEBUG ======")
else()
add_definitions(-D_RELEASE)
message("====== defined _RLEASE ======")
endif()
if (WIN32)
add_definitions(-DUNICODE -D_UNICODE)
endif()
if(MSVC)
add_compile_options("/utf-8")
endif()
function(load_resources plugin_name files_list)
message("- <${plugin_name}> ${${files_list}}")
file(GLOB _resource_files ${${files_list}})
set(resource_files)
foreach(full_filepath ${_resource_files})
file(RELATIVE_PATH file_path ${CMAKE_CURRENT_SOURCE_DIR} ${full_filepath})
message(STATUS "res: '${file_path}'")
list(APPEND resource_files ${file_path})
endforeach()
qt_add_resources(${plugin_name} "${plugin_name}"
PREFIX "/"
FILES ${resource_files}
)
message("- <${plugin_name}>")
endfunction()
link_directories(build/pluginmgr)
add_subdirectory(pluginmgr)
add_subdirectory(example)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
add_executable(${target_name} WIN32 main.cpp logo.rc)
target_link_libraries(${target_name} PUBLIC
pluginmgr
Qt6::Widgets
)
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "None")
message("set runtime lib path.")
set_target_properties(${target_name} PROPERTIES
INSTALL_RPATH "$ORIGIN;/usr/lib;$ORIGIN/../lib")
endif()
if(MSVC)
target_compile_options(${target_name} PRIVATE /W4 /WX)
else()
target_compile_options(${target_name} PRIVATE -Wall -Wextra -pedantic) # -Werror
endif()
install(TARGETS ${target_name})