-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
105 lines (87 loc) · 2.81 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
cmake_minimum_required(VERSION 3.25)
project(NDSFactory)
# Require Qt6 components
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
# Include sanitizers
include(${CMAKE_SOURCE_DIR}/cmake/sanitizers.cmake)
# Determine the Git commit hash if in a git repository
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
set(GIT_COMMIT_HASH "")
endif()
# Configure the revision header file
configure_file(
${CMAKE_SOURCE_DIR}/ui/dialogs/about/revision.h.in
${CMAKE_SOURCE_DIR}/ui/dialogs/about/revision.h
)
# Collect source and header files
## Dialogs
file(GLOB_RECURSE DIALOGS_HEADERS ui/dialogs/*.h)
file(GLOB_RECURSE DIALOGS_SOURCES ui/dialogs/*.cpp)
file(GLOB_RECURSE DIALOGS_UIS ui/dialogs/*.ui)
## Tabs
file(GLOB_RECURSE TABS_HEADERS ui/tabs/*.h)
file(GLOB_RECURSE TABS_SOURCES ui/tabs/*.cpp)
## Models
file(GLOB_RECURSE MODELS_HEADERS ui/models/*.h)
file(GLOB_RECURSE MODELS_SOURCES ui/models/*.cpp)
## Utils
file(GLOB_RECURSE UTILS_HEADERS ui/utils/*.h)
## NDSFactory
file(GLOB_RECURSE NDSFACTORY_SOURCES ndsfactory/*.cpp)
file(GLOB_RECURSE NDSFACTORY_HEADERS ndsfactory/*.h)
set(SOURCES
main.cpp
ui/mainwindow.cpp
${NDSFACTORY_SOURCES}
${DIALOGS_SOURCES}
${MODELS_SOURCES}
${TABS_SOURCES}
)
SET(HEADERS
ui/mainwindow.h
${NDSFACTORY_HEADERS}
${TABS_HEADERS}
${MODELS_HEADERS}
${DIALOGS_HEADERS}
${UTILS_HEADERS}
)
set(FORMS
ui/mainwindow.ui
${DIALOGS_UIS}
)
# Platform-specific executable creation
if(APPLE)
set(MACOSX_BUNDLE_ICON_FILE ndsfactory.icns)
set(MACOS_ICNS "res/ndsfactory.icns")
set_source_files_properties(${MACOS_ICNS} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${SOURCES} ${HEADERS} ${FORMS} ${MACOS_ICNS})
elseif(WIN32)
set(WIN32_RESOURCES "res/resources.rc")
add_executable(${PROJECT_NAME} WIN32 ${SOURCES} ${HEADERS} ${FORMS} ${WIN32_RESOURCES})
else()
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${FORMS})
endif()
# Set C++ standard for the target
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
# Enable Qt's automatic features for the target
set_target_properties(${PROJECT_NAME} PROPERTIES
AUTOMOC ON
AUTOUIC ON
)
# Add compile options for different compilers
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /WX /W4 /EHsc)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror)
endif()
# Link the necessary Qt6 libraries
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets)