-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
127 lines (107 loc) · 4.11 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
cmake_minimum_required(VERSION 3.26)
project(Isoberry)
set(CMAKE_CXX_STANDARD 17)
set(OpenGL_GL_PREFERENCE GLVND)
add_subdirectory("submodules/stbImage")
file (GLOB MY_SRC
"src/utility/*"
"src/graphics/*"
"src/objects/*"
"src/objects/collision/*"
"src/objects/entity/*"
"src/*"
)
if (WIN32 OR LINUX)
add_executable(Isoberry ${MY_SRC})
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# Link assets folder in Debug mode
add_custom_command(TARGET Isoberry PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_SOURCE_DIR}/resources/assets ${CMAKE_CURRENT_BINARY_DIR}/assets
COMMENT "Linking assets folder in Debug mode"
)
else()
# Copy assets folder in Release mode (or other non-Debug configurations)
add_custom_command(TARGET Isoberry PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/resources/assets ${CMAKE_CURRENT_BINARY_DIR}/assets
COMMENT "Copying assets folder in Release mode"
)
endif()
endif (WIN32 OR LINUX)
if (WIN32)
# Windows moment
target_compile_definitions(Isoberry PRIVATE NOMINMAX)
endif (WIN32)
if (APPLE)
add_compile_options(-stdlib=libc++)
set(CUR_TARGET Isoberry)
set(MACOSX_BUNDLE_ICON_FILE isoberry.icns)
set(myApp_ICON resources/app/icon/isoberry.icns
src/objects/entity/Entity.cpp
src/objects/entity/Entity.h
src/objects/entity/Player.cpp
src/objects/entity/Player.h
)
set_source_files_properties(${myApp_ICON} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
add_executable(${CUR_TARGET} MACOSX_BUNDLE ${MY_SRC} ${myApp_ICON})
set_target_properties(${CUR_TARGET} PROPERTIES
BUNDLE True
MACOSX_BUNDLE_GUI_IDENTIFIER my.domain.style.identifier.${CUR_TARGET}
MACOSX_BUNDLE_BUNDLE_NAME ${CUR_TARGET}
MACOSX_BUNDLE_BUNDLE_VERSION ${ISOBERRY_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${ISOBERRY_VERSION}
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# Link assets folder in Debug mode
add_custom_command(TARGET ${CUR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_SOURCE_DIR}/resources/assets
${CMAKE_CURRENT_BINARY_DIR}/${CUR_TARGET}.app/Contents/assets
COMMENT "Linking assets folder in Debug mode"
)
else()
# Copy assets folder in Release mode
add_custom_command(TARGET ${CUR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/resources/assets
${CMAKE_CURRENT_BINARY_DIR}/${CUR_TARGET}.app/Contents/assets
COMMENT "Copying assets folder in Release mode"
)
endif()
set(OPENSSL_INCLUDE_DIR /usr/local/opt/openssl)
set(OPENSSL_CRYPTO_LIBRARY /usr/local/opt/openssl/lib)
endif(APPLE)
target_include_directories(Isoberry PRIVATE
"submodules/stbImage")
if(${CMAKE_SYSTEM} MATCHES "Linux")
set(LINUX 1)
endif(${CMAKE_SYSTEM} MATCHES "Linux")
if (UNIX)
# X11
if(LINUX)
find_package(X11 REQUIRED)
include_directories(${X11_INCLUDE_DIR})
link_directories(${X11_LIBRARIES})
target_link_libraries(Isoberry PRIVATE ${X11_LIBRARIES})
endif(LINUX)
# GLUT
if(APPLE)
find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIR})
link_directories(${GLUT_LIBRARIES})
target_link_libraries(Isoberry PRIVATE ${GLUT_LIBRARIES})
endif(APPLE)
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
link_directories(${OPENGL_LIBRARIES})
target_link_libraries(Isoberry PRIVATE ${OPENGL_LIBRARIES})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(Isoberry PRIVATE Threads::Threads)
endif (UNIX)
find_package(glfw3 CONFIG REQUIRED)
target_link_libraries(Isoberry PRIVATE glfw)
find_package(raylib CONFIG REQUIRED)
target_link_libraries(Isoberry PRIVATE raylib)