-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
89 lines (66 loc) · 2.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
cmake_minimum_required(VERSION 2.8.10)
# DEFAULTS
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
# Set Output Directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build/bin)
# Set Additional Module Path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/Modules.cmake/")
# Check for C++11 Support
#include(CheckCXXCompilerFlag)
#CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
#CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
#if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fstack-protector-all")
#elseif(COMPILER_SUPPORTS_CXX0X)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fstack-protector-all")
#else()
# message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
#endif()
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(SEND_ERROR "In-source builds are not allowed.")
endif ()
#set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_COLOR_MAKEFILE ON)
# Set Our Global Log Dir
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/build/lib)
option(MEMDEBUG "Enable Memory debugging with ASAN" OFF)
if(MEMDEBUG)
set (ASAN_FLAGS "-fsanitize=address -fno-omit-frame-pointer")
else()
set (ASAN_FLAGS "")
endif()
option(DEBUGSYMBOLS "Enable debugging symbols" OFF)
if(DEBUGSYMBOLS)
set (DEBUGSYMBOLS_FLAGS "-g")
else()
set (DEBUGSYMBOLS_FLAGS "")
endif()
option(VERBOSEWARNINGS "Enable Verbose Warnings during compilation" OFF)
if(VERBOSEWARNINGS)
set (VERBOSEWARNINGS_FLAGS "-Wall -Wextra")
else()
set (VERBOSEWARNINGS_FLAGS "")
endif()
# Setup the CMAKE C++ Compilation flags
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VERBOSEWARNINGS_FLAGS} ${DEBUGSYMBOLS_FLAGS} ${ASAN_FLAGS}")
# Variables
project (Chip8)
# Set Link Dependencies
set(linkdepend glfw GL GLEW)
if(MEMDEBUG)
set(linkdepend ${linkdepend} asan)
endif()
# Project Information
message(STATUS "Configuring ${PROJECT_NAME}...")
# Find Files
file(GLOB CPP_FILES *.cpp)
add_executable(${PROJECT_NAME} EXCLUDE_FROM_ALL ${CPP_FILES})
# Include Dir
include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
# Linker Libs
foreach(lib ${linkdepend})
target_link_libraries(${PROJECT_NAME} ${lib})
endforeach(lib)