Commit 7cf3437a authored by Max Lyon's avatar Max Lyon
Browse files

add methods for OpenFlipper

parent fe97472b
Pipeline #16059 failed with stage
in 3 seconds
......@@ -186,6 +186,21 @@ macro (acg_append_files ret ext)
endforeach ()
endmacro ()
# append all files with extension "ext" in the "dirs" directories and its subdirectories to "ret"
# excludes all files starting with a '.' (dot)
macro (acg_append_files_recursive ret ext)
foreach (_dir ${ARGN})
file (GLOB_RECURSE _files "${_dir}/${ext}")
foreach (_file ${_files})
get_filename_component (_filename ${_file} NAME)
if (_filename MATCHES "^[.]")
list (REMOVE_ITEM _files ${_file})
endif ()
endforeach ()
list (APPEND ${ret} ${_files})
endforeach ()
endmacro ()
# get all files in directory, but ignore svn
macro (acg_get_files_in_dir ret dir)
file (GLOB_RECURSE __files RELATIVE "${dir}" "${dir}/*")
......@@ -217,6 +232,18 @@ function (acg_copy_after_build target src dst)
endforeach ()
endfunction ()
# install the whole directory without svn files
function (acg_install_dir src dst)
acg_unset (_files)
acg_get_files_in_dir (_files ${src})
foreach (_file ${_files})
get_filename_component (_file_PATH ${_file} PATH)
install(FILES "${src}/${_file}"
DESTINATION "${dst}/${_file_PATH}"
)
endforeach ()
endfunction ()
# extended version of add_executable that also copies output to out Build directory
function (acg_add_executable _target)
add_executable (${_target} ${ARGN})
......
......@@ -43,81 +43,137 @@ IF (DOXYGEN_FOUND)
MESSAGE(STATUS "dvips command DVIPS_CONVERTER not found but usually required.")
ENDIF (NOT DVIPS_CONVERTER)
IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in")
MESSAGE(STATUS "configured ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in --> ${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in
${CMAKE_CURRENT_BINARY_DIR}/doxy.config
@ONLY )
# use (configured) doxy.config from (out of place) BUILD tree:
SET(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
ELSE (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in")
# use static hand-edited doxy.config from SOURCE tree:
SET(DOXY_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
MESSAGE(STATUS "WARNING: using existing ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config instead of configuring from doxy.config.in file.")
ELSE (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
IF (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
# using template doxy.config.in
MESSAGE(STATUS "configured ${CMAKE_CMAKE_MODULE_PATH}/doxy.config.in --> ${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
CONFIGURE_FILE(${CMAKE_MODULE_PATH}/doxy.config.in
${CMAKE_CURRENT_BINARY_DIR}/doxy.config
@ONLY )
SET(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
ELSE (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
# failed completely...
MESSAGE(SEND_ERROR "Please create ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in (or doxy.config as fallback)")
ENDIF(EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
ENDIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
ENDIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in")
ADD_CUSTOM_TARGET(doc ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG})
# create a windows help .chm file using hhc.exe
# HTMLHelp DLL must be in path!
# fallback: use hhw.exe interactively
IF (WIN32)
FIND_PACKAGE(HTMLHelp)
IF (HTML_HELP_COMPILER)
SET (TMP "${CMAKE_CURRENT_BINARY_DIR}\\Doc\\html\\index.hhp")
STRING(REGEX REPLACE "[/]" "\\\\" HHP_FILE ${TMP} )
# MESSAGE(SEND_ERROR "DBG HHP_FILE=${HHP_FILE}")
ADD_CUSTOM_TARGET(winhelp ${HTML_HELP_COMPILER} ${HHP_FILE})
ADD_DEPENDENCIES (winhelp doc)
IF (NOT TARGET_DOC_SKIP_INSTALL)
# install windows help?
# determine useful name for output file
# should be project and version unique to allow installing
# multiple projects into one global directory
IF (EXISTS "${PROJECT_BINARY_DIR}/Doc/html/index.chm")
IF (PROJECT_NAME)
SET(OUT "${PROJECT_NAME}")
ELSE (PROJECT_NAME)
SET(OUT "Documentation") # default
ENDIF(PROJECT_NAME)
IF (${PROJECT_NAME}_VERSION_MAJOR)
SET(OUT "${OUT}-${${PROJECT_NAME}_VERSION_MAJOR}")
IF (${PROJECT_NAME}_VERSION_MINOR)
SET(OUT "${OUT}.${${PROJECT_NAME}_VERSION_MINOR}")
IF (${PROJECT_NAME}_VERSION_PATCH)
SET(OUT "${OUT}.${${PROJECT_NAME}_VERSION_PATCH}")
ENDIF(${PROJECT_NAME}_VERSION_PATCH)
ENDIF(${PROJECT_NAME}_VERSION_MINOR)
ENDIF(${PROJECT_NAME}_VERSION_MAJOR)
# keep suffix
SET(OUT "${OUT}.chm")
#MESSAGE("DBG ${PROJECT_BINARY_DIR}/Doc/html/index.chm \n${OUT}")
# create target used by install and package commands
INSTALL(FILES "${PROJECT_BINARY_DIR}/Doc/html/index.chm"
DESTINATION "doc"
RENAME "${OUT}"
)
ENDIF(EXISTS "${PROJECT_BINARY_DIR}/Doc/html/index.chm")
ENDIF(NOT TARGET_DOC_SKIP_INSTALL)
ENDIF(HTML_HELP_COMPILER)
# MESSAGE(SEND_ERROR "HTML_HELP_COMPILER=${HTML_HELP_COMPILER}")
ENDIF (WIN32)
# This macro generates a new doc target. acg_create_doc_target( targetName [directory with the doxy.config.in] [dependency])
# if no parameter is used except the target, a target of the given name will be created from the current source directories doxyfile and added as a dependency to the doc target
# The first additional parameter is used to specify a directory where the doxyfile will be used
# The second parameter defines a target, that will depend on the newly generated one. (Default is doc)
macro (acg_create_doc_target target)
set( DOC_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
set( DOC_DEPENDENCY "doc")
# collect arguments
if ( ${ARGC} EQUAL 2)
set( DOC_DIRECTORY "${ARGV1}" )
elseif ( ${ARGC} EQUAL 3)
set( DOC_DIRECTORY "${ARGV1}" )
set( DOC_DEPENDENCY "${ARGV2}" )
elseif( $ARGC GREATER 3 )
set( DOC_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
# failed as we do not know how to handle the parameters
MESSAGE(SEND_ERROR "Unknown parameter for acg_create_doc_target!")
endif()
if("${DOC_DEPENDENCY}" STREQUAL "doc")
#generate the global doc target (but only once!)
if ( NOT TARGET doc )
ADD_CUSTOM_TARGET( doc )
SET_TARGET_PROPERTIES( doc PROPERTIES EchoString "Building Documentation" )
GROUP_PROJECT(doc Documentation)
endif()
endif()
# If there exists an doxy.config.in, we configure it.
IF (EXISTS "${DOC_DIRECTORY}/doxy.config.in")
#MESSAGE(STATUS "configured ${DOC_DIRECTORY}/doxy.config.in --> ${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
CONFIGURE_FILE(${DOC_DIRECTORY}/doxy.config.in
${CMAKE_CURRENT_BINARY_DIR}/doxy.config
@ONLY )
# use (configured) doxy.config from (out of place) BUILD tree:
SET(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
ELSE (EXISTS "${DOC_DIRECTORY}/doxy.config.in")
# use static hand-edited doxy.config from SOURCE tree:
SET(DOXY_CONFIG "${DOC_DIRECTORY}/doxy.config")
IF (EXISTS "${DOC_DIRECTORY}/doxy.config")
MESSAGE(STATUS "WARNING: using existing ${DOC_DIRECTORY}/doxy.config instead of configuring from doxy.config.in file.")
ELSE (EXISTS "${DOC_DIRECTORY}/doxy.config")
IF (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
# using template doxy.config.in
#MESSAGE(STATUS "configured ${CMAKE_CMAKE_MODULE_PATH}/doxy.config.in --> ${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
CONFIGURE_FILE(${CMAKE_MODULE_PATH}/doxy.config.in
${CMAKE_CURRENT_BINARY_DIR}/doxy.config
@ONLY )
SET(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
ELSE (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
# failed completely...
MESSAGE(SEND_ERROR "Please create ${DOC_DIRECTORY}/doxy.config.in (or doxy.config as fallback)")
ENDIF(EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
ENDIF(EXISTS "${DOC_DIRECTORY}/doxy.config")
ENDIF(EXISTS "${DOC_DIRECTORY}/doxy.config.in")
ADD_CUSTOM_TARGET(${target} ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG})
# Group by folders on MSVC
GROUP_PROJECT( ${target} "Documentation")
add_dependencies( ${DOC_DEPENDENCY} ${target} )
# # Add winhelp target only once!
# GET_TARGET_PROPERTY(target_location winhelp EchoString)
# if ( NOT target_location STREQUAL "Building Windows Documentation" )
# ADD_CUSTOM_TARGET( winhelp )
# SET_TARGET_PROPERTIES( winhelp PROPERTIES EchoString "Building Windows Documentation" )
# endif()
# create a windows help .chm file using hhc.exe
# HTMLHelp DLL must be in path!
# fallback: use hhw.exe interactively
# IF (WIN32)
# FIND_PACKAGE(HTMLHelp)
# IF (HTML_HELP_COMPILER)
# SET (TMP "${CMAKE_CURRENT_BINARY_DIR}\\Doc\\html\\index.hhp")
# STRING(REGEX REPLACE "[/]" "\\\\" HHP_FILE ${TMP} )
# # MESSAGE(SEND_ERROR "DBG HHP_FILE=${HHP_FILE}")
# ADD_CUSTOM_TARGET(winhelp-${target} ${HTML_HELP_COMPILER} ${HHP_FILE})
# ADD_DEPENDENCIES (winhelp-${target} ${target})
#
# add_dependencies(winhelp winhelp-${target})
#
#
# IF (NOT TARGET_DOC_SKIP_INSTALL)
# # install windows help?
# # determine useful name for output file
# # should be project and version unique to allow installing
# # multiple projects into one global directory
# IF (EXISTS "${PROJECT_BINARY_DIR}/Doc/html/index.chm")
# IF (PROJECT_NAME)
# SET(OUT "${PROJECT_NAME}")
# ELSE (PROJECT_NAME)
# SET(OUT "Documentation") # default
# ENDIF(PROJECT_NAME)
# IF (${PROJECT_NAME}_VERSION_MAJOR)
# SET(OUT "${OUT}-${${PROJECT_NAME}_VERSION_MAJOR}")
# IF (${PROJECT_NAME}_VERSION_MINOR)
# SET(OUT "${OUT}.${${PROJECT_NAME}_VERSION_MINOR}")
# IF (${PROJECT_NAME}_VERSION_PATCH)
# SET(OUT "${OUT}.${${PROJECT_NAME}_VERSION_PATCH}")
# ENDIF(${PROJECT_NAME}_VERSION_PATCH)
# ENDIF(${PROJECT_NAME}_VERSION_MINOR)
# ENDIF(${PROJECT_NAME}_VERSION_MAJOR)
# # keep suffix
# SET(OUT "${OUT}.chm")
#
# #MESSAGE("DBG ${PROJECT_BINARY_DIR}/Doc/html/index.chm \n${OUT}")
# # create target used by install and package commands
# INSTALL(FILES "${PROJECT_BINARY_DIR}/Doc/html/index.chm"
# DESTINATION "doc"
# RENAME "${OUT}"
# )
# ENDIF(EXISTS "${PROJECT_BINARY_DIR}/Doc/html/index.chm")
# ENDIF(NOT TARGET_DOC_SKIP_INSTALL)
#
# ENDIF(HTML_HELP_COMPILER)
# # MESSAGE(SEND_ERROR "HTML_HELP_COMPILER=${HTML_HELP_COMPILER}")
# ENDIF (WIN32)
endmacro ()
ENDIF(DOXYGEN_FOUND)
......@@ -103,3 +103,63 @@ macro (acg_qt5)
endif (QT5_FOUND)
endmacro ()
#generates qt translations
function (acg_add_translations _target _languages _sources)
string (TOUPPER ${_target} _TARGET)
# generate/use translation files
# run with UPDATE_TRANSLATIONS set to on to build qm files
option (UPDATE_TRANSLATIONS_${_TARGET} "Update source translation *.ts files (WARNING: make clean will delete the source .ts files! Danger!)")
set (_new_ts_files)
set (_ts_files)
foreach (lang ${_languages})
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/translations/${_target}_${lang}.ts" OR UPDATE_TRANSLATIONS_${_TARGET})
list (APPEND _new_ts_files "translations/${_target}_${lang}.ts")
else ()
list (APPEND _ts_files "translations/${_target}_${lang}.ts")
endif ()
endforeach ()
set (_qm_files)
if ( _new_ts_files )
if (QT5_FOUND)
#qt5_create_translation(_qm_files ${_sources} ${_new_ts_files})
endif ()
endif ()
if ( _ts_files )
if (QT5_FOUND)
#qt5_add_translation(_qm_files2 ${_ts_files})
endif()
list (APPEND _qm_files ${_qm_files2})
endif ()
# create a target for the translation files ( and object files )
# Use this target, to update only the translations
add_custom_target (tr_${_target} DEPENDS ${_qm_files})
GROUP_PROJECT( tr_${_target} "Translations")
# Build translations with the application
add_dependencies(${_target} tr_${_target} )
if (NOT EXISTS ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Translations)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Translations )
endif ()
foreach (_qm ${_qm_files})
get_filename_component (_qm_name "${_qm}" NAME)
add_custom_command (TARGET tr_${_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy_if_different
${_qm}
${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Translations/${_qm_name})
endforeach ()
if (NOT ACG_PROJECT_MACOS_BUNDLE OR NOT APPLE)
install (FILES ${_qm_files} DESTINATION "${ACG_PROJECT_DATADIR}/Translations")
endif ()
endfunction ()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment