forked from gopro/cineform-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
138 lines (122 loc) · 5.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# CMakeLists.txt
cmake_minimum_required (VERSION 3.5.1)
project (CineFormSDK)
# Build settings
option(BUILD_LIBS "Build codec libraries" ON)
option(BUILD_TOOLS "Build test tools" ON)
option(BUILD_STATIC "Build static component" ON)
option(BUILD_SEPARATED "Build a separate de/encoder libraries" OFF)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
add_definitions(-D_ALLOCATOR=1 -DWARPSTUFF=1)
if (WIN32)
SET(COMPILER_FLAGS "")
SET(COMPILER_FLAGS_W_OMP "/openmp" )
SET(ADDITIONAL_LIBS "")
endif (WIN32)
if (UNIX)
SET(COMPILER_FLAGS -fPIC -O3)
SET(COMPILER_FLAGS_W_OMP -fopenmp -O3)
SET(ADDITIONAL_LIBS "-luuid -lpthread -lgomp")
SET(TOY_LIBS "-lm")
endif (UNIX)
if (APPLE)
SET(COMPILER_FLAGS -fvisibility=hidden -O3)
SET(COMPILER_FLAGS_W_OMP -O3)
SET(ADDITIONAL_LIBS "-lpthread")
endif (APPLE)
include_directories("Common" "Tables" "Codec" "ConvertLib" "WarpLib" "Example")
file(GLOB CODEC_SOURCES "Codec/*.c" "Codec/*.h" "Codec/*.cpp" "WarpLib/*.c" "WarpLib/*.h" )
file(GLOB ENCODER_SOURCES "EncoderSDK/*.cpp" "Common/*.h")
file(GLOB DECODER_SOURCES "DecoderSDK/*.cpp" "Common/*.h" "WarpLib/*.c" "WarpLib/*.h" "ConvertLib/*.cpp" "ConvertLib/*.h" )
file(GLOB EXAMPLE_SOURCE "Example/*.cpp" "Example/*.h" )
file(GLOB WAVELETDEMO_SOURCE "Example/WaveletDemo/*.c" "Example/WaveletDemo/*.h" )
file(GLOB PUBLIC_HEADERS "Common/*.h")
# Build CFHDCodec library (static and shared rules)
if (BUILD_LIBS)
if (BUILD_STATIC)
if (BUILD_SEPARATED)
add_library(CFHDEncoderStatic STATIC ${CODEC_SOURCES} ${ENCODER_SOURCES})
add_library(CFHDDecoderStatic STATIC ${CODEC_SOURCES} ${DECODER_SOURCES})
target_compile_options(CFHDEncoderStatic PUBLIC ${COMPILER_FLAGS})
target_compile_options(CFHDDecoderStatic PUBLIC ${COMPILER_FLAGS})
target_link_libraries (CFHDEncoderStatic)
target_link_libraries (CFHDDecoderStatic)
else (BUILD_SEPARATED)
add_library(CFHDCodecStatic STATIC ${CODEC_SOURCES} ${ENCODER_SOURCES} ${DECODER_SOURCES})
target_compile_options(CFHDCodecStatic PUBLIC ${COMPILER_FLAGS})
set_target_properties(CFHDCodecStatic PROPERTIES POSITION_INDEPENDENT_CODE ON)
if (UNIX)
set_target_properties(CFHDCodecStatic PROPERTIES OUTPUT_NAME CFHDCodec)
endif (UNIX)
target_link_libraries(CFHDCodecStatic)
endif (BUILD_SEPARATED)
else (BUILD_STATIC)
if (BUILD_SEPARATED)
add_library(CFHDEncoder SHARED ${CODEC_SOURCES} ${ENCODER_SOURCES})
add_library(CFHDDecoder SHARED ${CODEC_SOURCES} ${DECODER_SOURCES})
target_compile_options(CFHDEncoder PUBLIC ${COMPILER_FLAGS})
target_compile_options(CFHDDecoder PUBLIC ${COMPILER_FLAGS})
target_compile_definitions(CFHDEncoder PUBLIC -DDYNAMICLIB=1)
target_compile_definitions(CFHDDecoder PUBLIC -DDYNAMICLIB=1)
target_link_libraries (CFHDEncoder)
target_link_libraries (CFHDDecoder)
else (BUILD_SEPARATED)
add_library(CFHDCodecShared SHARED ${CODEC_SOURCES} ${ENCODER_SOURCES} ${DECODER_SOURCES})
target_compile_options(CFHDCodecShared PUBLIC ${COMPILER_FLAGS})
target_compile_definitions(CFHDCodecShared PUBLIC -DDYNAMICLIB=1 -DCODECCOMBINED=1)
target_link_libraries(CFHDCodecShared)
set_target_properties(CFHDCodecShared PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(CFHDCodecShared PROPERTIES OUTPUT_NAME CFHDCodec)
endif (BUILD_SEPARATED)
endif (BUILD_STATIC)
endif (BUILD_LIBS)
# Build tools
if (BUILD_TOOLS)
# TestCFHD
add_executable(TestCFHD ${EXAMPLE_SOURCE})
target_compile_options(TestCFHD PRIVATE ${COMPILER_FLAGS_W_OMP})
if (BUILD_STATIC)
if (BUILD_SEPARATED)
target_link_libraries(TestCFHD CFHDEncoderStatic CFHDDecoderStatic ${INTERNAL_LIBS} ${ADDITIONAL_LIBS})
else (BUILD_SEPARATED)
target_link_libraries(TestCFHD CFHDCodecStatic ${INTERNAL_LIBS} ${ADDITIONAL_LIBS})
endif (BUILD_SEPARATED)
else (BUILD_STATIC)
if (BUILD_SEPARATED)
target_link_libraries(TestCFHD CFHDEncoder CFHDDecoder ${INTERNAL_LIBS} ${ADDITIONAL_LIBS})
else (BUILD_SEPARATED)
target_link_libraries(TestCFHD CFHDCodecShared ${INTERNAL_LIBS} ${ADDITIONAL_LIBS})
endif (BUILD_SEPARATED)
endif (BUILD_STATIC)
# WaveletDemo
add_executable(WaveletDemo ${WAVELETDEMO_SOURCE})
target_link_libraries(WaveletDemo ${TOY_LIBS})
endif (BUILD_TOOLS)
# pkg-config integration
set(PROJECT_VERSION "10.0.2")
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
set(EXEC_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Installation prefix for executables and object code libraries" FORCE)
set(BIN_INSTALL_DIR ${EXEC_INSTALL_PREFIX}/bin CACHE PATH "Installation prefix for user executables" FORCE)
set(LIB_INSTALL_DIR ${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX} CACHE PATH "Installation prefix for object code libraries" FORCE)
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/cineformsdk CACHE PATH "Installation prefix for header files" FORCE)
# System wide installation
if (BUILD_STATIC)
if (BUILD_SEPARATED)
set(TARGET_NAMES CFHDEncoderStatic CFHDDecoderStatic)
else (BUILD_SEPARATED)
set(TARGET_NAMES CFHDCodecStatic)
endif (BUILD_SEPARATED)
else (BUILD_STATIC)
if (BUILD_SEPARATED)
set(TARGET_NAMES CFHDEncoder CFHDDecoder)
else (BUILD_SEPARATED)
set(TARGET_NAMES CFHDCodecShared)
endif (BUILD_SEPARATED)
endif (BUILD_STATIC)
foreach(TARGET_NAME ${TARGET_NAMES})
set(LIB_INSTALL_NAMES ${LIB_INSTALL_NAMES} -l${TARGET_NAME})
endforeach()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libcineformsdk.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libcineformsdk.pc)
install(TARGETS ${TARGET_NAMES} DESTINATION lib/)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcineformsdk.pc DESTINATION lib/pkgconfig)
install(FILES ${PUBLIC_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR})