-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
54 lines (42 loc) · 1.51 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
cmake_minimum_required(VERSION 3.5)
project(QNotepad)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_INSTALL_PREFIX "/usr/local")
else()
set(CMAKE_INSTALL_PREFIX "/usr")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(thirdparty/fmt)
option(CLASSIC "Only build features present in the classic Windows notepad (WinXP era)" ON)
if(NOT CLASSIC)
add_definitions(-DADVANCED)
endif(NOT CLASSIC)
include_directories(src) # This shouldn't be needed, but we do it so ui_mainwindow.h can see editor.h
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
file(GLOB SOURCES "src/*.cpp")
find_package(QT NAMES Qt5 COMPONENTS Widgets PrintSupport REQUIRED)
find_package(Qt5 COMPONENTS Widgets PrintSupport REQUIRED)
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
set(GIT_COMMIT "unknown")
endif()
add_definitions("-DGIT_COMMIT=\"${GIT_COMMIT}\"")
add_executable(qnotepad ${SOURCES})
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Haiku")
target_link_libraries(qnotepad Qt5::Widgets Qt5::PrintSupport fmt stdc++fs)
else()
target_link_libraries(qnotepad Qt5::Widgets Qt5::PrintSupport fmt)
endif()
install(TARGETS qnotepad DESTINATION bin)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install(FILES ${CMAKE_SOURCE_DIR}/qnotepad.desktop DESTINATION /usr/share/applications)
endif ()