Skip to content

Commit 789629a

Browse files
Merge pull request gameplay3d#1809 from FunMiles/next_Mac_cmake
Next mac cmake
2 parents 8b81587 + fe46cdd commit 789629a

File tree

8 files changed

+338
-88
lines changed

8 files changed

+338
-88
lines changed

gameplay/CMakeLists.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
2+
set(GAMEPLAY_PLATFORM_SRC
3+
src/PlatformMacOSX.mm
4+
src/gameplay-main-macosx.mm
5+
)
6+
else(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
7+
set(GAMEPLAY_PLATFORM_SRC )
8+
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
19

210
set(GAMEPLAY_SRC
311
src/AbsoluteLayout.cpp
@@ -165,6 +173,7 @@ set(GAMEPLAY_SRC
165173
src/PlatformAndroid.cpp
166174
src/PlatformLinux.cpp
167175
src/PlatformWindows.cpp
176+
${GAMEPLAY_PLATFORM_SRC}
168177
src/Properties.cpp
169178
src/Properties.h
170179
src/Quaternion.cpp
@@ -555,8 +564,13 @@ add_definitions(${GTK2_CFLAGS_OTHER})
555564
add_definitions(-D__linux__)
556565
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
557566

558-
add_definitions(-std=c++11)
559-
add_definitions(-lstdc++)
567+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
568+
# using Clang
569+
add_definitions(-std=c++11 -stdlib=libc++)
570+
else()
571+
add_definitions(-std=c++11)
572+
add_definitions(-lstdc++)
573+
endif()
560574

561575
add_library(gameplay STATIC
562576
${GAMEPLAY_SRC}

samples/BuildHelpers.CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,36 @@ macro(COPY_RES_EXTRA GAME_NAME REL_DIR)
4949
COPY_RES_FILES( ${GAME_NAME} ${GAME_NAME}_EXTRA_RES ${REL_DIR} "${SRC_FILES}" )
5050
add_dependencies( ${GAME_NAME}_ASSETS ${GAME_NAME}_EXTRA_RES )
5151
endmacro()
52+
53+
# Build a list of file matching a list of regular expression within a given path
54+
# RESULT name of the global variable into which the result is built
55+
# REL_PATH the path under which the files are to be found
56+
# ARGN list of patterns
57+
macro(MAKE_ABSOLUTE RESULT REL_PATH)
58+
set(${RESULT})
59+
foreach(SRC_FILE ${ARGN} )
60+
file(GLOB XX ${REL_PATH}/${SRC_FILE})
61+
list(APPEND ${RESULT} ${XX})
62+
endforeach()
63+
endmacro()
64+
65+
# Build a list of resource files matching a list of regular expression within a given path
66+
# and mark their correct Mac OS X destination, keeping the relative position to a base path
67+
# RESULT name of the global variable into which the result is built
68+
# BASE_SRC_PATH the base path under which the structure is replicated in the bundle
69+
# REL_PATH a pattern to be matched and searched recursively.
70+
macro(COPY_RES_MAC RESULT BASE_SRC_PATH)
71+
set(${RESULT})
72+
foreach(PATTERN ${ARGN} )
73+
file(GLOB_RECURSE XX RELATIVE ${BASE_SRC_PATH} ${BASE_SRC_PATH}/${PATTERN})
74+
foreach(FNAME ${XX})
75+
list(APPEND ${RESULT} ${BASE_SRC_PATH}/${FNAME})
76+
get_filename_component(DIR ${FNAME} DIRECTORY )
77+
set_source_files_properties(
78+
${BASE_SRC_PATH}/${FNAME}
79+
PROPERTIES
80+
MACOSX_PACKAGE_LOCATION Resources/${DIR}
81+
)
82+
endforeach()
83+
endforeach()
84+
endmacro()

samples/CMakeLists.txt

Lines changed: 66 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,76 @@
11
include(BuildHelpers.CMakeLists.txt)
22

3-
include_directories(
4-
${CMAKE_SOURCE_DIR}/gameplay/src
5-
${CMAKE_SOURCE_DIR}/external-deps/include
3+
include_directories(
4+
${CMAKE_SOURCE_DIR}/gameplay/src
5+
${CMAKE_SOURCE_DIR}/external-deps/include
66
)
77

8-
add_definitions(-D__linux__)
8+
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
9+
find_package(OpenGL REQUIRED)
10+
FIND_LIBRARY(AGL_LIBRARY AGL)
11+
FIND_LIBRARY(APP_SERVICES_LIBRARY ApplicationServices )
12+
FIND_LIBRARY(ATBOX_LIBRARY AudioToolbox)
13+
FIND_LIBRARY(CARBON_LIBRARY Carbon)
14+
FIND_LIBRARY(CAUDIO_LIBRARY CoreAudio)
15+
FIND_LIBRARY(COREVIDEO_LIBRARY CoreVideo)
16+
FIND_LIBRARY(CFOUNDATION_LIBRARY CoreFoundation)
17+
FIND_LIBRARY(CSERVICES_LIBRARY CoreServices)
18+
FIND_LIBRARY(OPENGL_LIBRARY OpenGL)
19+
FIND_LIBRARY(QUICKTIME_LIBRARY QuickTime )
20+
FIND_LIBRARY(IOKIT_LIBRARY IOKit )
21+
FIND_LIBRARY(AVF_LIBRARY AVFoundation)
22+
FIND_LIBRARY(OAL_LIBRARY OpenAL)
23+
FIND_LIBRARY(GKIT_LIBRARY GameKit)
24+
SET(FRAMEWORK_LIBRS
25+
${AGL_LIBRARY}
26+
${APP_SERVICES_LIBRARY}
27+
${ATBOX_LIBRARY}
28+
${CARBON_LIBRARY}
29+
${CAUDIO_LIBRARY}
30+
${COREVIDEO_LIBRARY}
31+
${CFOUNDATION_LIBRARY}
32+
${CSERVICES_LIBRARY}
33+
${OAL_LIBRARY}
34+
${OPENGL_LIBRARIES}
35+
${GKIT_LIBRARY}
36+
${IOKIT_LIBRARY}
37+
"-framework Foundation"
38+
"-framework Cocoa")
39+
link_directories(${CMAKE_SOURCE_DIR}/external-deps/lib/macosx/x86_64)
40+
set(GAMEPLAY_LIBRARIES
41+
stdc++
42+
gameplay
43+
gameplay-deps
44+
m
45+
dl
46+
pthread
47+
${FRAMEWORK_LIBRS}
48+
)
49+
ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
50+
add_definitions(-D__linux__)
951

10-
IF(ARCH_DIR STREQUAL "x64")
11-
link_directories(${CMAKE_SOURCE_DIR}/external-deps/lib/linux/x86_64)
12-
ELSE()
13-
link_directories(${CMAKE_SOURCE_DIR}/external-deps/lib/linux/x86)
14-
ENDIF(ARCH_DIR STREQUAL "x64")
52+
IF(ARCH_DIR STREQUAL "x64")
53+
link_directories(${CMAKE_SOURCE_DIR}/external-deps/lib/linux/x86_64)
54+
ELSE()
55+
link_directories(${CMAKE_SOURCE_DIR}/external-deps/lib/linux/x86)
56+
ENDIF(ARCH_DIR STREQUAL "x64")
1557

1658

17-
set(GAMEPLAY_LIBRARIES
18-
stdc++
19-
gameplay
20-
gameplay-deps
21-
m
22-
GL
23-
rt
24-
dl
25-
X11
26-
pthread
27-
gtk-x11-2.0
28-
glib-2.0
29-
gobject-2.0
30-
)
59+
set(GAMEPLAY_LIBRARIES
60+
stdc++
61+
gameplay
62+
gameplay-deps
63+
m
64+
GL
65+
rt
66+
dl
67+
X11
68+
pthread
69+
gtk-x11-2.0
70+
glib-2.0
71+
gobject-2.0
72+
)
73+
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
3174

3275
add_definitions(-std=c++11)
3376

samples/browser/CMakeLists.txt

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,53 @@ set(GAME_SRC
5555
src/WaterSample.h
5656
)
5757

58-
add_executable(${GAME_NAME}
59-
${GAME_SRC}
60-
)
58+
59+
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
60+
MESSAGE("Game name is ${GAME_NAME}")
61+
COPY_RES_MAC(GAME_RES ${CMAKE_SOURCE_DIR}/samples/browser res/*)
62+
COPY_RES_MAC(GAMEPLAY_RES ${CMAKE_SOURCE_DIR}/gameplay
63+
res/shaders/* res/ui/* res/logo_powered_white.png)
64+
set(Apple_Resources
65+
${GAME_RES}
66+
${GAMEPLAY_RES}
67+
game.config)
68+
SET(EXEC_TYPE MACOSX_BUNDLE)
69+
70+
SET_SOURCE_FILES_PROPERTIES(
71+
game.config
72+
PROPERTIES
73+
MACOSX_PACKAGE_LOCATION Resources
74+
)
75+
set( MACOSX_BUNDLE_INFO_STRING "\"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}\",\nCopyright 2016 gameplay3d contributors" )
76+
set( MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}" )
77+
set( MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
78+
set( MACOSX_BUNDLE_BUNDLE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
79+
set( MACOSX_BUNDLE_COPYRIGHT "(C) gameplay3d contributors" )
80+
set( PLIST_TEMPLATE ${GAME_NAME}-macosx.plist )
81+
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
82+
83+
add_executable(${GAME_NAME} ${EXEC_TYPE}
84+
${GAME_SRC}
85+
${Apple_Resources}
86+
)
6187

6288
target_link_libraries(${GAME_NAME} ${GAMEPLAY_LIBRARIES})
6389

90+
6491
set_target_properties(${GAME_NAME} PROPERTIES
6592
OUTPUT_NAME "${GAME_NAME}"
6693
CLEAN_DIRECT_OUTPUT 1
6794
)
6895

69-
source_group(res FILES ${GAME_RES} ${GAMEPLAY_RES} ${GAMEPLAY_RES_SHADERS} ${GAMEPLAY_RES_UI})
70-
source_group(src FILES ${GAME_SRC})
96+
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
7197

72-
COPY_RES( ${GAME_NAME} )
73-
COPY_RES_EXTRA( ${GAME_NAME} ${CMAKE_SOURCE_DIR}/gameplay
74-
res/logo_powered_white.png
75-
res/shaders/*
76-
res/ui/*
77-
)
98+
source_group(res FILES ${GAME_RES} ${GAMEPLAY_RES} ${GAMEPLAY_RES_SHADERS} ${GAMEPLAY_RES_UI})
99+
source_group(src FILES ${GAME_SRC})
78100

101+
COPY_RES( ${GAME_NAME} )
102+
COPY_RES_EXTRA( ${GAME_NAME} ${CMAKE_SOURCE_DIR}/gameplay
103+
res/logo_powered_white.png
104+
res/shaders/*
105+
res/ui/*
106+
)
107+
endif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

samples/character/CMakeLists.txt

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,51 @@ set(GAME_SRC
55
src/CharacterGame.h
66
)
77

8-
add_executable(${GAME_NAME}
9-
${GAME_SRC}
10-
)
8+
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
9+
COPY_RES_MAC(GAME_RES ${CMAKE_SOURCE_DIR}/samples/character res/*)
10+
COPY_RES_MAC(GAMEPLAY_RES ${CMAKE_SOURCE_DIR}/gameplay
11+
res/shaders/* res/ui/* res/logo_powered_white.png)
12+
set(Apple_Resources
13+
${GAME_RES}
14+
${GAMEPLAY_RES}
15+
game.config)
16+
SET(EXEC_TYPE MACOSX_BUNDLE)
17+
18+
SET_SOURCE_FILES_PROPERTIES(
19+
game.config
20+
PROPERTIES
21+
MACOSX_PACKAGE_LOCATION Resources
22+
)
23+
set( MACOSX_BUNDLE_INFO_STRING "\"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}\",\nCopyright 2016 gameplay3d contributors" )
24+
set( MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}" )
25+
set( MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
26+
set( MACOSX_BUNDLE_BUNDLE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
27+
set( MACOSX_BUNDLE_COPYRIGHT "(C) gameplay3d contributors" )
28+
set( PLIST_TEMPLATE sample-racer-macosx.plist )
29+
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
30+
31+
add_executable(${GAME_NAME} ${EXEC_TYPE}
32+
${GAME_SRC} ${Apple_Resources}
33+
)
1134

1235
target_link_libraries(${GAME_NAME} ${GAMEPLAY_LIBRARIES})
1336

14-
set_target_properties(${GAME_NAME} PROPERTIES
15-
OUTPUT_NAME "${GAME_NAME}"
16-
CLEAN_DIRECT_OUTPUT 1
17-
)
37+
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
1838

19-
source_group(res FILES ${GAME_RES} ${GAMEPLAY_RES} ${GAMEPLAY_RES_SHADERS} ${GAMEPLAY_RES_UI})
20-
source_group(src FILES ${GAME_SRC})
39+
set_target_properties(${GAME_NAME} PROPERTIES
40+
OUTPUT_NAME "${GAME_NAME}"
41+
CLEAN_DIRECT_OUTPUT 1
42+
)
2143

22-
COPY_RES( ${GAME_NAME} )
23-
COPY_RES_EXTRA( ${GAME_NAME} ${CMAKE_SOURCE_DIR}/gameplay
24-
res/logo_powered_white.png
25-
res/shaders/*
26-
res/ui/*
27-
)
44+
source_group(res FILES ${GAME_RES} ${GAMEPLAY_RES} ${GAMEPLAY_RES_SHADERS} ${GAMEPLAY_RES_UI})
45+
source_group(src FILES ${GAME_SRC})
2846

47+
COPY_RES( ${GAME_NAME} )
48+
COPY_RES_EXTRA( ${GAME_NAME} ${CMAKE_SOURCE_DIR}/gameplay
49+
res/logo_powered_white.png
50+
res/shaders/*
51+
res/ui/*
52+
)
53+
endif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
2954
# Just use the PNG config file (most compatible)
3055
configure_file( game.dxt.config game.config COPYONLY )

samples/racer/CMakeLists.txt

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,59 @@
11
set(GAME_NAME sample-racer)
22

33
set(GAME_SRC
4-
src/RacerGame.cpp
5-
src/RacerGame.h
6-
)
4+
src/RacerGame.cpp
5+
src/RacerGame.h
6+
)
77

8-
add_executable(${GAME_NAME}
9-
${GAME_SRC}
10-
)
8+
if(NOT ${APPLE})
9+
set_target_properties(${GAME_NAME} PROPERTIES
10+
OUTPUT_NAME "${GAME_NAME}"
11+
CLEAN_DIRECT_OUTPUT 1
12+
)
13+
endif(NOT ${APPLE})
1114

15+
source_group(res FILES ${GAME_RES} ${GAMEPLAY_RES} ${GAMEPLAY_RES_SHADERS} ${GAMEPLAY_RES_UI})
16+
source_group(src FILES ${GAME_SRC})
17+
18+
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
19+
COPY_RES_MAC(GAME_RES ${CMAKE_SOURCE_DIR}/samples/racer res/*)
20+
COPY_RES_MAC(GAMEPLAY_RES ${CMAKE_SOURCE_DIR}/gameplay
21+
res/shaders/* res/ui/* res/logo_powered_white.png)
22+
set(Apple_Resources
23+
${GAME_RES}
24+
${GAMEPLAY_RES}
25+
game.config)
26+
SET(EXEC_TYPE MACOSX_BUNDLE)
27+
28+
SET_SOURCE_FILES_PROPERTIES(
29+
game.config
30+
PROPERTIES
31+
MACOSX_PACKAGE_LOCATION Resources
32+
)
33+
set( MACOSX_BUNDLE_INFO_STRING "\"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}\",\nCopyright 2016 gameplay3d contributors" )
34+
set( MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}" )
35+
set( MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
36+
set( MACOSX_BUNDLE_BUNDLE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
37+
set( MACOSX_BUNDLE_COPYRIGHT "(C) gameplay3d contributors" )
38+
set( PLIST_TEMPLATE sample-racer-macosx.plist )
39+
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
40+
41+
add_executable(${GAME_NAME} ${EXEC_TYPE}
42+
${GAME_SRC}
43+
${Apple_Resources}
44+
)
1245
target_link_libraries(${GAME_NAME} ${GAMEPLAY_LIBRARIES})
1346

14-
set_target_properties(${GAME_NAME} PROPERTIES
15-
OUTPUT_NAME "${GAME_NAME}"
16-
CLEAN_DIRECT_OUTPUT 1
17-
)
47+
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
1848

19-
source_group(res FILES ${GAME_RES} ${GAMEPLAY_RES} ${GAMEPLAY_RES_SHADERS} ${GAMEPLAY_RES_UI})
20-
source_group(src FILES ${GAME_SRC})
2149

22-
COPY_RES( ${GAME_NAME} )
23-
COPY_RES_EXTRA( ${GAME_NAME} ${CMAKE_SOURCE_DIR}/gameplay
24-
res/logo_powered_white.png
25-
res/shaders/*
26-
res/ui/*
27-
)
50+
COPY_RES( ${GAME_NAME} )
51+
COPY_RES_EXTRA( ${GAME_NAME} ${CMAKE_SOURCE_DIR}/gameplay
52+
res/logo_powered_white.png
53+
res/shaders/*
54+
res/ui/*
55+
)
2856

57+
endif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
2958
# Just use the PNG config file (most compatible)
30-
configure_file( game.png.config game.config COPYONLY )
59+
configure_file( game.png.config game.config COPYONLY )

0 commit comments

Comments
 (0)