forked from cnr-isti-vclab/corto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
130 lines (111 loc) · 3.99 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
128
129
130
cmake_minimum_required(VERSION 3.1)
project(corto)
option(BUILD_CORTO_CODEC_UNITY "Build the unity codec shared library of corto" ON)
option(BUILD_CORTO_EXE "Build the command line binary of corto" ON)
set (CMAKE_CXX_STANDARD 11)
SET(CORTO_SOURCE_PATH src)
SET(CORTO_HEADER_PATH include/corto)
SET(LIB_HEADERS
${CORTO_HEADER_PATH}/bitstream.h
${CORTO_HEADER_PATH}/color_attribute.h
${CORTO_HEADER_PATH}/corto.h
${CORTO_HEADER_PATH}/cstream.h
${CORTO_HEADER_PATH}/decoder.h
${CORTO_HEADER_PATH}/encoder.h
${CORTO_HEADER_PATH}/index_attribute.h
${CORTO_HEADER_PATH}/normal_attribute.h
${CORTO_HEADER_PATH}/point.h
${CORTO_HEADER_PATH}/tunstall.h
${CORTO_HEADER_PATH}/vertex_attribute.h
${CORTO_HEADER_PATH}/zpoint.h
${CORTO_SOURCE_PATH}/corto_codec.h)
SET(LIB_SOURCES
${CORTO_SOURCE_PATH}/bitstream.cpp
${CORTO_SOURCE_PATH}/color_attribute.cpp
${CORTO_SOURCE_PATH}/cstream.cpp
${CORTO_SOURCE_PATH}/decoder.cpp
${CORTO_SOURCE_PATH}/encoder.cpp
${CORTO_SOURCE_PATH}/normal_attribute.cpp
${CORTO_SOURCE_PATH}/tunstall.cpp
${CORTO_SOURCE_PATH}/corto_codec.cpp)
SET(EXE_SOURCE
${CORTO_SOURCE_PATH}/main.cpp
${CORTO_SOURCE_PATH}/meshloader.cpp
${CORTO_SOURCE_PATH}/tinyply.cpp)
SET(EXE_HEADERS
${CORTO_SOURCE_PATH}/meshloader.h
${CORTO_SOURCE_PATH}/tinyply.h
${CORTO_SOURCE_PATH}/objload.h)
SET(CORTO_DEFINITIONS "")
if(MSVC)
SET(CORTO_CFLAGS /nologo /W3)
LIST(APPEND CORTO_DEFINITIONS _CRT_SECURE_NO_DEPRECATE)
else()
SET(CORTO_CFLAGS -O2 -W -Wall -c -std=c++11 -pedantic)
endif()
ADD_LIBRARY(corto STATIC ${LIB_SOURCES} ${LIB_HEADERS})
SET(CORTOLIB_CFLAGS ${CORTO_CFLAGS})
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
LIST(APPEND CORTOLIB_CFLAGS -fPIC)
elseif(APPLE)
LIST(APPEND CORTOLIB_CFLAGS -fvisibility=hidden)
if(IOS)
LIST(APPEND CORTOLIB_CFLAGS -fembed-bitcode)
set_xcode_property(corto IPHONEOS_DEPLOYMENT_TARGET "9.2")
endif(IOS)
endif()
target_include_directories(corto PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(corto PRIVATE ${CORTO_HEADER_PATH})
target_compile_definitions(corto PUBLIC ${CORTO_DEFINITIONS})
target_compile_options (corto PUBLIC ${CORTOLIB_CFLAGS})
set_target_properties (corto PROPERTIES DEBUG_POSTFIX "d")
INSTALL(TARGETS corto
RUNTIME DESTINATION bin
BUNDLE DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
INSTALL(FILES
${CORTO_HEADER_PATH}/bitstream.h
${CORTO_HEADER_PATH}/color_attribute.h
${CORTO_HEADER_PATH}/corto.h
${CORTO_HEADER_PATH}/cstream.h
${CORTO_HEADER_PATH}/decoder.h
${CORTO_HEADER_PATH}/encoder.h
${CORTO_HEADER_PATH}/index_attribute.h
${CORTO_HEADER_PATH}/normal_attribute.h
${CORTO_HEADER_PATH}/point.h
${CORTO_HEADER_PATH}/tunstall.h
${CORTO_HEADER_PATH}/vertex_attribute.h
${CORTO_HEADER_PATH}/zpoint.h
DESTINATION include/corto)
if (BUILD_CORTO_CODEC_UNITY)
ADD_LIBRARY(cortocodec_unity SHARED ${LIB_SOURCES} ${LIB_HEADERS})
target_include_directories(cortocodec_unity PUBLIC ${CORTO_SOURCE_PATH})
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
# G++
target_compile_options(cortocodec_unity PRIVATE -Wall -Wextra)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
# MSVC
target_compile_options(cortocodec_unity PRIVATE /EHsc /MTd /W2 /c)
# Set the DLLEXPORT variable to export symbols
target_compile_definitions(cortocodec_unity PRIVATE WIN_EXPORT)
endif()
endif()
if (BUILD_CORTO_EXE)
ADD_EXECUTABLE(cortoexe ${EXE_SOURCE} ${EXE_HEADERS})
SET(CORTOEXE_CFLAGS ${CORTO_CFLAGS})
if(APPLE)
if(IOS)
set_xcode_property(cortoexe IPHONEOS_DEPLOYMENT_TARGET "9.2")
endif()
endif()
target_include_directories(cortoexe PUBLIC ${CORTO_SOURCE_PATH})
target_link_libraries(cortoexe PUBLIC corto)
target_compile_options (cortoexe PUBLIC ${CORTOEXE_CFLAGS})
set_target_properties (cortoexe PROPERTIES OUTPUT_NAME "corto")
INSTALL(TARGETS cortoexe
RUNTIME DESTINATION bin
BUNDLE DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif()