You can probably do this using install(SCRIPT ...)
and provide a wee CMake script to be invoked.
So add this to your CMakeLists.txt:
install(SCRIPT InstallScript.cmake)
Then in the InstallScript.cmake:
if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/")
execute_process(COMMAND update-rc.d solshare_stats_runscript defaults
RESULT_VARIABLE Result
OUTPUT_VARIABLE Output
ERROR_VARIABLE Error)
if(Result EQUAL 0)
message(STATUS "Ran update-rc.d as CMAKE_INSTALL_PREFIX == \"/\"")
else()
message(FATAL_ERROR "Result - ${Result}\nOutput - ${Output}\nError - Error")
endif()
else()
message(STATUS "Not running update-rc.d as CMAKE_INSTALL_PREFIX != \"/\"")
endif()
You may need to provide more arguments to the execute_process
call in the script (e.g. WORKING_DIRECTORY
).