Skip to content

Commit 11759a7

Browse files
authored
Merge pull request #135 from socram8888/subdir-build
Allow building in another directory
2 parents e4f8acd + 5179e4c commit 11759a7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ if(NOT CMAKE_BUILD_TYPE)
2121
message(STATUS "Setting build type to '${CMAKE_BUILD_TYPE}' as none was specified.")
2222
endif()
2323

24+
if (NOT CMAKE_INSTALL_BINDIR)
25+
set(CMAKE_INSTALL_BINDIR bin)
26+
endif()
27+
2428
set(CMAKE_C_FLAGS "-Wall -Wextra --pedantic -Wno-strict-aliasing -Wno-variadic-macros")
2529
set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG")
2630
set(CMAKE_C_FLAGS_RELEASE "-O2")
@@ -98,7 +102,7 @@ endif()
98102

99103
# INSTALL
100104

101-
install(TARGETS ${TARGET_NAME} DESTINATION bin)
105+
install(TARGETS ${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
102106

103107
set(SERVICE_EXTRA_OPTIONS "")
104108
if(IS_DIRECTORY "/etc/munin/plugins" AND
@@ -114,7 +118,7 @@ endif()
114118

115119
configure_file(${TARGET_NAME}.service.in ${TARGET_NAME}.service)
116120

117-
install(FILES ${TARGET_NAME}.service
121+
install(FILES ${CMAKE_BINARY_DIR}/${TARGET_NAME}.service
118122
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/system/)
119123

120124
# TESTING

0 commit comments

Comments
 (0)