# CMakeLists.txt  --  Ravenna Project
# Copyright (C) 2017, Merging Technologies S.A. All rights reserved.
# For copyright information and disclaimer see file COPYRIGHT in root directory of source tree (or contact Merging Technologies S.A.)

if(NOT ZMAN_SDK)
	include_directories("${CMAKE_SOURCE_DIR}/applications/zman/common")
endif()
include_directories("../common")


#########################################################################################
# Set package properties
project(oem_modules_process)

#########################################################################################
# Perform build configuration of dependencies


#########################################################################################
# All the project files
set(SOURCES
	main.cpp
	
	hardware.cpp
	IPC_dispatcher.cpp
	I2S_modules.cpp
	)
set(COMMON_SOURCES

	)
	
    
set(HEADERS 
	hardware.hpp
	IPC_dispatcher.hpp
	I2S_modules.hpp	
	)
set(COMMON_HEADERS
	../common/oem_modules_process_defs.h
	)


#########################################################################################
# Build and link the project


source_group("Generated Sources - Do Not Edit" FILES ${GENERATED_SOURCES})
source_group("Sources" FILES ${SOURCES} ${HEADERS})
source_group("Common" FILES ${COMMON_SOURCES} ${COMMON_HEADERS})


# Make sure the compiler can find the pre-processed files from qt4/5_wrap_ui
include_directories("${PROJECT_BINARY_DIR}")

# Build the app!
add_executable(${PROJECT_NAME}
 
     # source files that are actually built direclty
     ${SOURCES}
	 ${COMMON_SOURCES}	 
     ${WIN32_SOURCES}	 
     ${GENERATED_SOURCES}
     
     # items included so they show up in your IDE
     ${HEADERS}     
	 ${COMMON_HEADERS}
)


# ---------------------------------------------------------------------------

# Link the app!
target_link_libraries(${PROJECT_NAME} ${WIN32_LIBRAIRIES} ${Boost_LIBRARIES} ${MTAL_LIBRARIES} ${XILINX_LIBRARY} rvstd MTAL_IPC)

### Begin DEBUG
# Use oem_modules_process.debug with gdb to be able to debug oem_modules_process
if (WIN32)
else (WIN32)
	if (ZMAN_FAMILY)
			add_custom_command(	TARGET ${PROJECT_NAME}
								POST_BUILD
								COMMAND ${OBJCOPY} --only-keep-debug ${PROJECT_NAME} ${PROJECT_NAME}.debug
								COMMAND ${STRIP} ${PROJECT_NAME}
								COMMAND ${OBJCOPY} --add-gnu-debuglink=${PROJECT_NAME}.debug ${PROJECT_NAME}
								DEPENDS ${PROJECT_NAME}
								COMMENT "Separate debug symbols to file ${PROJECT_NAME}.debug") 
	endif (ZMAN_FAMILY)
endif (WIN32)
### End DEBUG

if (WIN32)
	
else (WIN32)
	if (ZMAN_FAMILY AND NOT ZMAN_SDK)
		install(TARGETS ${PROJECT_NAME} DESTINATION /opt/zman/rootfs/mnt/oem/bin)
	endif ()
endif (WIN32)

set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "ZMan/OEM")