-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
executable file
·116 lines (99 loc) · 3.57 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(proxyme)
# get the git tag and hash
find_package(Git)
if(GIT_FOUND)
exec_program(
${GIT_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}
ARGS "rev-parse --is-inside-work-tree"
OUTPUT_VARIABLE GITWORKTREE )
if( "${GITWORKTREE}" STREQUAL "true" )
exec_program(
${GIT_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}
ARGS "name-rev --tags --name-only $(git rev-parse HEAD)"
OUTPUT_VARIABLE GITTAG )
exec_program(
${GIT_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}
ARGS "rev-parse --short HEAD"
OUTPUT_VARIABLE GITHASH )
exec_program(
${GIT_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}
ARGS "diff-index --name-only HEAD"
OUTPUT_VARIABLE GITDIRTY
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(GITDIRTY)
set (proxyme_VERSION "${GITTAG} (${GITHASH}-dirty)")
else()
set (proxyme_VERSION "${GITTAG} (${GITHASH})")
endif()
else()
set (proxyme_VERSION "undefined (no git tree)")
endif()
else()
set (proxyme_VERSION "undefined (git not found)")
endif()
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
)
include_directories("${PROJECT_BINARY_DIR}")
FIND_PACKAGE(Boost COMPONENTS system filesystem program_options regex)
###################################################################################
# - Try to find ctemplate
# Once done this will define
# LIBCTEMPLATE_FOUND - System has ctemplate
# LIBCTEMPLATE_INCLUDE_DIRS - The ctemplate include directories
# LIBCTEMPLATE_LIBRARIES - The libraries needed to use ctemplate
# LIBCTEMPLATE_DEFINITIONS - Compiler switches required for using ctemplate
find_package(PkgConfig)
pkg_check_modules(PC_LIBCTEMPLATE QUIET libctemplate)
set(LIBCTEMPLATE_DEFINITIONS ${PC_LIBCTEMPLATE_CFLAGS_OTHER})
find_path(LIBCTEMPLATE_INCLUDE_DIR ctemplate/template.h
HINTS ${PC_LIBCTEMPLATE_INCLUDEDIR} ${PC_LIBCTEMPLATE_INCLUDE_DIRS}
PATH_SUFFIXES ctemplate )
find_library(LIBCTEMPLATE_LIBRARY NAMES ctemplate
HINTS ${PC_LIBCTEMPLATE_LIBDIR} ${PC_LIBCTEMPLATE_LIBRARY_DIRS} )
set(LIBCTEMPLATE_LIBRARIES ${LIBCTEMPLATE_LIBRARY} )
set(LIBCTEMPLATE_INCLUDE_DIRS ${LIBCTEMPLATE_INCLUDE_DIR} )
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(LibCtemplate DEFAULT_MSG
LIBCTEMPLATE_LIBRARY LIBCTEMPLATE_INCLUDE_DIR)
mark_as_advanced(LIBCTEMPLATE_INCLUDE_DIR LIBCTEMPLATE_LIBRARY )
###################################################################################
find_program(CTEMPLATE_MAKE_TPL_VARNAMES_H ctemplate-make_tpl_varnames_h
$ENV{HOME}/bin
/usr/local/bin
/usr/bin
NO_DEFAULT_PATH
)
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/proxyme.tpl.varnames.h
COMMAND ${CTEMPLATE_MAKE_TPL_VARNAMES_H} ${PROJECT_SOURCE_DIR}/templates/proxyme.tpl
COMMENT "Building header file with ctemplate definitions"
)
ADD_EXECUTABLE(proxyme src/main.cpp proxyme.tpl.varnames.h config.h)
target_link_libraries(
proxyme
${Boost_LIBRARIES}
${LIBCTEMPLATE_LIBRARIES}
)
set(proxyme_templates
templates/proxyme.ini
templates/apm.tpl
templates/apt.tpl
templates/curl.tpl
templates/git.tpl
templates/maven.tpl
templates/npm.tpl
templates/subversion.tpl
templates/wget.tpl
)
install (TARGETS proxyme DESTINATION bin)
install (FILES ${proxyme_templates} DESTINATION share/proxyme)