2014-04-29 14:11:27 +00:00
|
|
|
# preamble
|
|
|
|
project( Lsyncd )
|
2021-11-24 13:28:46 +00:00
|
|
|
cmake_minimum_required( VERSION 3.10 )
|
2022-03-11 06:17:44 +00:00
|
|
|
set( LSYNCD_VERSION 2.3.0-beta1 )
|
2014-04-29 14:11:27 +00:00
|
|
|
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/" )
|
|
|
|
|
|
|
|
|
|
|
|
# finding Lua
|
2016-12-13 13:53:01 +00:00
|
|
|
find_package( Lua REQUIRED )
|
2014-04-29 14:11:27 +00:00
|
|
|
include_directories ( ${LUA_INCLUDE_DIR} )
|
|
|
|
|
|
|
|
|
|
|
|
# setting Lsyncd sources
|
|
|
|
set( LSYNCD_SRC lsyncd.c runner.c defaults.c )
|
|
|
|
|
|
|
|
|
|
|
|
# selecting the file notification mechanisms to compile against
|
|
|
|
option( WITH_INOTIFY "Compile with inotify file notifications (Linux)" ON )
|
|
|
|
option( WITH_FSEVENTS "Compile with inotify file notifications (OSX)" OFF )
|
|
|
|
|
|
|
|
if( WITH_INOTIFY )
|
|
|
|
set( LSYNCD_SRC ${LSYNCD_SRC} inotify.c )
|
|
|
|
endif( WITH_INOTIFY )
|
|
|
|
|
|
|
|
if( WITH_FSEVENTS )
|
|
|
|
set( LSYNCD_SRC ${LSYNCD_SRC} fsevents.c )
|
|
|
|
|
|
|
|
option( XNU_DIR "Path to the xnu sources" )
|
|
|
|
|
|
|
|
# if( NOT XNU_DIR/bsd/sys/fsevents.h )
|
|
|
|
# message( SEND_ERROR "Cannot find bsd/sys/fsevents.h in XNU_DIR" )
|
|
|
|
# endif( )
|
|
|
|
|
|
|
|
include_directories( ${XNU_DIR} )
|
|
|
|
endif( WITH_FSEVENTS )
|
|
|
|
|
2020-09-25 19:36:25 +00:00
|
|
|
if ( APPLE )
|
|
|
|
set( LSYNCD_TARGET_APPLE 1 )
|
|
|
|
endif ( APPLE )
|
2014-04-29 14:11:27 +00:00
|
|
|
|
|
|
|
# generating the config.h file
|
|
|
|
configure_file (
|
|
|
|
"${PROJECT_SOURCE_DIR}/config.h.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/config.h"
|
|
|
|
)
|
|
|
|
include_directories("${PROJECT_BINARY_DIR}")
|
|
|
|
|
|
|
|
|
|
|
|
# building and compiling the part of lsyncd written in Lua
|
|
|
|
# also called "runner"
|
2016-11-25 14:09:27 +00:00
|
|
|
add_custom_command( OUTPUT runner.c
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Generating built-in runner linkable"
|
2014-04-29 14:11:27 +00:00
|
|
|
COMMAND ${LUA_EXECUTABLE} ${PROJECT_SOURCE_DIR}/bin2carray.lua runner.out runner runner.c
|
2016-11-25 14:09:27 +00:00
|
|
|
DEPENDS runner.out
|
|
|
|
)
|
2014-04-29 14:11:27 +00:00
|
|
|
|
|
|
|
# this supposes the Lua compiler 'luac' is sitting right next to the Lua interpreter 'lua'
|
|
|
|
add_custom_command( OUTPUT runner.out
|
2016-11-25 14:09:27 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Compiling built-in runner"
|
2016-11-24 14:44:08 +00:00
|
|
|
COMMAND ${LUA_COMPILER} -o runner.out ${PROJECT_SOURCE_DIR}/lsyncd.lua
|
2016-11-25 14:09:27 +00:00
|
|
|
DEPENDS ${PROJECT_SOURCE_DIR}/lsyncd.lua
|
|
|
|
)
|
2014-04-29 14:11:27 +00:00
|
|
|
|
|
|
|
# building and compiling the built-in default configs:
|
|
|
|
# rsync rysnc-ssh and direct
|
2016-11-25 14:09:27 +00:00
|
|
|
add_custom_command( OUTPUT defaults.c
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Generating built-in default configs"
|
2014-04-29 14:11:27 +00:00
|
|
|
COMMAND ${LUA_EXECUTABLE} ${PROJECT_SOURCE_DIR}/bin2carray.lua defaults.out defaults defaults.c
|
2016-11-25 14:09:27 +00:00
|
|
|
DEPENDS defaults.out
|
|
|
|
)
|
2014-04-29 14:11:27 +00:00
|
|
|
|
|
|
|
set( DEFAULT_CONFIGS
|
|
|
|
${PROJECT_SOURCE_DIR}/default.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/default-rsync.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/default-rsyncssh.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/default-direct.lua
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_command( OUTPUT defaults.out
|
2016-11-25 14:09:27 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Compiling built-in default configs"
|
2016-11-24 14:44:08 +00:00
|
|
|
COMMAND ${LUA_COMPILER} -o defaults.out ${DEFAULT_CONFIGS}
|
2016-11-25 14:09:27 +00:00
|
|
|
DEPENDS ${DEFAULT_CONFIGS}
|
|
|
|
)
|
2014-04-29 14:11:27 +00:00
|
|
|
|
2014-04-29 14:38:25 +00:00
|
|
|
# the manpage
|
2017-01-04 09:59:01 +00:00
|
|
|
add_custom_target( manpage
|
2016-11-25 14:09:27 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Updating the manpage"
|
2022-04-20 17:20:52 +00:00
|
|
|
COMMAND a2x --format=manpage docs/manpage/lsyncd.1.txt
|
|
|
|
DEPENDS docs/manpage/lsyncd.1.txt
|
2014-04-29 14:38:25 +00:00
|
|
|
)
|
2014-04-29 14:11:27 +00:00
|
|
|
|
2022-04-20 17:20:52 +00:00
|
|
|
# the html documention
|
|
|
|
add_custom_target( docs-html
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Generate html documentation"
|
2022-04-20 21:08:29 +00:00
|
|
|
COMMAND env JEKYLL_ENV=local jekyll build -d ${CMAKE_CURRENT_BINARY_DIR}/html
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs
|
2022-04-20 17:20:52 +00:00
|
|
|
DEPENDS ${CMAKE_SOURCE_DIR}/docs
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-12-02 16:01:37 +00:00
|
|
|
# create_symlink( ${CMAKE_SOURCE_DIR}/tests tests)
|
2021-12-08 17:21:16 +00:00
|
|
|
ADD_CUSTOM_TARGET(prepare_tests ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/tests tests
|
|
|
|
)
|
2021-12-02 16:01:37 +00:00
|
|
|
|
2017-01-05 09:37:43 +00:00
|
|
|
add_custom_target( tests
|
|
|
|
COMMAND echo "Running the tests"
|
|
|
|
COMMAND echo "Note you are expected to:"
|
|
|
|
COMMAND echo " * have lua-posix installed"
|
2021-12-02 16:01:37 +00:00
|
|
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/setup.lua
|
2021-12-08 17:21:16 +00:00
|
|
|
COMMAND ${CMAKE_BINARY_DIR}/lsyncd -log all -script ${CMAKE_SOURCE_DIR}/tests/utils_test.lua
|
2021-12-02 16:01:37 +00:00
|
|
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/schedule.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/l4rsyncdata.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/filter-rsync.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/exclude-rsync.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/exclude-rsyncssh.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/churn-rsync.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/churn-rsyncssh.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/churn-direct.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/teardown.lua
|
2017-01-05 09:37:43 +00:00
|
|
|
COMMAND echo "Finished all successfull!"
|
2021-12-08 17:21:16 +00:00
|
|
|
DEPENDS prepare_tests
|
2017-01-05 09:37:43 +00:00
|
|
|
)
|
|
|
|
|
2014-04-29 14:11:27 +00:00
|
|
|
# compiling and linking it all together
|
|
|
|
add_executable( lsyncd ${LSYNCD_SRC} )
|
|
|
|
target_link_libraries( lsyncd ${LUA_LIBRARIES} )
|
2014-04-29 14:38:25 +00:00
|
|
|
|
|
|
|
install( TARGETS lsyncd RUNTIME DESTINATION bin )
|
2022-04-20 17:20:52 +00:00
|
|
|
install( FILES docs/manpage/lsyncd.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT man )
|
2021-12-08 17:48:44 +00:00
|
|
|
install( DIRECTORY examples DESTINATION doc )
|
2022-04-20 17:50:35 +00:00
|
|
|
install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION doc OPTIONAL)
|