This repository has been archived by the owner on Jun 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
61 lines (49 loc) · 1.74 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
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project("pacman" VERSION 1.0 HOMEPAGE_URL "https://github.com/mirceanton/pacman")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
if(WIN32)
set(SFML_STATIC_LIBRARIES TRUE)
endif()
# TODO change me ON Windows
SET(SFML_HOME "C:/SFML/SFML-2.6.1/")
file(GLOB_RECURSE GAME_SRC "src/*.cpp" "src/*.hpp")
set(SFML_DIR ${SFML_HOME}/lib/cmake/SFML)
find_package(SFML 2.5 REQUIRED COMPONENTS "graphics" "window" "audio" "system")
if(WIN32)
add_executable(pacman WIN32 ${GAME_SRC} ${CMAKE_SOURCE_DIR}/res/win-icon.rc)
target_link_libraries(pacman PRIVATE sfml-main)
elseif(APPLE)
include(${CMAKE_SOURCE_DIR}/cmake/MacBundle.cmake)
find_library(FOUNDATION_FRAMEWORK Foundation)
target_link_libraries(pacman PRIVATE ${FOUNDATION_FRAMEWORK})
else()
add_executable(pacman ${GAME_SRC})
endif()
# link all required libraries
target_link_libraries(pacman PRIVATE sfml-graphics sfml-window sfml-audio sfml-system)
# include SFML headers
include_directories(${SFML_HOME}/include)
# show warnings (depending on C++ compiler)
if(MSVC)
target_compile_options(pacman PRIVATE /W4)
else()
target_compile_options(pacman PRIVATE -Wall)
endif()
# COPY resources folder to destination (WINDOWS, LINUX)
if(NOT APPLE)
add_custom_command(
TARGET pacman
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/res
$<TARGET_FILE_DIR:pacman>/res)
endif()
# COPY the audio DLL to destination (Windows only)
if(WIN32)
add_custom_command(
TARGET pacman
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SFML_HOME}/bin/openal32.dll
$<TARGET_FILE_DIR:pacman>/openal32.dll)
endif()