File: CMakeLists.txt

package info (click to toggle)
gtkpod 2.1.5-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 19,428 kB
  • ctags: 6,307
  • sloc: ansic: 51,604; xml: 16,135; sh: 11,916; cpp: 7,545; perl: 1,449; makefile: 1,376; lex: 638; awk: 73; python: 35
file content (153 lines) | stat: -rw-r--r-- 4,433 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
    message("In-source build attempted; use out-of source builds.")
    message(FATAL_ERROR "Refer to the CMake documentation for more details.")
endif()

message("-------------------------------------------")
message("Configuration started")
message("-------------------------------------------")
project(gtkpod)
cmake_minimum_required(VERSION 2.6)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")

set(PACKAGE ${CMAKE_PROJECT_NAME})
set(VERSION 1.0.0)
set(GETTEXT_PACKAGE ${CMAKE_PROJECT_NAME})
set(PACKAGE_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share)
set(PACKAGE_LOCALE_DIR ${PACKAGE_DATA_DIR}/locale)

option(USE_CLANG "Use clang instead of gcc to compile" OFF)
option(USE_LOCAL_DATA_FILES
    "Use data files in the source directory when running" OFF)
option(WANT_CURL "Enable build with CURL" ON)
option(WANT_GIO "Enable build with GIO" ON)
option(WANT_LIBVORBISFILE "Enable build with libvorbisfile" ON)
option(WANT_FLAC "Enable build with FLAC" ON)
option(LINK_AS_NEEDED "Link with -Wl,--as-needed" ON)

if(USE_CLANG)
    set(CMAKE_C_COMPILER clang)
endif()

if(USE_LOCAL_DATA_FILES)
    set(PACKAGE_DATA_DIR ${CMAKE_SOURCE_DIR})
endif()

include(flex)
include(CheckIncludeFile)
include(CheckIncludeFiles)

find_package(PkgConfig REQUIRED)
find_package(GTK2 REQUIRED)
find_package(Glade REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(Libgpod REQUIRED)
find_package(ID3tag REQUIRED)
CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H)
CHECK_INCLUDE_FILES(mp4v2/platform.h HAVE_MP4V2_PLATFORM_H)

# This is hacky... the result is a test file that looks like this:
# #include <mp4v2/platform.h>
# typedef void* MP4FileHandle;//>
# #include <mp4v2/itmf_tags.h>
# This matches the way it's used in the code, and the autoconf test
CHECK_INCLUDE_FILES("mp4v2/platform.h>\ntypedef void* MP4FileHandle\;//;mp4v2/itmf_tags.h" HAVE_MP4V2_ITMF_TAGS_H)

set(OPT_INCLUDES "")
set(OPT_CFLAGS "")
set(OPT_LIBS "")

if(WANT_CURL)
    message("-- Checking for CURL...")
    find_package(CURL)
    if(CURL_FOUND)
        set(HAVE_CURL ON)
        set(OPT_INCLUDES ${OPT_INCLUDES} ${CURL_INCLUDE_DIRS})
        set(OPT_LIBS ${OPT_LIBS} ${CURL_LIBRARIES})
    endif()
endif()

if(WANT_GIO)
    find_package(GIO)
    if(GIO_FOUND)
        set(HAVE_GIO 1)
        set(OPT_INCLUDES ${OPT_INCLUDES} ${GIO_INCLUDE_DIRS})
        set(OPT_CFLAGS ${OPT_CFLAGS} ${GIO_CFLAGS_OTHER})
        set(OPT_LIBS ${OPT_LIBS} ${GIO_LDFLAGS})
    endif()
endif()

if(WANT_LIBVORBISFILE)
    find_package(VorbisFile)
    if(VORBISFILE_FOUND)
        set(HAVE_LIBVORBISFILE 1)
        set(OPT_INCLUDES ${OPT_INCLUDES} ${VORBISFILE_INCLUDE_DIRS})
        set(OPT_CFLAGS ${OPT_CFLAGS} ${VORBISFILE_CFLAGS_OTHER})
        set(OPT_LIBS ${OPT_LIBS} ${VORBISFILE_LDFLAGS})
    endif()
endif()

if(WANT_FLAC)
    find_package(FLAC)
    if(FLAC_FOUND)
        set(HAVE_FLAC 1)
        set(OPT_INCLUDES ${OPT_INCLUDES} ${FLAC_INCLUDE_DIRS})
        set(OPT_CFLAGS ${OPT_CFLAGS} ${FLAC_CFLAGS_OTHER})
        set(OPT_LIBS ${OPT_LIBS} ${FLAC_LDFLAGS})
    endif()
endif()

if(LINK_AS_NEEDED)
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
endif()

check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(stdint.h HAVE_STDINT_H)

include_directories(
    ${CMAKE_BINARY_DIR}
    ${CMAKE_SOURCE_DIR}/src
    ${GTK2_ALL_INCLUDES}
    ${LIBXML2_INCLUDE_DIR}
    ${GLADE2_INCLUDE_DIRS}
    ${LIBGPOD_INCLUDE_DIRS}
    ${ID3TAG_INCLUDE_DIRS}
    ${OPT_INCLUDES}
)

add_definitions(
    ${GTK2_ALL_CFLAGS}
    ${LIBXML2_DEFINITIONS}
    ${GLADE2_CFLAGS_OTHER}
    ${LIBGPOD_CFLAGS_OTHER}
    ${ID3TAG_CFLAGS_OTHER}
    ${OPT_CFLAGS}
    -DHAVE_CONFIG_H
)

configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.in
    ${CMAKE_BINARY_DIR}/config.h @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/data/man/gtkpod.1.in
    ${CMAKE_BINARY_DIR}/gtkpod.1 @ONLY)

set(INTLTOOL_MERGE_EXECUTABLE ${CMAKE_SOURCE_DIR}/cmake/intltool-merge)

add_custom_target(desktopfile ALL ${INTLTOOL_MERGE_EXECUTABLE} -d
    ${CMAKE_SOURCE_DIR}/po ${CMAKE_SOURCE_DIR}/data/gtkpod.desktop.in
    ${CMAKE_BINARY_DIR}/gtkpod.desktop)

include(sources)
include(Po)
compile_po_files(po GTKPOD_SOURCES)
add_executable(gtkpod ${GTKPOD_SOURCES})

target_link_libraries(gtkpod
    ${GTK2_ALL_LIBS}
    ${LIBXML2_LIBRARIES}
    ${GLADE2_LDFLAGS}
    ${LIBGPOD_LDFLAGS}
    ${ID3TAG_LDFLAGS}
    ${OPT_LIBS}
)

include(install)