-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
115 lines (99 loc) · 3.71 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
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
include(FetchContent)
set(CMAKE_CXX_STANDARD 11)
project (draco_c C CXX)
FetchContent_Declare(
draco
GIT_REPOSITORY https://github.com/google/draco.git
GIT_TAG 1.5.6
)
FetchContent_GetProperties(draco)
if(NOT draco_POPULATED)
FetchContent_Populate(draco)
set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(${draco_SOURCE_DIR} ${draco_BINARY_DIR} EXCLUDE_FROM_ALL)
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")
endif()
list(APPEND draco_c_sources
"${CMAKE_CURRENT_SOURCE_DIR}/src/decoder.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/src/mesh.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/src/point_cloud.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/src/point_attribute.cc"
)
list(APPEND draco_c_public_api "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(draco_INCLUDE_DIRS "${draco_SOURCE_DIR}/src" "${CMAKE_BINARY_DIR}")
if(BUILD_SHARED_LIBS)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(draco_lib_type SHARED)
else()
set(draco_lib_type STATIC)
endif()
add_library(draco_c ${draco_lib_type} ${draco_c_sources})
target_include_directories(draco_c PRIVATE ${draco_INCLUDE_DIRS})
target_include_directories(draco_c PUBLIC ${draco_c_public_api})
if(BUILD_SHARED_LIBS)
target_compile_definitions(draco_c PRIVATE "DRACO_C_BUILDING_DLL=1")
set(link_type PRIVATE)
set_target_properties(draco_c PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS FALSE)
set_target_properties(draco_c PROPERTIES C_VISIBILITY_PRESET hidden)
set_target_properties(draco_c PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(draco_c PROPERTIES VISIBILITY_INLINES_HIDDEN ON)
else()
target_compile_definitions(draco_c PRIVATE "DRACO_C_STATIC=1")
set(link_type PUBLIC)
endif()
set(draco_object_library_deps
draco_attributes
draco_compression_attributes_dec
draco_compression_attributes_enc
draco_compression_attributes_pred_schemes_dec
draco_compression_attributes_pred_schemes_enc
draco_compression_bit_coders
draco_compression_decode
draco_compression_encode
draco_compression_entropy
draco_compression_mesh_dec
draco_compression_mesh_enc
draco_compression_point_cloud_dec
draco_compression_point_cloud_enc
draco_core
draco_dec_config
draco_enc_config
draco_io
draco_mesh
draco_metadata
draco_metadata_dec
draco_metadata_enc
draco_animation
draco_animation_dec
draco_animation_enc
draco_point_cloud
draco_points_dec
draco_points_enc)
target_link_libraries(draco_c PRIVATE ${draco_object_library_deps})
if(DRACO_C_TESTS)
enable_testing()
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
FetchContent_Populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
set(SRCS_UNITTEST
"${CMAKE_CURRENT_SOURCE_DIR}/src/c_api_test.cc"
)
add_executable(test_draco_c ${SRCS_UNITTEST})
target_include_directories(test_draco_c PRIVATE
"${draco_INCLUDE_DIRS}"
"${gtest_SOURCE_DIR}/include"
)
target_link_libraries(test_draco_c PRIVATE draco_c gtest gtest_main)
target_compile_definitions(test_draco_c PRIVATE "DRACO_C_STATIC=1")
add_definitions(-DDRACO_C_TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/testdata/")
add_test(test_draco_c ${CMAKE_CURRENT_BINARY_DIR}/test_draco_c)
endif()