-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCMakeLists.txt
65 lines (55 loc) · 2.31 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
cmake_minimum_required(VERSION 3.5)
project(PacMan VERSION 0.99 LANGUAGES C CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
# BUILD EXTERNAL LIBRARIES
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
ExternalProject_Add(SFML
#GIT_REPOSITORY https://github.com/SFML/SFML.git GIT_TAG 2.5.1
SOURCE_DIR ${CMAKE_SOURCE_DIR}/ext/SFML
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
ExternalProject_Get_Property(SFML INSTALL_DIR)
set(SFML_LIB ${INSTALL_DIR})
# ADD SOURCE FILES AND HEADERS OF EXECUTABLE
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${SFML_LIB}/include ${TINY_XML_LIB}/include)
set(SOURCE
${CMAKE_SOURCE_DIR}/source/GameEngine.h
${CMAKE_SOURCE_DIR}/source/GameEngine.cpp
${CMAKE_SOURCE_DIR}/source/Geometry.h
${CMAKE_SOURCE_DIR}/source/Geometry.cpp
${CMAKE_SOURCE_DIR}/source/TileMap.h
${CMAKE_SOURCE_DIR}/source/GhostStates.h
${CMAKE_SOURCE_DIR}/source/GhostStates.cpp
${CMAKE_SOURCE_DIR}/source/PacManGame.h
${CMAKE_SOURCE_DIR}/source/PacManGame.cpp
${CMAKE_SOURCE_DIR}/source/Main.cpp
)
# LINK EXTERNAL LIBRARIES TO EXECUTABLE
LINK_DIRECTORIES(${SFML_LIB}/lib)
# ADD EXECUTABLE
add_executable(PacMan ${SOURCE})
if (MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT PacMan)
set_target_properties( PacMan PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/Build")
set_target_properties( PacMan PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/Build")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
endif(MSVC)
# ADD DEPENDISIES FOR EXECUTABLE
add_dependencies(PacMan SFML)
TARGET_LINK_LIBRARIES(PacMan
optimized sfml-system debug sfml-system-d
optimized sfml-window debug sfml-window-d
optimized sfml-graphics debug sfml-graphics-d
optimized sfml-audio debug sfml-audio-d)
# POST BUILD SCRIPTS
set(POST_LIB_DIR "lib")
if (WIN32)
set(POST_LIB_DIR "bin")
endif()
ADD_CUSTOM_COMMAND(TARGET PacMan POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${SFML_LIB}/${POST_LIB_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/res" "${CMAKE_CURRENT_BINARY_DIR}/res")