1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
6 SET(VERSION "${VERSION_MAJOR}.1.0")
10 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
11 SET(EXEC_PREFIX "\${prefix}")
12 SET(LIBDIR "\${prefix}/lib")
13 SET(INCLUDEDIR "\${prefix}/include")
15 # Build type : Release
16 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
17 SET(CMAKE_BUILD_TYPE "Release")
19 MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
22 # Set required packages
23 INCLUDE(FindPkgConfig)
25 #pkg_check_modules(libpkgs REQUIRED )
26 #FOREACH(flag ${libpkgs_CFLAGS})
27 # SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
31 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
32 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
33 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
34 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Wmissing-prototypes -Wno-sign-compare -g -DHAVE_MMAP")
35 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
36 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
37 SET(CMAKE_C_FLAGS_RELEASE "-O2")
39 SET(CMAKE_SKIP_BUILD_RPATH true)
41 # Get uname value to set 'TARGET' definition
42 # TODO: Is this needed?
43 FIND_PROGRAM(UNAME NAMES uname)
44 EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
45 IF("${ARCH}" STREQUAL "arm")
46 ADD_DEFINITIONS("-DTARGET")
47 MESSAGE("add -DTARGET")
48 ENDIF("${ARCH}" STREQUAL "arm")
50 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
53 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
58 add_library(xdgmime SHARED
60 xdgmime/src/xdgmimeglob.c
61 xdgmime/src/xdgmimeint.c
62 xdgmime/src/xdgmimemagic.c
63 xdgmime/src/xdgmimealias.c
64 xdgmime/src/xdgmimeparent.c
65 xdgmime/src/xdgmimecache.c
66 xdgmime/src/xdgmimeicon.c
67 xdgmime/src/xdgmimeglobs2.c
69 target_link_libraries(xdgmime ${libpkgs_LDFLAGS})
70 SET_TARGET_PROPERTIES(xdgmime PROPERTIES SOVERSION ${VERSION_MAJOR})
71 SET_TARGET_PROPERTIES(xdgmime PROPERTIES VERSION ${VERSION})
74 CONFIGURE_FILE(xdgmime.pc.in xdgmime.pc @ONLY)
77 INSTALL(TARGETS xdgmime DESTINATION lib COMPONENT RuntimeLibraries)
79 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/xdgmime/src/xdgmime.h DESTINATION include)
80 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/xdgmime.pc DESTINATION lib/pkgconfig)
83 add_subdirectory(test)