-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
106 lines (81 loc) · 2.89 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
cmake_minimum_required(VERSION 3.24)
project(RedundantCoding VERSION 0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake)
set(INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include)
set(SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/source)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(BOOST_ENABLE_CMAKE ON)
set(MAKE_TEST_EXE ON)
set(QT_INCLUDE_LIBRARIES Core Quick Concurrent)
set(BOOST_COMPONENTS regex filesystem)
set(GTEST_LINK gtest_main gmock_main)
#CMakeConfig.hpp Constants
add_definitions(-DROOT_PATH_CMAKE=${CMAKE_CURRENT_SOURCE_DIR})
#Macros
include(${CMAKE_DIR}/UpdateSubmodules.cmake)
include(${CMAKE_DIR}/AddFiles.cmake)
#QT6 is required to be installed
find_package(Qt6 6.4 REQUIRED COMPONENTS ${QT_INCLUDE_LIBRARIES})
#Boost has to be installed on operating system
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
#GTest can be downloaded via git submodules
if(MAKE_TEST_EXE)
find_package(GTest)
endif()
#Set dependencies if found or not by find_package
#If not found then get from git submodules
add_subdirectory(dependencies)
#Create executable
qt_standard_project_setup()
qt_add_executable(appRedundantCoding)
qt_policy(SET QTP0001 NEW)
#Get cpp files to add to Executables
file(GLOB_RECURSE SOURCE_FILES ${SOURCE_DIR}/*.cpp)
#Get include files to add to Executables (Required for MOC)
file(GLOB_RECURSE INCLUDE_FILES ${INCLUDE_DIR}/*.hpp)
#Get project files
add_subdirectory(include)
add_subdirectory(source)
add_subdirectory(source_gui)
add_subdirectory(assets)
#Files in include can be included with just a file name now
target_include_directories(appRedundantCoding PRIVATE
${INCLUDE_DIR}
)
if(${Boost_FOUND})
target_include_directories(appRedundantCoding PRIVATE ${Boost_INCLUDE_DIRS})
endif()
#Transform library names into proper form for linking
list(TRANSFORM QT_INCLUDE_LIBRARIES PREPEND "Qt6::")
list(TRANSFORM GTEST_LINK PREPEND "GTest::")
#Link to main application
target_link_libraries(appRedundantCoding
PRIVATE ${Boost_LIBRARIES} ${QT_INCLUDE_LIBRARIES}
)
#Add resources and GUI files
qt_add_qml_module(appRedundantCoding
URI RedundantCoding
VERSION 1.0
RESOURCE_PREFIX "/"
QML_FILES ${QML_FILES}
RESOURCES ${RESOURCES}
)
#Create separate Tester executables that runs tests
if(MAKE_TEST_EXE)
include(CTest)
add_subdirectory(tests)
endif()
set_target_properties(appRedundantCoding PROPERTIES
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
install(TARGETS appRedundantCoding
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
#cmake -B build -S . -G "MinGW Makefiles" && cd build && make && cd ..
#cmake -B build -S . -G "MinGW Makefiles" && cd build && make && cd tests && export GTEST_COLOR=1 && ./Tester.exe