-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
74 lines (58 loc) · 1.87 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
cmake_minimum_required(VERSION 3.5)
project(powermenu)
# C++11
set(CMAKE_CXX_STANDARD 11)
# Default to release variant
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
function(load_env_file filepath)
file(READ ${filepath} content)
# Split the content into lines
string(REPLACE "\n" ";" lines ${content})
foreach(line IN LISTS lines)
# Check if the line is not empty
if(NOT line STREQUAL "")
# Strip whitespace from the line
string(STRIP ${line} stripped_line)
# Skip comments and invalid lines
if (stripped_line MATCHES "^[^#].*") # Ignore lines starting with #
string(REPLACE "=" ";" var_list ${stripped_line})
list(LENGTH var_list num_elements)
if(num_elements GREATER 1)
list(GET var_list 0 var_name)
list(GET var_list 1 var_value)
set(${var_name} ${var_value} PARENT_SCOPE)
endif()
endif()
endif()
endforeach()
endfunction()
load_env_file(${CMAKE_CURRENT_SOURCE_DIR}/.env)
# Set the API key from the environment variable
set(SYNCTHING_API_KEY ${SYNCTHING_API_KEY})
# Create a header file with the API key
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/syncthingApiKey.h.in
${CMAKE_CURRENT_BINARY_DIR}/src/syncthingApiKey.h # Place the output in the build directory
@ONLY
)
find_package(Qt5Widgets REQUIRED)
# Source files
set(SOURCES
src/main.cpp
src/mainWindow.cpp
)
# Header files
set(HEADERS
src/mainWindow.h
)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
add_executable(powermenu ${SOURCES} ${HEADERS} ${MOC_SOURCES})
# Include the generated header file location
target_include_directories(powermenu PRIVATE
include
${CMAKE_CURRENT_BINARY_DIR}/src
)
target_link_libraries(powermenu Qt5::Widgets)
set(CMAKE_AUTOMOC ON)