-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmakelists.txt
50 lines (39 loc) · 2.52 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
cmake_minimum_required(VERSION 3.30.0)
set(CMAKE_CXX_STANDARD_REQUIRED 17)
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)
project(gameJam)
set(version 0.1.0)
find_package(SDL2 2.30 CONFIG REQUIRED)
find_package(SDL2_image 2.8 CONFIG REQUIRED)
find_package(SDL2_ttf 2.22 CONFIG REQUIRED)
find_package(SDL2_mixer 2.8 CONFIG REQUIRED)
file(GLOB_RECURSE SOURCES ${PROJECT_SOURCE_DIR}/src/*.cc)
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
add_executable(${PROJECT_NAME} WIN32 ${SOURCES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
message("Copying ${CMAKE_CURRENT_SOURCE_DIR}/res/ to ${CMAKE_CURRENT_SOURCE_DIR}/prod/res/")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/res/
${CMAKE_CURRENT_SOURCE_DIR}/prod/res/)
message("Copying ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.exe to ${CMAKE_CURRENT_SOURCE_DIR}/prod/${PROJECT_NAME}.exe")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.exe
${CMAKE_CURRENT_SOURCE_DIR}/prod/${PROJECT_NAME}.exe)
else()
add_executable(${PROJECT_NAME} ${SOURCES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wfloat-equal -Werror -Wformat=2 -Wno-missing-declarations -Wmissing-include-dirs -Wcast-qual -Wpointer-arith -Wsequence-point -Wshadow -Wextra -Wcast-align -Wswitch -Wundef -Wunreachable-code -Wno-format-extra-args -Wno-unused-function -Wno-unused-parameter -Wwrite-strings -Wstrict-aliasing -Wpedantic")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/res
${CMAKE_CURRENT_BINARY_DIR}/res)
endif()
target_precompile_headers(${PROJECT_NAME} PRIVATE <array> <cstdint> <iostream> <memory> <string> <utility> <variant> <vector> "${INCLUDE_DIR}SDL2/SDL.h" "${INCLUDE_DIR}SDL2/SDL_image.h" "${INCLUDE_DIR}SDL2/SDL_mixer.h" "${INCLUDE_DIR}SDL2/SDL_ttf.h")
target_include_directories(${PROJECT_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/include")
target_include_directories(${PROJECT_NAME} PRIVATE "${INCLUDE_DIR}")
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2::SDL2main SDL2::SDL2)
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2_image::SDL2_image)
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2_ttf::SDL2_ttf)
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2_mixer::SDL2_mixer)