-
Notifications
You must be signed in to change notification settings - Fork 110
/
CMakeLists.txt
100 lines (88 loc) · 3.77 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
# Root CMake file
cmake_minimum_required(VERSION 3.4)
project(FX)
# Project configurations
set(CMAKE_CONFIGURATION_TYPES Debug Release)
set(CMAKE_DEBUG_POSTFIX _Debug)
set(CMAKE_RELEASE_POSTFIX _Release)
# Set output folders
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin )
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin )
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/lib )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
# All projects use unicode define
# this is mainly for windows functions either being defined to call A or W prefixed functions
add_definitions(-DUNICODE -D_UNICODE)
# Precompiled header macro
# src = Path to source files
# pchSrc = Path to precompiled header source file
macro(enable_precompiled_headers src pchSrc)
if(MSVC)
message("Enabling precompiled header generated from source file ${pchSrc}")
message("Files using precompiled headers => ${src}")
# Set precompiled header usage
set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS "/Yu")
# Set precompiled header
set_source_files_properties(${pchSrc} PROPERTIES COMPILE_FLAGS "/Yc")
endif(MSVC)
endmacro(enable_precompiled_headers)
# Excludes a file from precompiled header usage
macro(precompiled_header_exclude exclude)
if(MSVC)
# Excluded files
set_source_files_properties(${exclude} PROPERTIES COMPILE_FLAGS "")
endif(MSVC)
endmacro(precompiled_header_exclude)
# Function to enable c++11 compilation on linux
macro(enable_cpp11)
if(UNIX)
# C++11 support enabled for linux compilers
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
endif(UNIX)
endmacro(enable_cpp11)
# Set output binary postfixes so that they will be named <project>_<configuration>.exe/dll
macro(set_output_postfixes projectName)
set_target_properties(${projectName} PROPERTIES
OUTPUT_NAME_DEBUG ${projectName}_Debug
OUTPUT_NAME_RELEASE ${projectName}_Release)
endmacro(set_output_postfixes)
# Sub-Project directories
add_subdirectory(third_party)
add_subdirectory(Shared)
add_subdirectory(Graphics)
add_subdirectory(Main)
add_subdirectory(Audio)
add_subdirectory(Beatmap)
add_subdirectory(GUI)
# Unit test projects
add_subdirectory(Tests)
add_subdirectory(Tests.Shared)
add_subdirectory(Tests.Game)
# Enabled project filters on windows
if(MSVC)
# Use filters in VS projects
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Put all third party libraries in a seperate folder in the VS solution
set_target_properties(jpeg PROPERTIES FOLDER "Third Party")
set_target_properties(png PROPERTIES FOLDER "Third Party")
set_target_properties(zlib PROPERTIES FOLDER "Third Party")
set_target_properties(ogg PROPERTIES FOLDER "Third Party")
set_target_properties(vorbis PROPERTIES FOLDER "Third Party")
set_target_properties(freetype PROPERTIES FOLDER "Third Party")
set_target_properties(SDL2 PROPERTIES FOLDER "Third Party")
# My libraries in the libraries folder
set_target_properties(Shared PROPERTIES FOLDER Libraries)
set_target_properties(Graphics PROPERTIES FOLDER Libraries)
set_target_properties(Audio PROPERTIES FOLDER Libraries)
set_target_properties(Beatmap PROPERTIES FOLDER Libraries)
set_target_properties(GUI PROPERTIES FOLDER Libraries)
# Unit tests
set_target_properties(Tests PROPERTIES FOLDER "Tests")
set_target_properties(Tests.Shared PROPERTIES FOLDER "Tests")
set_target_properties(Tests.Game PROPERTIES FOLDER "Tests")
endif(MSVC)