-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
70 lines (56 loc) · 2.62 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
cmake_minimum_required(VERSION 3.15.0)
project(ExampleQt VERSION 1.0.0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# locate packages
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets})
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
find_package(spdlog CONFIG REQUIRED)
set(LIBRARY_SOURCES lib/LayerCake.cpp)
add_library(StaticLibrary STATIC ${LIBRARY_SOURCES})
if (MSVC)
# we apply the static CRT for MSVC
set_property(TARGET StaticLibrary PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# dismiss several warnings
target_compile_options(StaticLibrary PRIVATE -wd4996)
else()
# dismiss several warnings
target_compile_options(StaticLibrary PRIVATE -Wno-deprecated-declarations)
endif()
target_include_directories(StaticLibrary PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc")
target_link_libraries(StaticLibrary PRIVATE spdlog::spdlog spdlog::spdlog_header_only)
set(LOCALIZATION_SOURCES app/localization/LanguageManager.cpp
app/localization/StringIDs.cpp
app/localization/English.cpp
app/localization/German.cpp)
set(APP_SOURCES app/main.cpp
app/MainDlg.cpp
${LOCALIZATION_SOURCES})
set(APP_RESOURCE res/resource.qrc)
if (MSVC)
# include MSVS's native resource file
set(APP_RESOURCE app/Application.rc ${APP_RESOURCE})
endif()
configure_file (version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/app/version.h)
add_executable(${PROJECT_NAME} ${APP_SOURCES} ${APP_RESOURCE})
if (MSVC)
# we apply the static CRT for MSVC
set_property(TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
if (CMAKE_BUILD_TYPE MATCHES ".*Rel.*")
# this magic setting makes our app native to Windows (just for Release builds)
# otherwise we'll create a "console" app
set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE ON)
endif()
# dismiss several warnings
target_compile_options(${PROJECT_NAME} PRIVATE -wd4996)
else()
# dismiss several warnings
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-deprecated-declarations -Wnarrowing)
endif()
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc")
target_link_libraries(${PROJECT_NAME} PRIVATE StaticLibrary)
target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog spdlog::spdlog_header_only)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)