Cmake build: Prepare for hardening use of external programs

This commit is contained in:
Kornel Benko 2016-11-22 16:51:44 +01:00
parent 7950d109c8
commit ff0c95aba6
2 changed files with 25 additions and 0 deletions

View File

@ -135,3 +135,15 @@ elseif(UNIX)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lyx${PROGRAM_SUFFIX}.desktop DESTINATION ${SYSTEM_DATADIR}/applications)
install(FILES ${TOP_SRC_DIR}/lib/images/lyx.svg RENAME lyx${PROGRAM_SUFFIX}.svg DESTINATION ${SYSTEM_DATADIR}/icons/hicolor/scalable/apps/)
endif()
if(USE_POSIX_PACKAGING AND EXISTS "${TOP_SRC_DIR}/lib/usr.bin.lyxwrap.in")
# handle lyxwrap
#get_filename_component(prefix "${CMAKE_INSTALL_PREFIX}" REALPATH)
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(version_suffix ${PROGRAM_SUFFIX})
string(REGEX REPLACE "^/" "" lyxwrapprefix1 "${prefix}")
string(REPLACE "/" "." lyxwrapprefix ${lyxwrapprefix1})
#message(STATUS "lyxwrapprefix = ${lyxwrapprefix}")
configure_file(${TOP_SRC_DIR}/lib/usr.bin.lyxwrap.in "${lyxwrapprefix}.${LYX_UTILITIES_INSTALL_PATH}.lyx${PROGRAM_SUFFIX}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lyxwrapprefix}.${LYX_UTILITIES_INSTALL_PATH}.lyx${PROGRAM_SUFFIX}" DESTINATION /etc/apparmor.d/)
endif()

View File

@ -25,8 +25,10 @@ file(GLOB lyx_sources ${TOP_SRC_DIR}/src/${LYX_CPP_FILES})
file(GLOB moc_files ${TOP_SRC_DIR}/src/${LYX_MOC_FILES})
list(REMOVE_ITEM lyx_sources ${moc_files} .)
file(GLOB lyx_headers ${TOP_SRC_DIR}/src/${LYX_HPP_FILES})
set(lyxwrap_sources ${TOP_SRC_DIR}/src/lyxwrap.cpp)
list(REMOVE_ITEM lyx_sources
${TOP_SRC_DIR}/src/lyxwrap.cpp
${TOP_SRC_DIR}/src/Variables.cpp
${TOP_SRC_DIR}/src/Section.cpp
${TOP_SRC_DIR}/src/lyxcore.cpp
@ -189,4 +191,15 @@ if(LYX_BUNDLE)
endif()
endif()
set(dowrapper ON) # create and install wrapper for external commands
foreach(_f ${lyxwrap_sources})
if(NOT EXISTS "${_f}")
set(dowrapper OFF)
endif()
endforeach()
if(dowrapper AND USE_POSIX_PACKAGING)
add_executable(lyxwrap${PROGRAM_SUFFIX} ${lyxwrap_sources})
install(TARGETS lyxwrap${PROGRAM_SUFFIX} DESTINATION ${LYX_UTILITIES_INSTALL_PATH})
endif()
add_subdirectory(tests)