# 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" ) # 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) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libcineformsdk.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libcineformsdk.pc) # System wide installation if (BUILD_STATIC) if (BUILD_SEPARATED) install(TARGETS CFHDEncoderStatic CFHDDecoderStatic DESTINATION lib/) else (BUILD_SEPARATED) install(TARGETS CFHDCodecStatic DESTINATION lib/) endif (BUILD_SEPARATED) else (BUILD_STATIC) if (BUILD_SEPARATED) install(TARGETS CFHDEncoder CFHDDecoder DESTINATION lib/) else (BUILD_SEPARATED) install(TARGETS CFHDCodecShared DESTINATION lib/) endif (BUILD_SEPARATED) endif (BUILD_STATIC)