-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
64 lines (59 loc) · 2.52 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
cmake_minimum_required(VERSION 3.10)
project("catlock"
LANGUAGES CXX
VERSION 1.0.1
DESCRIPTION "Lock keyboard and pointer"
)
include(GNUInstallDirs)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build type" FORCE)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 6)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wduplicated-branches -Wrestrict")
endif()
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 5)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wduplicated-cond -Wnull-dereference")
endif()
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 4.7)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuseless-cast")
endif()
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 4.2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast -Wshadow")
endif()
add_definitions(-DVERSION=\"${PROJECT_VERSION}\")
find_package(XCB COMPONENTS KEYSYMS IMAGE DPMS REQUIRED)
find_package(X11 REQUIRED)
find_package(POPT REQUIRED)
find_package(XmlTo REQUIRED)
add_executable(catlock catlock.cpp)
target_link_libraries(catlock ${XCB_LIBRARIES} ${X11_LIBRARIES} ${POPT_LIBRARIES})
install(TARGETS catlock RUNTIME DESTINATION ${BINDIR} ${CMAKE_INSTALL_BINDIR})
install(FILES catlock.desktop DESTINATION "${CMAKE_INSTALL_DATADIR}/applications")
install(FILES catlock.png DESTINATION "${CMAKE_INSTALL_DATADIR}/pixmaps")
configure_file(catlock.xml.in catlock.xml @ONLY)
XMLTO(catlock.xml MODES man ALL)
foreach(file ${XMLTO_FILES_man})
get_filename_component(fileExt ${file} EXT)
string( REGEX REPLACE "^[.]" "" fileExt ${fileExt} )
install(
FILES ${file}.gz
DESTINATION ${CMAKE_INSTALL_MANDIR}/man${fileExt}
)
endforeach()
# Add ghrelease target
add_custom_target(ghrelease
COMMAND tar czf "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}.tar.gz"
--exclude=.git --exclude=build --owner root --group root --transform
"s/^\\./${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}/" .
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Creating source tarball"
COMMAND sh .github/release "${CMAKE_PROJECT_NAME}" "${CMAKE_PROJECT_VERSION}"
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}.tar.gz"
VERBATIM
)