-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
109 lines (102 loc) · 3.37 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
cmake_minimum_required(VERSION 3.3)
project(SimpleChess)
# Find SFML
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/deps/SFML/cmake/Modules" ${CMAKE_MODULE_PATH})
if(WIN32)
find_package(SFML 2 REQUIRED COMPONENTS graphics window system audio network main)
else()
find_package(SFML 2 REQUIRED COMPONENTS graphics window system audio network)
endif()
# SimpleChess
if(APPLE) # Application bundle if on an apple machine
# Optionally build application bundle
set(BUILD_APPBUNDLE FALSE CACHE BOOL "Build into OS x Application Bundle.")
if(BUILD_APPBUNDLE)
# Set bundle properties
set(MACOSX_BUNDLE_BUNDLE_NAME SimpleChess)
set(MACOSX_BUNDLE_INFO_STRING SimpleChess)
set(MACOSX_BUNDLE_SHORT_VERSION_STRING 3.0)
set(MACOSX_BUNDLE_BUNDLE_VERSION 3.0)
set(MACOSX_BUNDLE_GUI_IDENTIFIER com.cplusplus.chesspp)
# Throw all the resource paths into a variable
file(GLOB_RECURSE SIMPLECHESS_RESOURCES
${PROJECT_SOURCE_DIR}/res/*
${PROJECT_SOURCE_DIR}/config/*
)
# Make sure each resource file gets put in the right directory
# in the application bundle
FOREACH(file ${SIMPLECHESS_RESOURCES})
file(RELATIVE_PATH relPath ${PROJECT_SOURCE_DIR} ${file})
string(FIND ${relPath} "/" inSubDirectory REVERSE)
if(${inSubDirectory} GREATER 0)
string(SUBSTRING ${relPath} 0 ${inSubDirectory} relDir)
set(PACKAGE_LOCATION Resources/${relDir})
else()
set(PACKAGE_LOCATION Resources)
endif()
set_source_files_properties(${file}
PROPERTIES
MACOSX_PACKAGE_LOCATION ${PACKAGE_LOCATION}
)
ENDFOREACH()
add_executable(SimpleChess MACOSX_BUNDLE
"src/main.cpp"
)
endif()
endif()
if(NOT APPLE OR NOT BUILD_APPBUNDLE)
# Copy resources to build directory if build directory is different from source directory.
if(NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
file(COPY config/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/config/)
file(COPY res/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/res/)
file(COPY log/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/log/)
endif()
if(WIN32)
add_executable(SimpleChess WIN32
"src/main.cpp"
)
else()
add_executable(SimpleChess
"src/main.cpp"
)
endif()
endif()
set_property(TARGET SimpleChess PROPERTY CXX_STANDARD 14)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if(APPLE)
# Building with Clang (on OS x at least) requires -stdlib=libc++ flag
set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
endif()
endif()
target_include_directories(SimpleChess PUBLIC
"src/"
${SFML_INCLUDE_DIR}
)
target_link_libraries(SimpleChess ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
if(SFML_STATIC_LIBRARIES)
target_link_libraries(SimpleChess z bz2)
endif()
# options
if(WIN32)
set(SIMPLECHESS_REDIRECT_OUTPUT_DEFAULT ON)
else()
set(SIMPLECHESS_REDIRECT_OUTPUT_DEFAULT OFF)
endif()
option(SIMPLECHESS_REDIRECT_OUTPUT "Redirects output to files instead of stdout and stderr" ${SIMPLECHESS_REDIRECT_OUTPUT_DEFAULT})
if(SIMPLECHESS_REDIRECT_OUTPUT)
target_compile_definitions(SimpleChess
PRIVATE SIMPLECHESS_REDIRECT_OUTPUT
)
endif()
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(SIMPLECHESS_TRUNC_LOGS "Truncate the log files at the start of the program" ON
"SIMPLECHESS_REDIRECT_OUTPUT" ON
)
if(SIMPLECHESS_TRUNC_LOGS)
target_compile_definitions(SimpleChess
PRIVATE SIMPLECHESS_TRUNC_LOGS
)
endif()
# Divvy out work to subdirectories
#add_subdirectory("src/")