-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
60 lines (37 loc) · 1.65 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
cmake_minimum_required(VERSION 3.10)
project(Mahjong LANGUAGES CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
# If the build type not indicated explicity, set it to the Release build.
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}/external/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)
file(GLOB_RECURSE SOURCE source/*.cpp)
include_directories("source")
link_directories(${SFML_LIB}/lib)
add_executable(Mahjong ${SOURCE})
add_dependencies(Mahjong SFML)
TARGET_LINK_LIBRARIES(Mahjong
optimized sfml-system debug sfml-system-d sfml-system
optimized sfml-window debug sfml-window-d sfml-window
optimized sfml-graphics debug sfml-graphics-d sfml-graphics
optimized sfml-audio debug sfml-audio-d sfml-audio
optimized sfml-network debug sfml-network-d sfml-network)
set(POST_LIB_DIR "lib")
if (WIN32)
set(POST_LIB_DIR "bin")
endif()
ADD_CUSTOM_COMMAND(TARGET Mahjong 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}/resources" "${CMAKE_CURRENT_BINARY_DIR}/resources")