This repository has been archived by the owner on Jun 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
87 lines (71 loc) · 2.91 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
cmake_minimum_required(VERSION 3.15)
project(sdklauncher CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Qt
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "..." FORCE)
endif()
if(UNIX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(QT_INCLUDE "/usr/include/x86_64-linux-gnu/qt5")
endif()
if(WIN32)
set(CMAKE_CXX_STANDARD 23)
# On Windows, the install dir must be specified, as it's not standardized
if(DEFINED QT_BASEDIR)
# Add it to the prefix path so find_package can find it
list(APPEND CMAKE_PREFIX_PATH ${QT_BASEDIR})
set(QT_INCLUDE ${QT_BASEDIR}/include)
# CMake has an odd policy that links a special link lib for Qt on newer versions of CMake. Enable it so we don't get spammed, and I get to write less
cmake_policy(SET CMP0020 NEW)
else()
message(FATAL_ERROR "--!@ Please define your QT install dir with -DQT_BASEDIR=C:/your/qt5/here")
endif()
endif()
message("Using ${QT_INCLUDE} as our Qt include dir")
find_package(Qt5 REQUIRED COMPONENTS Widgets Core Gui)
list(APPEND LINK_LIBS Qt5::Widgets Qt5::Core Qt5::Gui keyvalues SAPP)
list(APPEND INC_DIRS ${QT_INCLUDE} ${QT_INCLUDE}/QtWidgets ${QT_INCLUDE}/QtGui ${QT_INCLUDE}/QtCore)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
option(USE_STEAM "Uses steam" OFF)
# Steam
if(USE_STEAM)
set(STEAM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/steam)
add_library(steam_api64 SHARED IMPORTED)
include_directories("${STEAM_DIR}/public/steam")
list(APPEND LINK_DIRS "${STEAM_DIR}/redistributable_bin")
if (WIN32)
list(APPEND LINK_LIBS win64/steam_api64)
else()
list(APPEND LINK_LIBS ${CMAKE_BINARY_DIR}/libsteam_api.so)
endif()
add_compile_definitions(USE_STEAM)
endif()
# Main Application
set(SRC
src/mainview.h
src/mainview.cpp
src/main.cpp src/config.h src/editconfig.cpp src/editconfig.h)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/libs/SpeedyKeyV")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/libs/SAPP")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/libs/SpeedyKeyV")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/libs/SAPP")
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(${PROJECT_NAME} ${SRC} res/resource.qrc)
target_link_libraries(${PROJECT_NAME} PRIVATE ${LINK_LIBS})
target_link_directories(${PROJECT_NAME} PUBLIC ${LINK_DIRS})
target_include_directories(${PROJECT_NAME} PRIVATE ${INC_DIRS})
if(WIN32)
# Set up the debugger so it can run the program without copying a million dlls
set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=%PATH%;${QT_BASEDIR}/bin;")
# Copy the steam windows binary
if(USE_STEAM)
configure_file("${STEAM_DIR}/redistributable_bin/win64/steam_api64.dll" "${CMAKE_BINARY_DIR}/steam_api64.dll" COPYONLY)
endif()
endif()
if(UNIX AND USE_STEAM)
configure_file("${STEAM_DIR}/redistributable_bin/linux64/libsteam_api.so" "${CMAKE_BINARY_DIR}/libsteam_api.so" COPYONLY)
endif()