-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathCMakeLists.txt
84 lines (72 loc) · 3.1 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
cmake_minimum_required(VERSION 3.5)
project(SuperMario 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})
ExternalProject_Add(TinyXml2
#GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git
SOURCE_DIR ${CMAKE_SOURCE_DIR}/ext/tinyxml2
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>)
ExternalProject_Get_Property(TinyXml2 INSTALL_DIR)
set(TINY_XML_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/Blocks.h
${CMAKE_SOURCE_DIR}/source/Blocks.cpp
${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/Items.h
${CMAKE_SOURCE_DIR}/source/Items.cpp
${CMAKE_SOURCE_DIR}/source/Mario.h
${CMAKE_SOURCE_DIR}/source/Mario.cpp
${CMAKE_SOURCE_DIR}/source/Enemies.h
${CMAKE_SOURCE_DIR}/source/Enemies.cpp
${CMAKE_SOURCE_DIR}/source/Pickups.h
${CMAKE_SOURCE_DIR}/source/Pickups.cpp
${CMAKE_SOURCE_DIR}/source/SuperMarioGame.h
${CMAKE_SOURCE_DIR}/source/SuperMarioGame.cpp
${CMAKE_SOURCE_DIR}/source/main.cpp
)
# LINK EXTERNAL LIBRARIES TO EXECUTABLE
LINK_DIRECTORIES(${SFML_LIB}/lib ${TINY_XML_LIB}/lib)
# ADD EXECUTABLE
add_executable(SuperMario ${SOURCE})
if (MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT SuperMario)
set_target_properties( SuperMario PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/Build")
set_target_properties( SuperMario 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(SuperMario SFML TinyXml2)
TARGET_LINK_LIBRARIES(SuperMario
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
optimized tinyxml2 debug tinyxml2d)
# POST BUILD SCRIPTS
set(POST_LIB_DIR "lib")
if (WIN32)
set(POST_LIB_DIR "bin")
endif()
ADD_CUSTOM_COMMAND(TARGET SuperMario POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${SFML_LIB}/${POST_LIB_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${TINY_XML_LIB}/${POST_LIB_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/res" "${CMAKE_CURRENT_BINARY_DIR}/res")