-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
109 lines (81 loc) · 2.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
cmake_minimum_required(VERSION 3.14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Uncomment these to put the dlls in the same directory as the executable (useful if you don't have SDL2 installed and you're building from source)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Uncomment if you need to do some debugging :)
# set(CMAKE_FIND_DEBUG_MODE TRUE)
set(PROJECT_NAME PhysicsEngine)
# Add your sources here (adding headers is optional, but helps some CMake generators)
set(ENGINE_SOURCE
"Collisions.cpp"
"Constraints.cpp"
"Shape.cpp"
"RigidBody.cpp"
"PhysicsEngineMath.cpp"
"PhysicsEngine.cpp"
)
set(FRAMEWORK_SOURCE
"BaseGame.cpp"
"SDL2Extras.cpp"
"Colour.cpp"
"Input.cpp"
)
set(DEMO_SOURCE
"Demo.cpp"
"Game.cpp"
"Constants.cpp"
)
# Uncomment if no console should be created
# set(WINDOWS_NO_CONSOLE)
project(${PROJECT_NAME})
list(TRANSFORM ENGINE_SOURCE PREPEND src/PhysicsEngine/)
list(TRANSFORM FRAMEWORK_SOURCE PREPEND src/Framework/)
list(TRANSFORM DEMO_SOURCE PREPEND src/Demo/)
set(PROJECT_SOURCES ${ENGINE_SOURCE};${FRAMEWORK_SOURCE};${DEMO_SOURCE})
set(PROJECT_DISTRIBS LICENSE README.md)
set(CONSOLE_FLAG)
if (WINDOWS_NO_CONSOLE)
set(CONSOLE_FLAG WIN32)
endif()
add_executable(${PROJECT_NAME} ${CONSOLE_FLAG} MACOSX_BUNDLE ${PROJECT_SOURCES})
include(get_sdl2.cmake)
#target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/include/Demo)
include_directories(${PROJECT_SOURCE_DIR}/include/External)
include_directories(${PROJECT_SOURCE_DIR}/include/Framework)
include_directories(${PROJECT_SOURCE_DIR}/include/PhysicsEngine)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
# Link
target_link_libraries(${PROJECT_NAME} SDL2::SDL2main SDL2::SDL2 SDL2::image)
# Setup release packages
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
BUNDLE DESTINATION bin
)
install(FILES ${PROJECT_DISTRIBS}
DESTINATION .
)
if (NOT EMSCRIPTEN)
# Install dependencies
set(DEP_SEARCH_DIRS)
# We built these, so we're installing them
if(TARGET SDL2)
list(APPEND DEP_SEARCH_DIRS $<TARGET_FILE_DIR:SDL2>)
endif()
if(TARGET SDL2_image)
list(APPEND DEP_SEARCH_DIRS $<TARGET_FILE_DIR:SDL2_image> $<TARGET_FILE_DIR:png> $<TARGET_FILE_DIR:zlib>)
endif()
set(EXE_SUFFIX)
if(APPLE)
set(EXE_SUFFIX ".app")
endif()
install(CODE "
include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:${PROJECT_NAME}>${EXE_SUFFIX}\" \"\" \"${DEP_SEARCH_DIRS}\")
")
endif()
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_GENERATOR "ZIP" "TGZ")
include(CPack)