-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
172 lines (136 loc) · 6.21 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
cmake_minimum_required(VERSION 3.14)
if(NOT DEFINED PRISM_VERSION)
file(READ "${CMAKE_CURRENT_LIST_DIR}/vcpkg.json" _contents)
string(JSON PRISM_VERSION GET "${_contents}" version)
endif()
project(prism_qt_core VERSION ${PRISM_VERSION} LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Gui Widgets Quick Qml QuickControls2 REQUIRED Sql)
find_package(prism COMPONENTS qt::modular container)
include_directories(${Qt${QT_VERSION_MAJOR}Quick_PRIVATE_INCLUDE_DIRS})
include_directories(${Qt${QT_VERSION_MAJOR}Core_PRIVATE_INCLUDE_DIRS})
option(VCPKG_DISABLE_TEST "disable run test when vcpkg install " OFF)
add_library(${PROJECT_NAME} SHARED
include/prism/qt/core/hpp/prismQt.hpp
include/prism/qt/core/hpp/prismQtJson.hpp
include/prism/qt/core/hpp/prismModelListProxy.hpp
include/prism/qt/core/hpp/prismModelProxy.hpp
include/prism/qt/core/hpp/prismTreeModelProxy.hpp
include/prism/qt/core/hpp/prismTreeNodeProxy.hpp
include/prism/qt/core/hpp/prismDataAccessLayer.hpp
include/prism/qt/core/hpp/prismQtTask.hpp
include/prism/qt/core/hpp/prismEnumProxy.hpp
include/prism/qt/core/helper/imagePaintedItem.h
include/prism/qt/core/helper/imagepainteditemqsg.h
include/prism/qt/core/helper/sortfilterproxymodel.h
include/prism/qt/core/helper/qeventloopguard.h
include/prism/qt/core/helper/condition_varaiable_guard.h
include/prism/qt/core/helper/prismdataaccesslayerbase.h
include/prism/qt/core/helper/stopwatch.h
include/prism/qt/core/prismQt_core_global.h
include/prism/qt/core/prismQt_events.h
src/helper/qeventloopguard.cpp
src/helper/condition_varaiable_guard.cpp
src/helper/bind.h src/helper/bind.cpp
src/helper/imagePaintedItem.cpp
src/helper/imagepainteditemqsg.cpp
src/helper/sortfilterproxymodel.cpp
src/helper/prismdataaccesslayerbase.cpp
src/helper/stopwatch.cpp
src/prismQt_core.h
src/prismQt_core.cpp
src/prismQt_core.qrc
)
add_library(prism::qt::core ALIAS ${PROJECT_NAME})
target_compile_definitions(${PROJECT_NAME} PRIVATE PRISM_QT_CORE_LIBRARY)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)
target_link_libraries(${PROJECT_NAME} PRIVATE
prism::prism
prism::qt::modular
prism::container
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Sql
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Qml
Qt${QT_VERSION_MAJOR}::QuickControls2)
#
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
configure_package_config_file("${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME})
install(EXPORT ${PROJECT_NAME}_Targets
FILE ${PROJECT_NAME}Targets.cmake
#NAMESPACE prism::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME})
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
# vcpkg
if(EXISTS ${VCPKG_ROOT})
execute_process( COMMAND git rev-parse --abbrev-ref HEAD WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE GIT_BRANCH_RESULT )
execute_process( COMMAND git rev-parse HEAD WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE )
string(REPLACE "_" "-" PORT_NAME "${PROJECT_NAME}")
configure_file(${PROJECT_SOURCE_DIR}/cmake/vcpkg.json.in ${VCPKG_ROOT}/ports/${PORT_NAME}/vcpkg.json @ONLY NEWLINE_STYLE LF)
configure_file(${PROJECT_SOURCE_DIR}/cmake/vcpkg.json.in ${PROJECT_SOURCE_DIR}/vcpkg.json @ONLY NEWLINE_STYLE LF)
configure_file(${PROJECT_SOURCE_DIR}/cmake/vcpkg_cus_info.json.in ${VCPKG_ROOT}/ports/${PORT_NAME}/vcpkg_cus_info.json @ONLY NEWLINE_STYLE LF)
file(COPY ${PROJECT_SOURCE_DIR}/cmake/portfile.cmake DESTINATION ${VCPKG_ROOT}/ports/${PORT_NAME})
endif()
#
#if( NOT VCPKG_DISABLE_TEST)
if(CMAKE_PROJECT_NAME STREQUAL "${PROJECT_NAME}" AND NOT VCPKG_DISABLE_TEST)
find_package(Catch2 REQUIRED)
include(CTest)
include(Catch)
#test prismQt json
set(TST_PRISMQTJSON_SOURCE
tests/test_prismQtJson.cpp
tests/models/test_model.h)
add_executable(tst_${PROJECT_NAME} ${TST_PRISMQTJSON_SOURCE} )
target_include_directories(tst_${PROJECT_NAME} PRIVATE include)
target_include_directories(tst_${PROJECT_NAME} PRIVATE ${prism_INCLUDE_DIRS})
target_link_libraries(tst_${PROJECT_NAME} PRIVATE
${PROJECT_NAME}
Catch2::Catch2
prism::prism
prism::qt::modular
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Sql
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Qml
Qt${QT_VERSION_MAJOR}::QuickControls2)
set_target_properties(tst_${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../bin/${CMAKE_SYSTEM_PROCESSOR}
)
#catch_discover_tests(tst_${PROJECT_NAME})
add_custom_target(run_tst_${PROJECT_NAME}
COMMAND ${CMAKE_CTEST_COMMAND} --verbose
DEPENDS tst_${PROJECT_NAME}
)
endif()
#execute_process(COMMAND ${CMAKE_COMMAND} -E echo "
#----------
#----------" )