# Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT("$(projectName)" C)


IF(NOT DEFINED PACKAGE_NAME)
	SET(PACKAGE_NAME "org.tizen.$(projectName)")
ENDIF(NOT DEFINED PACKAGE_NAME)

SET(PREFIX ${CMAKE_INSTALL_PREFIX})
IF(NOT DEFINED BINDIR)
	SET(BINDIR"${PREFIX}/bin")
ENDIF(NOT DEFINED BINDIR)
IF(NOT DEFINED MANIFESTDIR)
	SET(MANIFESTDIR "/opt/share/packages")
ENDIF(NOT DEFINED MANIFESTDIR)
IF(NOT DEFINED DESKTOP_ICONDIR)
	SET(DESKTOP_ICONDIR "/opt/share/icons/default/small")
ENDIF(NOT DEFINED DESKTOP_ICONDIR)
IF(NOT DEFINED DESKTOP_ICON)
	SET(DESKTOP_ICON ${PACKAGE_NAME}.png)
ENDIF(DESKTOP_ICON)

SET(SRCS src/main.c)

ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE_NAME}\"")

INCLUDE(FindPkgConfig)
pkg_check_modules(PKGS REQUIRED
        elementary
        capi-appfw-application
        capi-system-system-settings
        efl-extension
        dlog)

FOREACH(flag ${PKGS_CFLAGS})
	SET(EXTRA_CFLGAS "${EXTRA_CFLGAS} ${flag}")
ENDFOREACH(flag)

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLGAS}")
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKGS_LDFLAGS})
CONFIGURE_FILE(${PACKAGE_NAME}.xml.in ${PACKAGE_NAME}.xml)

INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
INSTALL(FILES ${PACKAGE_NAME}.xml DESTINATION ${MANIFESTDIR})
INSTALL(FILES ${CMAKE_SOURCE_DIR}/${DESKTOP_ICON} DESTINATION ${DESKTOP_ICONDIR})

