-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
77 lines (60 loc) · 2.26 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
cmake_minimum_required (VERSION 3.13...3.21)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")
include(FetchContent)
function(add_git_dependency libName gitURL)
FetchContent_Declare(${libName}
GIT_REPOSITORY ${gitURL}
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(${libName})
target_compile_options(${libName} PRIVATE "-w")
endfunction()
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
endif()
project(
raylib-template # Project name, change this as needed.
LANGUAGES C CXX
)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") # Keep all runtime files in one directory.
file(
GLOB_RECURSE SOURCE_FILES
CONFIGURE_DEPENDS # Automatically reconfigure if source files are added/removed.
${PROJECT_SOURCE_DIR}/src/*.cpp
${PROJECT_SOURCE_DIR}/src/*.hpp
)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
# Ensure the C++17 standard is available.
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
# Enforce UTF-8 encoding on MSVC.
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /utf-8)
endif()
# Enable warnings recommended for new projects.
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wno-c++11-narrowing -Wno-unused-parameter)
endif()
find_package(raylib CONFIG REQUIRED)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
raylib
)
target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=address,undefined)
# Define the source directory for your data
set(DATA_SOURCE_DIR "${CMAKE_SOURCE_DIR}/data")
# Define the destination directory where the data should be copied
set(DATA_DEST_DIR "${CMAKE_BINARY_DIR}/data")
# if you want to run the command without relying on any specific target
add_custom_target(copy_data ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${DATA_SOURCE_DIR}" $<TARGET_FILE_DIR:${PROJECT_NAME}>/data/
COMMENT "Copying data directory to output..."
)
# Ensure the custom target runs before building the executable
add_dependencies(${PROJECT_NAME} copy_data)