-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
132 lines (102 loc) · 4.3 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
128
129
130
131
cmake_minimum_required( VERSION 2.6 )
project(work-break)
if (NOT CMAKE_BUILD_TYPE)
set ( CMAKE_BUILD_TYPE Release )
endif (NOT CMAKE_BUILD_TYPE)
if (NOT CMAKE_INSTALL_PREFIX)
message(FATAL_ERROR "CMAKE_INSTALL_PREFIX is not set but it has to be. Something is wrong.")
endif ()
set(MAJOR_VERSION 1)
set(MINOR_VERSION 0)
set(PATCH_VERSION 1)
set(APP_VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION})
add_definitions(-DAPP_NAME=\"${PROJECT_NAME}\"
-DAPP_VERSION=\"${APP_VERSION}\")
add_definitions ( -Wall )
find_package ( Qt4 4.6.0 REQUIRED)
include ( ${QT_USE_FILE} )
if (QT_QTDBUS_FOUND)
add_definitions(-DHAVE_QTDBUS)
endif (QT_QTDBUS_FOUND)
include_directories (
${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
)
set(SRC
src/main.cpp
src/workbreak.cpp
)
if (APPLE)
SET (SRC ${SRC} macosx/${PROJECT_NAME}.icns)
endif (APPLE)
set(MOCS
src/workbreak.h
)
set(ICONS
src/icons/green.png
src/icons/red.png
src/icons/yellow.png
)
set(DOCS
docs/index_en.html.in
)
if (QT_QTDBUS_FOUND)
qt4_add_dbus_interface(SRC src/dbus/org.freedesktop.Notifications.xml notifications_interface)
endif (QT_QTDBUS_FOUND)
qt4_wrap_cpp(MOCS_SRC ${MOCS})
add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE
${SRC} ${MOCS_SRC})
target_link_libraries(${PROJECT_NAME} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
if (QT_QTDBUS_FOUND)
target_link_libraries(${PROJECT_NAME} ${QT_QTDBUS_LIBRARY})
endif (QT_QTDBUS_FOUND)
# generate documantation form *.in sources
foreach (i ${DOCS})
get_filename_component(htmlfile ${i} NAME_WE)
message(STATUS " generating docs for: ${i} -> ${htmlfile}.html")
configure_file(${i} ${CMAKE_CURRENT_BINARY_DIR}/${htmlfile}.html)
set (DOCS_HTML ${DOCS_HTML} ${CMAKE_CURRENT_BINARY_DIR}/${htmlfile}.html)
endforeach()
# platform specific
if (APPLE)
# mac's bundle install
SET_TARGET_PROPERTIES(${CMAKE_PROJECT_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/macosx/Info.plist.in")
SET(MACOSX_BUNDLE_ICON_FILE ${PROJECT_NAME}.icns)
SET(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME} ${QSHARE_VERSION}")
SET(MACOSX_BUNDLE_GUI_IDENTIFIER "cz.yarpen.${PROJECT_NAME}")
SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${APP_VERSION}")
SET(MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}")
SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "${APP_VERSION}")
SET(MACOSX_BUNDLE_BUNDLE_VERSION "${APP_VERSION}")
SET(MACOSX_BUNDLE_COPYRIGHT "(c) Petr Vanek; [email protected]")
SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/macosx/${PROJECT_NAME}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
INSTALL(TARGETS ${PROJECT_NAME} BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX})
INSTALL(FILES ${ICONS} DESTINATION ${PROJECT_NAME}.app/Contents/Resources/icons)
INSTALL(FILES ${DOCS_HTML} DESTINATION ${PROJECT_NAME}.app/Contents/Resources)
set(FILE_PREFIX "/../Resources/")
# create a "transportable" bundle - all libs into the bundle: "make bundle" after make install
configure_file(macosx/bundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/bundle.cmake @ONLY)
add_custom_target(bundle ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/bundle.cmake)
elseif (WIN32)
message(FATAL_ERROR "Building for windows is not implemented yet")
elseif (UNIX)
set(FILE_PREFIX ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/)
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
install(FILES ${ICONS} DESTINATION share/${PROJECT_NAME}/icons/)
install(FILES ${PROJECT_NAME}.desktop DESTINATION share/applications/)
install(FILES ${PROJECT_NAME}.png DESTINATION share/pixmaps/)
install(FILES ${DOCS_HTML} DESTINATION share/${PROJECT_NAME}/)
else ()
message(FATAL_ERROR "Unknown platform to build")
endif ()
message(STATUS "File prefix: ${FILE_PREFIX}")
add_definitions(-DFILE_PREFIX=\"${FILE_PREFIX}\")
########## Add make dist target ################
SET(CPACK_PACKAGE_VERSION "${APP_VERSION}")
SET(CPACK_SOURCE_GENERATOR "TBZ2")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
SET(CPACK_IGNORE_FILES "/CVS/;/\\\\.git\;/\\\\.svn/;\\\\.swp$;\\\\.#;/#;\\\\.tar.gz$;/CMakeFiles/;CMakeCache.txt;refresh-copyright-and-license.pl")
SET(CPACK_SOURCE_IGNORE_FILES ${CPACK_IGNORE_FILES})
INCLUDE(CPack)
# simulate autotools' "make dist"
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)