Newer
Older
cmake_minimum_required (VERSION 3.5.1)
# 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)
SET(COMPILER_FLAGS -fPIC)
SET(COMPILER_FLAGS_W_OMP -fopenmp)
SET(ADDITIONAL_LIBS "-luuid -lpthread -lgomp")
SET(TOY_LIBS "-lm")
endif (UNIX)
if (APPLE)
SET(COMPILER_FLAGS -fvisibility=hidden)
SET(COMPILER_FLAGS_W_OMP)
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")
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
# 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)
set(TARGET_NAMES CFHDCodecStatic)
endif (BUILD_SEPARATED)
else (BUILD_STATIC)
set(TARGET_NAMES CFHDEncoder CFHDDecoder)
set(TARGET_NAMES CFHDCodecShared)
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})