Skip to content

Commit 512ed71

Browse files
matteblairtallytalwar
authored andcommitted
Use CMake source_group function to organize tangram-core files in Xcode (tangrams#1989)
* Use CMake source_group function to organize tangram-core files in Xcode Requires listing all headers in tangram-core, but now Xcode can index header contents and match them with their cpp counterparts! * Check CMake version >= 3.8 for source_group
1 parent 9dbe41c commit 512ed71

File tree

2 files changed

+106
-31
lines changed

2 files changed

+106
-31
lines changed

cmake/utils.cmake

-26
Original file line numberDiff line numberDiff line change
@@ -81,32 +81,6 @@ function(check_and_link_libraries TARGET)
8181
endforeach()
8282
endfunction(check_and_link_libraries)
8383

84-
macro(group_recursive_sources CURDIR CURGROUP)
85-
file(GLOB children ${CURDIR}/*)
86-
87-
foreach(child ${children})
88-
if(IS_DIRECTORY ${child})
89-
file(GLOB FOUND_HEADERS ${child}/*.h)
90-
file(GLOB FOUND_SOURCES ${child}/*.cpp)
91-
string(REGEX MATCH "([^/]+)$" group ${child})
92-
93-
if("${CURGROUP}" STREQUAL "")
94-
source_group(${group} FILES ${FOUND_HEADERS} ${FOUND_SOURCES})
95-
else()
96-
source_group(${CURGROUP}/${group} FILES ${FOUND_HEADERS} ${FOUND_SOURCES})
97-
set(group ${CURGROUP}/${group})
98-
endif()
99-
100-
group_recursive_sources(${child} ${group})
101-
endif()
102-
endforeach()
103-
104-
# add files from top level group
105-
file(GLOB FOUND_HEADERS ${CURGROUP}/*.h)
106-
file(GLOB FOUND_SOURCES ${CURGROUP}/*.cpp)
107-
source_group(${CURGROUP} FILES ${FOUND_HEADERS} ${FOUND_SOURCES})
108-
endmacro()
109-
11084
macro(add_bundle_resources RESOURCE_LIST RESOURCE_DIR RESOURCE_BASE)
11185

11286
file(GLOB_RECURSE FULL_RESOURCE_PATHS "${RESOURCE_DIR}/[^.]**")

core/CMakeLists.txt

+106-5
Original file line numberDiff line numberDiff line change
@@ -4,96 +4,194 @@ project(tangram-core)
44
add_subdirectory(deps)
55

66
add_library(tangram-core
7+
include/tangram/log.h
8+
include/tangram/map.h
9+
include/tangram/platform.h
10+
include/tangram/tangram.h
11+
include/tangram/data/clientGeoJsonSource.h
12+
include/tangram/data/properties.h
13+
include/tangram/data/propertyItem.h
14+
include/tangram/data/tileSource.h
15+
include/tangram/tile/tileID.h
16+
include/tangram/tile/tileTask.h
17+
include/tangram/util/types.h
18+
include/tangram/util/url.h
19+
include/tangram/util/variant.h
720
src/map.cpp
821
src/platform.cpp
922
src/data/clientGeoJsonSource.cpp
23+
src/data/memoryCacheDataSource.h
1024
src/data/memoryCacheDataSource.cpp
25+
src/data/networkDataSource.h
1126
src/data/networkDataSource.cpp
1227
src/data/properties.cpp
28+
src/data/rasterSource.h
1329
src/data/rasterSource.cpp
1430
src/data/tileSource.cpp
31+
src/data/formats/geoJson.h
1532
src/data/formats/geoJson.cpp
33+
src/data/formats/mvt.h
1634
src/data/formats/mvt.cpp
35+
src/data/formats/topoJson.h
1736
src/data/formats/topoJson.cpp
37+
src/debug/frameInfo.h
1838
src/debug/frameInfo.cpp
39+
src/debug/textDisplay.h
1940
src/debug/textDisplay.cpp
41+
src/gl/framebuffer.h
2042
src/gl/framebuffer.cpp
43+
src/gl/glError.h
2144
src/gl/glError.cpp
45+
src/gl/glyphTexture.h
2246
src/gl/glyphTexture.cpp
47+
src/gl/hardware.h
2348
src/gl/hardware.cpp
49+
src/gl/mesh.h
2450
src/gl/mesh.cpp
51+
src/gl/primitives.h
2552
src/gl/primitives.cpp
53+
src/gl/renderState.h
2654
src/gl/renderState.cpp
55+
src/gl/shaderProgram.h
2756
src/gl/shaderProgram.cpp
57+
src/gl/shaderSource.h
2858
src/gl/shaderSource.cpp
59+
src/gl/texture.h
2960
src/gl/texture.cpp
61+
src/gl/vao.h
3062
src/gl/vao.cpp
63+
src/gl/vertexLayout.h
3164
src/gl/vertexLayout.cpp
65+
src/js/JavaScript.h
66+
src/js/JavaScriptFwd.h
67+
src/labels/curvedLabel.h
3268
src/labels/curvedLabel.cpp
69+
src/labels/label.h
3370
src/labels/label.cpp
71+
src/labels/labelCollider.h
3472
src/labels/labelCollider.cpp
73+
src/labels/labelProperty.h
3574
src/labels/labelProperty.cpp
75+
src/labels/labelSet.h
3676
src/labels/labelSet.cpp
77+
src/labels/labels.h
3778
src/labels/labels.cpp
79+
src/labels/spriteLabel.h
3880
src/labels/spriteLabel.cpp
81+
src/labels/textLabel.h
3982
src/labels/textLabel.cpp
83+
src/marker/marker.h
4084
src/marker/marker.cpp
85+
src/marker/markerManager.h
4186
src/marker/markerManager.cpp
87+
src/scene/ambientLight.h
4288
src/scene/ambientLight.cpp
89+
src/scene/dataLayer.h
4390
src/scene/dataLayer.cpp
91+
src/scene/directionalLight.h
4492
src/scene/directionalLight.cpp
93+
src/scene/drawRule.h
4594
src/scene/drawRule.cpp
95+
src/scene/filters.h
4696
src/scene/filters.cpp
97+
src/scene/importer.h
4798
src/scene/importer.cpp
99+
src/scene/light.h
48100
src/scene/light.cpp
101+
src/scene/pointLight.h
49102
src/scene/pointLight.cpp
103+
src/scene/scene.h
50104
src/scene/scene.cpp
105+
src/scene/sceneLayer.h
51106
src/scene/sceneLayer.cpp
107+
src/scene/sceneLoader.h
52108
src/scene/sceneLoader.cpp
109+
src/scene/spotLight.h
53110
src/scene/spotLight.cpp
111+
src/scene/spriteAtlas.h
54112
src/scene/spriteAtlas.cpp
113+
src/scene/stops.h
55114
src/scene/stops.cpp
115+
src/scene/styleContext.h
56116
src/scene/styleContext.cpp
117+
src/scene/styleMixer.h
57118
src/scene/styleMixer.cpp
119+
src/scene/styleParam.h
58120
src/scene/styleParam.cpp
121+
src/selection/featureSelection.h
59122
src/selection/featureSelection.cpp
123+
src/selection/selectionQuery.h
60124
src/selection/selectionQuery.cpp
125+
src/style/debugStyle.h
61126
src/style/debugStyle.cpp
127+
src/style/debugTextStyle.h
62128
src/style/debugTextStyle.cpp
129+
src/style/material.h
63130
src/style/material.cpp
131+
src/style/pointStyle.h
64132
src/style/pointStyle.cpp
133+
src/style/pointStyleBuilder.h
65134
src/style/pointStyleBuilder.cpp
135+
src/style/polygonStyle.h
66136
src/style/polygonStyle.cpp
137+
src/style/polylineStyle.h
67138
src/style/polylineStyle.cpp
139+
src/style/rasterStyle.h
68140
src/style/rasterStyle.cpp
141+
src/style/style.h
69142
src/style/style.cpp
143+
src/style/textStyle.h
70144
src/style/textStyle.cpp
145+
src/style/textStyleBuilder.h
71146
src/style/textStyleBuilder.cpp
147+
src/text/fontContext.h
72148
src/text/fontContext.cpp
149+
src/text/textUtil.h
73150
src/text/textUtil.cpp
151+
src/tile/tile.h
74152
src/tile/tile.cpp
153+
src/tile/tileBuilder.h
75154
src/tile/tileBuilder.cpp
155+
src/tile/tileManager.h
76156
src/tile/tileManager.cpp
77157
src/tile/tileTask.cpp
158+
src/tile/tileWorker.h
78159
src/tile/tileWorker.cpp
160+
src/util/builders.h
79161
src/util/builders.cpp
162+
src/util/dashArray.h
80163
src/util/dashArray.cpp
164+
src/util/extrude.h
81165
src/util/extrude.cpp
166+
src/util/floatFormatter.h
82167
src/util/floatFormatter.cpp
168+
src/util/geom.h
83169
src/util/geom.cpp
170+
src/util/inputHandler.h
84171
src/util/inputHandler.cpp
172+
src/util/jobQueue.h
85173
src/util/jobQueue.cpp
174+
src/util/json.h
86175
src/util/json.cpp
176+
src/util/mapProjection.h
87177
src/util/mapProjection.cpp
178+
src/util/rasterize.h
88179
src/util/rasterize.cpp
89180
src/util/stbImage.cpp
90181
src/util/url.cpp
182+
src/util/yamlPath.h
91183
src/util/yamlPath.cpp
184+
src/util/yamlUtil.h
92185
src/util/yamlUtil.cpp
186+
src/util/zipArchive.h
93187
src/util/zipArchive.cpp
188+
src/util/zlibHelper.h
94189
src/util/zlibHelper.cpp
190+
src/view/flyTo.h
95191
src/view/flyTo.cpp
192+
src/view/view.h
96193
src/view/view.cpp
194+
src/view/viewConstraint.h
97195
src/view/viewConstraint.cpp
98196
)
99197

@@ -138,15 +236,15 @@ target_link_libraries(tangram-core
138236

139237
# Add JavaScript implementation.
140238
if(TANGRAM_JSCORE_ENABLED)
141-
target_sources(tangram-core PRIVATE src/js/JSCoreContext.cpp)
239+
target_sources(tangram-core PRIVATE src/js/JSCoreContext.cpp src/js/JSCoreContext.h)
142240
if (TANGRAM_USE_JSCORE_STATIC)
143241
target_link_libraries(tangram-core PRIVATE jscore-static)
144242
else()
145243
target_link_libraries(tangram-core PRIVATE "-framework JavaScriptCore")
146244
endif()
147245
target_compile_definitions(tangram-core PRIVATE TANGRAM_USE_JSCORE=1)
148246
else()
149-
target_sources(tangram-core PRIVATE src/js/DuktapeContext.cpp)
247+
target_sources(tangram-core PRIVATE src/js/DuktapeContext.cpp src/js/DuktapeContext.h)
150248
target_link_libraries(tangram-core PRIVATE duktape)
151249
endif()
152250

@@ -184,9 +282,6 @@ target_compile_options(tangram-core
184282
PUBLIC -std=c++14
185283
)
186284

187-
# make groups for xcode
188-
group_recursive_sources(src "src")
189-
190285
# We include GLSL shader sources into the library by generating header files with the source text
191286
# printed into a string constant. A CMake script generates one of these headers for each shader source
192287
# file and they each become a custom target that the core library depends on.
@@ -231,3 +326,9 @@ foreach(_shader ${SHADER_FILES})
231326
endforeach()
232327
add_custom_target(shader-headers DEPENDS ${SHADER_OUTPUT_FILES})
233328
add_dependencies(tangram-core shader-headers)
329+
330+
if(CMAKE_VERSION VERSION_GREATER "3.8")
331+
# Create source groups for Xcode - this source_group syntax requires version >=3.8
332+
get_target_property(TANGRAM_CORE_SOURCES tangram-core SOURCES)
333+
source_group(TREE ${PROJECT_SOURCE_DIR} FILES ${TANGRAM_CORE_SOURCES})
334+
endif()

0 commit comments

Comments
 (0)