Skip to content
Snippets Groups Projects
CMakeLists.txt 5.8 KiB
Newer Older
dnewman-gpsw's avatar
dnewman-gpsw committed
# CMakeLists.txt
cmake_minimum_required (VERSION 3.5.1)
dnewman-gpsw's avatar
dnewman-gpsw committed
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)
dnewman-gpsw's avatar
dnewman-gpsw committed

if (WIN32)
	SET(COMPILER_FLAGS "")
Grant Kim's avatar
Grant Kim committed
	if (MSVC)
		SET(COMPILER_FLAGS_W_OMP "/openmp")
Grant Kim's avatar
Grant Kim committed
		SET(ADDITIONAL_LIBS "")
	else()
		SET(COMPILER_FLAGS_W_OMP -fopenmp)
Grant Kim's avatar
Grant Kim committed
		SET(ADDITIONAL_LIBS "-lgomp")
	endif()
dnewman-gpsw's avatar
dnewman-gpsw committed
endif (WIN32)
 
if (UNIX)
	SET(COMPILER_FLAGS -fPIC)
	SET(COMPILER_FLAGS_W_OMP -fopenmp)
dnewman-gpsw's avatar
dnewman-gpsw committed
	SET(ADDITIONAL_LIBS "-luuid -lpthread -lgomp")
	SET(TOY_LIBS "-lm")
endif (UNIX)

if (APPLE)
	SET(COMPILER_FLAGS -fvisibility=hidden)
	SET(COMPILER_FLAGS_W_OMP)
dnewman-gpsw's avatar
dnewman-gpsw committed
	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" )
David's avatar
David committed
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")
dnewman-gpsw's avatar
dnewman-gpsw committed

# 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)
dnewman-gpsw's avatar
dnewman-gpsw committed

# Build tools
if (BUILD_TOOLS)
    # TestCFHD
    add_executable(TestCFHD ${EXAMPLE_SOURCE})
    target_compile_options(TestCFHD PRIVATE ${COMPILER_FLAGS_W_OMP})
dnewman-gpsw's avatar
dnewman-gpsw committed

    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)
dnewman-gpsw's avatar
dnewman-gpsw committed

    # 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)
dnewman-gpsw's avatar
dnewman-gpsw committed

# 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})