-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
82 lines (62 loc) · 2.57 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
# /CMakeLists.txt
cmake_minimum_required(VERSION 3.1)
project(AutomataForge)
set(CMAKE_CXX_STANDARD 17)
# Define source and include directories
set(SOURCE_DIR ${CMAKE_SOURCE_DIR}/src)
set(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(LIB_DIR ${CMAKE_SOURCE_DIR}/lib)
# Include the lib/CMakeLists.txt to handle dependencies
add_subdirectory(${LIB_DIR})
# Define the source files
file(GLOB_RECURSE SOURCES "${SOURCE_DIR}/*.cpp")
# Define the executable
add_executable(${PROJECT_NAME} ${SOURCES})
# Define includes
# SDL
target_include_directories(${PROJECT_NAME} PRIVATE ${INCLUDE_DIR} ${SDL2_INCLUDE_DIR})
# GLEW
target_include_directories(${PROJECT_NAME} PRIVATE ${GLEW_INCLUDE_DIR})
# GLM
target_include_directories(${PROJECT_NAME} PRIVATE ${GLM_INCLUDE_DIR})
target_link_directories(${PROJECT_NAME} PRIVATE "${SDL2_BUILD_DIR}/$<CONFIG>")
# message(STATUS "SDL2 Include Directory: ${SDL2_INCLUDE_DIR}")
# Platform-specific logic
if(WIN32)
message(STATUS "Configuring for Windows")
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
target_link_libraries(${PROJECT_NAME} optimized SDL2 debug SDL2d optimized SDL2main debug SDL2maind)
target_link_libraries(${PROJECT_NAME} ${GLEW_LIBRARY})
target_link_libraries(${PROJECT_NAME} opengl32)
else()
target_link_libraries(${PROJECT_NAME} SDL2)
endif()
# Define the output directory
set(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/out)
# Delete and recreate the output directory
file(REMOVE_RECURSE ${OUTPUT_DIR})
file(MAKE_DIRECTORY ${OUTPUT_DIR})
# Copy project executable
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_BINARY_DIR}/$<CONFIG>
${OUTPUT_DIR})
# Copy SDL2 libraries
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${SDL2_BUILD_DIR}/$<CONFIG>
${OUTPUT_DIR})
# Copy GLEW libraries
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${GLEW_LIB_DIR}
${OUTPUT_DIR})
# Copy GLEW binaries
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${GLEW_BIN_DIR}
${OUTPUT_DIR})
# Copy resources from the res/ folder
file(COPY ${CMAKE_SOURCE_DIR}/res/ DESTINATION ${OUTPUT_DIR}/res)
# Copy shaders from the shaders/ folder
file(COPY ${CMAKE_SOURCE_DIR}/shaders/ DESTINATION ${OUTPUT_DIR}/shaders)