-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
129 lines (93 loc) · 3.42 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
cmake_minimum_required(VERSION 3.18)
include(cmake/prelude.cmake)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake
CACHE STRING "Vcpkg toolchain file")
project(
tasarch
VERSION 0.1.0
DESCRIPTION "retroarch frontend for TASing"
HOMEPAGE_URL "https://org.anize.rs"
LANGUAGES CXX
)
docs_early_return()
include(cmake/project-is-top-level.cmake)
include(cmake/variables.cmake)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# ---- External Dependencies ----
add_subdirectory(external)
set(EXTERNAL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external)
set(SRC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
# for QT
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt6 COMPONENTS Widgets Core5Compat OpenGLWidgets REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(toml11 CONFIG REQUIRED)
find_package(asio CONFIG REQUIRED)
# find_package(cppcoro CONFIG REQUIRED)
# find_package(PkgConfig REQUIRED)
# pkg_check_modules(ELPP REQUIRED easyloggingpp)
# ---- Declare library ----
# add_library(
# tasarch_lib OBJECT
# source/lib.cpp
# )
# target_include_directories(
# tasarch_lib ${warning_guard}
# PUBLIC
# "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source>"
# )
# target_compile_features(tasarch_lib PUBLIC cxx_std_17)
# ---- Gather Files ----
# COMMON src and libs across all targets (testing, gui and "server")
set(COMMON_SRC_PATHS "${PROJECT_SOURCE_DIR}/src/log" "${PROJECT_SOURCE_DIR}/src/config" "${PROJECT_SOURCE_DIR}/src/gdb" "${PROJECT_SOURCE_DIR}/src/util")
set(COMMON_LIBS "fmt::fmt" "spdlog::spdlog" "toml11::toml11" "asio" "asio::asio")
# src and libs for only gui
set(UI_SRC_PATHS "src" "src/gui" "src/test" ${COMMON_SRC_PATHS})
set(UI_LIBS "Qt6::Widgets" "Qt6::OpenGLWidgets" ${COMMON_LIBS})
# function for globbing the src files
function(glob_src_files src_paths out_cpp_files out_h_files)
set(cpp_glob "")
set(h_glob "")
foreach(src_path IN LISTS src_paths)
set(cpp_glob "${src_path}/*.cpp" ${cpp_glob})
set(h_glob "${src_path}/*.h" "${src_path}/*.hpp" ${h_glob})
endforeach()
file(GLOB cpp_files ${cpp_glob})
file(GLOB h_files ${h_glob})
set(${out_cpp_files} ${cpp_files} PARENT_SCOPE)
set(${out_h_files} ${h_files} PARENT_SCOPE)
endfunction()
glob_src_files("${UI_SRC_PATHS}" CPP_FILES H_FILES)
file(GLOB UI_FILES "src/gui/*.ui")
# ---- Declare executable ----
add_executable(tasarch_exe ${CPP_FILES} ${H_FILES} ${UI_FILES})
add_executable(tasarch::exe ALIAS tasarch_exe)
set_target_properties(
tasarch_exe PROPERTIES
OUTPUT_NAME tasarch
EXPORT_NAME exe
)
target_compile_features(tasarch_exe PRIVATE cxx_std_20)
# set_property(TARGET tasarch_exe PROPERTY CXX_STANDARD 20)
source_group(TREE src PREFIX src FILES ${CPP_FILES} ${H_FILES} ${UI_FILES})
target_include_directories(tasarch_exe SYSTEM PUBLIC $<BUILD_INTERFACE:${EXTERNAL_INCLUDE_DIR}>)
target_include_directories(tasarch_exe PUBLIC $<BUILD_INTERFACE:${SRC_INCLUDE_DIR}>)
message(STATUS "Linking to libraries: ${UI_LIBS}")
target_link_libraries(tasarch_exe ${UI_LIBS})
# ---- Install rules ----
if(NOT CMAKE_SKIP_INSTALL_RULES)
include(cmake/install-rules.cmake)
endif()
# ---- Developer mode ----
if(NOT tasarch_DEVELOPER_MODE)
return()
elseif(NOT PROJECT_IS_TOP_LEVEL)
message(
AUTHOR_WARNING
"Developer mode is intended for developers of tasarch"
)
endif()
include(cmake/dev-mode.cmake)