Add conditional build stuff
[platform/core/api/efl-util.git] / CMakeLists.txt
1
2 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
3 SET(fw_name "capi-ui-efl-util")
4
5 PROJECT(${fw_name})
6
7 SET(CMAKE_INSTALL_PREFIX /usr)
8 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
9
10 SET(INC_DIR include)
11 INCLUDE_DIRECTORIES(${INC_DIR})
12
13 # required dependencies
14 SET(dependents "dlog elementary capi-base-common")
15
16 INCLUDE(FindPkgConfig)
17 pkg_check_modules(${fw_name} REQUIRED ${dependents})
18 FOREACH(flag ${${fw_name}_CFLAGS})
19     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
20 ENDFOREACH(flag)
21
22 # optional
23 SET(ECORE_X "ecore-x utilX")
24 pkg_check_modules(ECORE_X ${ECORE_X})
25 FOREACH(flag ${${ECORE_X}_CFLAGS})
26     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
27 ENDFOREACH(flag)
28
29 IF (ECORE_X_FOUND)
30    SET(HAVE_X "1")
31    SET(deps "${deps} ecore-x utilX")
32 ELSE (ECORE_X_FOUND)
33    SET(HAVE_X "0")
34 ENDIF (ECORE_X_FOUND)
35
36 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
37 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
38
39 IF("${ARCH}" STREQUAL "arm")
40     ADD_DEFINITIONS("-DTARGET")
41 ENDIF("${ARCH}" STREQUAL "arm")
42
43 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
44 ADD_DEFINITIONS("-DSLP_DEBUG")
45
46 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
47
48 aux_source_directory(src SOURCES)
49 ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
50
51 TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
52
53 SET_TARGET_PROPERTIES(${fw_name}
54      PROPERTIES
55      VERSION ${FULLVER}
56      SOVERSION ${MAJORVER}
57      CLEAN_DIRECT_OUTPUT 1
58 )
59
60 INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
61 INSTALL(
62         DIRECTORY ${INC_DIR}/ DESTINATION include/ui
63         FILES_MATCHING
64         PATTERN "*_private.h" EXCLUDE
65         PATTERN "${INC_DIR}/*.h"
66         )
67
68 SET(PC_NAME ${fw_name})
69 SET(PC_REQUIRED ${dependents})
70 SET(PC_LDFLAGS -l${fw_name})
71 SET(PC_CFLAGS -I\${includedir}/ui)
72
73 CONFIGURE_FILE(
74     capi-ui-efl-util.pc.in
75     ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
76     @ONLY
77 )
78
79 CONFIGURE_FILE(
80     config.h.in
81     ${CMAKE_CURRENT_SOURCE_DIR}/include/config.h
82     @ONLY
83 )
84
85 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
86
87 IF(UNIX)
88
89 ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
90 ADD_CUSTOM_COMMAND(
91         DEPENDS clean 
92         COMMENT "distribution clean"
93         COMMAND find
94         ARGS    . 
95         -not -name config.cmake -and \(
96         -name tester.c -or
97         -name Testing -or
98         -name CMakeFiles -or
99         -name cmake.depends -or
100         -name cmake.check_depends -or
101         -name CMakeCache.txt -or
102         -name cmake.check_cache -or
103         -name *.cmake -or
104         -name Makefile -or
105         -name core -or
106         -name core.* -or
107         -name gmon.out -or
108         -name install_manifest.txt -or
109         -name *.pc -or
110         -name *~ \)
111         | grep -v TC | xargs rm -rf
112         TARGET  distclean
113         VERBATIM
114 )
115
116 ENDIF(UNIX)
117