-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
116 lines (91 loc) · 2.75 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
cmake_minimum_required(VERSION 3.10)
#--------------------------------------------------------------------------------------------------
# variables
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test)
set(PROJECT_NAME ArchitectureMVC)
set(TEST_NAME UnitTest)
#--------------------------------------------------------------------------------------------------
# project
project(${PROJECT_NAME})
if (MSVC)
# enable VS-Solution filters support
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif (MSVC)
#--------------------------------------------------------------------------------------------------
# builds
add_executable(${PROJECT_NAME}
${SRC_DIR}/Document.cpp
${SRC_DIR}/EditorController.cpp
${SRC_DIR}/Line.cpp
${SRC_DIR}/MainWindow.cpp
${SRC_DIR}/Rectangle.cpp
${SRC_DIR}/main.cpp
)
add_executable(${TEST_NAME}
${TEST_DIR}/tests.cpp
)
# properties
set_target_properties(${PROJECT_NAME} ${TEST_NAME}
PROPERTIES
CXX_STANDARD 23
CXX_STANDARD_REQUIRED ON
)
#--------------------------------------------------------------------------------------------------
# gtest
#
find_package(GTest REQUIRED)
# add src to the include directories for the test target
target_include_directories(${TEST_NAME}
PRIVATE
${SRC_DIR}
${GTEST_INCLUDE_DIRS}
${GTEST_LIBRARY}
${GTEST_INCLUDE_DIR}
${GTEST_MAIN_LIBRARY}
)
# link test target against gtest libraries
target_link_libraries(${TEST_NAME}
PRIVATE
GTest::gtest
GTest::gtest_main
#GTest::gmock
#GTest::gmock_main
)
#--------------------------------------------------------------------------------------------------
# compiler settings
if (MSVC)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
add_compile_options("/std:c++latest")
target_compile_options(${PROJECT_NAME} PRIVATE
/W4
)
target_compile_options(${TEST_NAME} PRIVATE
/W4
)
else ()
target_compile_options(${PROJECT_NAME} PRIVATE
-std=c++23 -Wall -Wextra -pedantic -Werror
)
target_compile_options(${TEST_NAME} PRIVATE
-std=c++23 -Wall -Wextra -pedantic -Werror
)
endif (MSVC)
#--------------------------------------------------------------------------------------------------
# deb pkg
if (UNIX)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
set(CPACK_GENERATOR DEB)
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_CONTACT 155024765+ProphetRu@users.noreply.github.com)
include(CPack)
endif (UNIX)
#--------------------------------------------------------------------------------------------------
# testing
enable_testing()
include(GoogleTest)
gtest_discover_tests(${TEST_NAME})