-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
82 lines (69 loc) · 2.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
cmake_minimum_required(VERSION 3.5.1)
project(cmake_clang_tools)
# Installation paths
set(PYTHON_SCRIPTS_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin)
set(CONFIG_FILES_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake_clang_tools)
set(CMAKE_SCRIPTS_INSTALL_PATH ${CONFIG_FILES_INSTALL_PATH})
# Register the local build in case one doesn't use "make install"
export(PACKAGE cmake_clang_tools)
# ... for the build tree
set(PYTHON_SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bin")
set(CONFIG_FILE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/config")
configure_file(cmake/cmake_clang_tools-macros.cmake.in
"${PROJECT_BINARY_DIR}/cmake_clang_tools-macros.cmake" @ONLY)
set(CMAKE_CLANG_TOOLS_MACROS_PATH ${PROJECT_BINARY_DIR})
configure_file(cmake/cmake_clang_toolsConfig.cmake.in
"${PROJECT_BINARY_DIR}/cmake_clang_toolsConfig.cmake" @ONLY)
# ... for the install tree
set(PYTHON_SCRIPTS_DIR "${PYTHON_SCRIPTS_INSTALL_PATH}")
set(CONFIG_FILE_DIR "${CONFIG_FILES_INSTALL_PATH}")
configure_file(cmake/cmake_clang_tools-macros.cmake.in
"${PROJECT_BINARY_DIR}/cmake_clang_tools-macros.cmake" @ONLY)
set(CMAKE_CLANG_TOOLS_MACROS_PATH ${CMAKE_SCRIPTS_INSTALL_PATH})
configure_file(cmake/cmake_clang_toolsConfig.cmake.in
"${PROJECT_BINARY_DIR}/cmake_clang_toolsConfig.cmake" @ONLY)
# Install scripts, configurations and CMake files.
install(
FILES
bin/check_if_tool_runs.py
bin/cmake_clang_tools_helpers.py
bin/run_clang_format_tool.py
bin/run_clang_tidy_tool.py
DESTINATION ${PYTHON_SCRIPTS_INSTALL_PATH}
PERMISSIONS WORLD_EXECUTE WORLD_READ GROUP_EXECUTE GROUP_READ OWNER_EXECUTE OWNER_WRITE OWNER_READ
)
install(
FILES
config/.clang-format
config/.clang-tidy
config/config.yaml
DESTINATION ${CONFIG_FILES_INSTALL_PATH}
PERMISSIONS WORLD_READ GROUP_READ OWNER_WRITE OWNER_READ
)
install(
FILES
"${PROJECT_BINARY_DIR}/cmake_clang_toolsConfig.cmake"
"${PROJECT_BINARY_DIR}/cmake_clang_tools-macros.cmake"
DESTINATION ${CMAKE_SCRIPTS_INSTALL_PATH}
)
install(
FILES package.xml
DESTINATION ${CONFIG_FILES_INSTALL_PATH}
)
# Uninstall
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
)
find_program(PYTEST pytest-3)
if (PYTEST)
# Testing
# Attach the target to ALL to always run the tests.
# This is not a catkin package and there is no way to run them otherwise.
add_custom_target(test_${PROJECT_NAME} ALL
COMMAND pytest-3 ${CMAKE_SOURCE_DIR}/test
)
endif()