-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
55 lines (46 loc) · 1.41 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
cmake_minimum_required(VERSION 3.22)
project(PongSFML)
# Set C++ options
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Add SFML as a dependency
add_subdirectory(deps/SFML)
# Get all the C++ files
# in the sources recursively
file(GLOB_RECURSE PONG_SOURCES
source/*.cpp
)
# Create the project
add_executable(pong ${PONG_SOURCES})
target_include_directories(pong PRIVATE
source/
)
# Link SFML
target_link_libraries(pong PRIVATE
sfml-graphics
sfml-audio
)
# Windows fiasco
if (WIN32)
add_custom_command(TARGET pong POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/deps/SFML/extlibs/bin/x64/openal32.dll $<TARGET_FILE_DIR:pong>
)
add_custom_command(TARGET pong POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/assets $<TARGET_FILE_DIR:pong>/assets
)
set_target_properties(pong PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:pong>)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT pong)
else()
file(COPY ${CMAKE_SOURCE_DIR}/assets DESTINATION ${CMAKE_BINARY_DIR})
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message("-- Using libasan")
# Enable address sanitizer and Extra warnings
target_compile_options(pong PRIVATE
-Wall -Wextra
-fsanitize=address
)
target_link_options(pong PRIVATE -fsanitize=address)
endif()