-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
72 lines (56 loc) · 2.05 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
# ##
# @author Yanqing Wu, Junwen Shen
# @email [email protected]
# @create date 2023-02-10 05:37:39
# @modify date 2023-03-24 23:18:07
# @desc This is the top-level CMakeLists.txt
# ##
cmake_minimum_required(VERSION 3.10)
# Set the project name and application name
project(fillgame VERSION 0.1.0 LANGUAGES CXX)
# IMPORTANT: set if to build with Qt GUI or not! Whenever switched the choice; do `rm -rf build/`
option(IS_BUILD_GUI "to build with Qt GUI or not" OFF)
# ################################
# Following is a temporary fix for VSCode GUI Dev; comment it out if you don't develop GUI
# set(IS_BUILD_GUI ON)
# ################################
if(IS_BUILD_GUI)
message(STATUS "\nBuilding with Qt GUI...\n")
# Turn on automatic invocation of the MOC, UIC & RCC
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
# Find the QtWidgets library
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets Core Gui Network REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets Core Gui Network REQUIRED)
else()
message(STATUS "\nBuilding without Qt GUI...\n")
endif()
# 3rd party; should be above our own settings
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG b796f7d44681514f58a683a3a71ff17c94edb0c1 # release-1.13.0
)
if(WIN32)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif()
FetchContent_MakeAvailable(googletest)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Add compiler flags
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
elseif(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wreorder")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
# Find includes in the build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Set directory variables for usage in child CMakeLists.txt
set(FILLGAME_PROJ_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(FILLGAME_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
# sub directory's CMakeLists.txt
add_subdirectory(src)
add_subdirectory(test)