-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCMakeLists.txt
127 lines (101 loc) · 3.67 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 2.6)
project(xmradio C)
set(version 0.5.2)
set(XMR_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_MODULE_PATH ${XMR_CMAKE_PATH} ${CMAKE_MODULE_PATH})
include(cmake/macro.cmake)
# Default build type set to Release
# to avoid auto build system
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
option(NLS "Native language support" ON)
option(WARN_AS_ERROR "Warning as error" ON)
option(BUILD_TEST "Build tests" OFF)
option(ENABLE_ASAN "Build with Address-Sanitizer if gcc >= 4.8 or clang >= 3.1" OFF)
include(CheckIncludeFiles)
include(FindPkgConfig)
check_include_files(unistd.h HAVE_UNISTD_H)
check_include_files(malloc.h HAVE_MALLOC_H)
check_include_files(X11/XF86keysym.h HAVE_MMKEYS_H)
find_program(GLIB_GENMARSHAL
NAMES glib-genmarshal
DOC "glib-genmarshal executable"
)
mark_as_advanced(GLIB_GENMARSHAL)
if (NLS)
FIND_PACKAGE(Gettext REQUIRED)
endif(NLS)
if (NLS AND GETTEXT_FOUND)
set(ENABLE_NLS TRUE)
message(STATUS "Native language support: YES")
else(NLS AND GETTEXT_FOUND)
message(STATUS "Native language support: NO")
endif(NLS AND GETTEXT_FOUND)
set(package xmradio)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(bindir ${exec_prefix}/bin)
if (NOT DEFINED LIB_INSTALL_DIR)
get_property(_USE_LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
if ("${_USE_LIB64}" STREQUAL "TRUE")
set(LIB_INSTALL_DIR "${exec_prefix}/lib64")
else()
set(LIB_INSTALL_DIR "${exec_prefix}/lib")
endif()
endif()
set(libdir ${LIB_INSTALL_DIR})
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
set(pkgdatadir ${prefix}/share/${package})
set(localedir ${prefix}/share/locale)
set(skindir ${pkgdatadir}/skin)
set(i18ndir ${PROJECT_SOURCE_DIR}/po)
set(uidir ${pkgdatadir}/ui)
set(plugindir ${libdir}/${package}/plugins)
set(plugindatadir ${pkgdatadir}/plugins)
set(PLUGIN_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/plugins)
if (WARN_AS_ERROR)
set(CMAKE_C_FLAGS "-Wall -Werror ${CMAKE_C_FLAGS}")
endif(WARN_AS_ERROR)
if (ENABLE_ASAN)
if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_LESS 4.8)
message(WARNING "Your gcc version may not use Address-Sanitizer")
endif()
set(CMAKE_C_FLAGS "-fsanitize=address -fno-omit-frame-pointer ${CMAKE_C_FLAGS}")
elseif (${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE CLANG_VERSION)
if (CLANG_VERSION VERSION_LESS 3.1)
message(WARNING "Your clang version may not use Address-Sanitizer")
endif()
set(CMAKE_C_FLAGS "-fsanitize=address -fno-omit-frame-pointer ${CMAKE_C_FLAGS}")
endif()
endif(ENABLE_ASAN)
set(CMAKE_C_FLAGS "-Wno-deprecated-declarations ${CMAKE_C_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-rpath='\$ORIGIN' -Wl,-rpath=${libdir} ${CMAKE_EXE_LINKER_FLAGS}")
message("Build type: ${CMAKE_BUILD_TYPE}")
if (CMAKE_BUILD_TYPE EQUAL "Debug")
set(_DEBUG TRUE)
endif()
set(XMR_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/output)
set(EXECUTABLE_OUTPUT_PATH ${XMR_OUTPUT_PATH})
set(LIBRARY_OUTPUT_PATH ${XMR_OUTPUT_PATH})
configure_file(${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h)
include_directories(${PROJECT_BINARY_DIR})
add_subdirectory(data)
add_subdirectory(po)
add_subdirectory(src)
add_subdirectory(plugins)
if (BUILD_TEST)
add_subdirectory(test)
endif(BUILD_TEST)