-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
111 lines (87 loc) · 2.77 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
cmake_minimum_required(VERSION 3.16)
# Read version from VERSION.txt
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/resources/VERSION.txt" VERSION_CONTENTS)
string(STRIP "${VERSION_CONTENTS}" APP_VERSION)
# Project definition
project(nepdate VERSION ${APP_VERSION} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Platform-specific settings
if (WIN32)
message(STATUS "Configuring for Windows")
elseif (UNIX AND NOT APPLE)
message(STATUS "Configuring for Linux")
endif()
# Find Qt version
find_package(Qt6 QUIET COMPONENTS Widgets Gui Core)
if (NOT Qt6_FOUND)
find_package(Qt5 QUIET COMPONENTS Widgets Gui Core)
if (NOT Qt5_FOUND)
message(FATAL_ERROR "Neither Qt6 nor Qt5 could be found")
else()
set(QT_VERSION_MAJOR 5)
message(STATUS "Configuring Using Qt5")
endif()
else()
set(QT_VERSION_MAJOR 6)
message(STATUS "Configuring Using Qt6")
endif()
# Set AUTOMOC, AUTORCC, and AUTOUIC to automatically generate necessary files
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
# Helper function to add executables
function(add_nepdate_executable target_name sources headers forms resources)
add_executable(${target_name} ${sources} ${headers} ${forms} ${resources})
if (${QT_VERSION_MAJOR} EQUAL 6)
target_link_libraries(${target_name} PRIVATE Qt6::Widgets Qt6::Gui Qt6::Core)
elseif(${QT_VERSION_MAJOR} EQUAL 5)
target_link_libraries(${target_name} PRIVATE Qt5::Widgets Qt5::Gui Qt5::Core)
endif()
endfunction()
# Define nepdate-widget executable
set(NEPDATE_WIDGET_SOURCES
main.cpp
mainwindow.cpp
calendarwindow.cpp
)
set(NEPDATE_WIDGET_HEADERS
mainwindow.h
bikram.h
DayTithiWidget.h
panchanga.h
calendarwindow.h
)
set(NEPDATE_WIDGET_FORMS
mainwindow.ui
calendarwindow.ui
)
set(NEPDATE_WIDGET_RESOURCES
resources.qrc
)
add_nepdate_executable(nepdate_widget "${NEPDATE_WIDGET_SOURCES}" "${NEPDATE_WIDGET_HEADERS}" "${NEPDATE_WIDGET_FORMS}" "${NEPDATE_WIDGET_RESOURCES}")
# Set the output name to nepdate-widget
set_target_properties(nepdate_widget PROPERTIES OUTPUT_NAME nepdate-widget)
# Define nepdate-calendar executable
set(NEPDATE_CALENDAR_SOURCES
main_calendar.cpp
calendarwindow.cpp
mainwindow.cpp
)
set(NEPDATE_CALENDAR_HEADERS
calendarwindow.h
DayTithiWidget.h
bikram.h
panchanga.h
mainwindow.h
)
set(NEPDATE_CALENDAR_FORMS
calendarwindow.ui
mainwindow.ui
)
set(NEPDATE_CALENDAR_RESOURCES
resources.qrc
)
add_nepdate_executable(nepdate_calendar "${NEPDATE_CALENDAR_SOURCES}" "${NEPDATE_CALENDAR_HEADERS}" "${NEPDATE_CALENDAR_FORMS}" "${NEPDATE_CALENDAR_RESOURCES}")
# Set the output name to nepdate-calendar
set_target_properties(nepdate_calendar PROPERTIES OUTPUT_NAME nepdate-calendar)