From 7c0eba4d75cf37a587d5df9dd696dc56a7732464 Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Sun, 5 Jun 2016 16:26:59 +0200 Subject: [PATCH] Cmake build: Allow user defined suffix for program files --- CMakeLists.txt | 7 +++++- development/cmake/modules/LyXMacros.cmake | 26 ++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68753c197a..72bbf35325 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,6 +129,7 @@ LYX_OPTION(RELEASE "Build release version, build debug when disabled" O LYX_OPTION(DEBUG "Enforce debug build" OFF ALL) LYX_OPTION(NO_OPTIMIZE "Don't use any optimization/debug flags" OFF ALL) LYX_OPTION(PACKAGE_SUFFIX "Use version suffix for packaging" ON ALL) +LYX_STRING(SUFFIX_VALUE "Use this string as suffix" "") LYX_OPTION(PCH "Use precompiled headers" OFF ALL) LYX_OPTION(MERGE_FILES "Merge source files into one compilation unit" OFF ALL) LYX_OPTION(MERGE_REBUILD "Rebuild generated files from merged files build" OFF ALL) @@ -345,7 +346,11 @@ foreach(_c_l ${_config_lines} ) set(LYX_PATCH_VERSION ${CMAKE_MATCH_4}) set(LYX_DIR_VER "LYX_DIR_${CMAKE_MATCH_1}${CMAKE_MATCH_2}x") set(LYX_USERDIR_VER "LYX_USERDIR_${CMAKE_MATCH_1}${CMAKE_MATCH_2}x") - set(LYX_INSTALL_SUFFIX "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}") + if ("${LYX_SUFFIX_VALUE}" MATCHES "") + set(LYX_INSTALL_SUFFIX "${LYX_MAJOR_VERSION}.${LYX_MINOR_VERSION}") + else() + set(LYX_INSTALL_SUFFIX "${LYX_SUFFIX_VALUE}") + endif() endif() endif() if(_c_l MATCHES "^AC_SUBST\\( *LYX_DATE *, *\\[\\\"(.*)\\\"\\].*") diff --git a/development/cmake/modules/LyXMacros.cmake b/development/cmake/modules/LyXMacros.cmake index 2e2f7d8930..be7470c93f 100644 --- a/development/cmake/modules/LyXMacros.cmake +++ b/development/cmake/modules/LyXMacros.cmake @@ -209,6 +209,7 @@ endmacro(lyx_const_touched_files) macro(LYX_OPTION_INIT) set(LYX_OPTIONS) + set(LYX_OPTION_STRINGS) endmacro() @@ -244,6 +245,7 @@ macro(LYX_COMBO _name _description _default) set(${_lyx_name}_show_message ON) string(REGEX REPLACE ";" " " _use_list "${_combo_list}") set(${_lyx_name}_description "${_description} (${_use_list})") + list(APPEND LYX_OPTION_STRINGS ${_lyx_name}) # Now check the value list(FIND _combo_list ${${_lyx_name}} _idx) if (_idx LESS 0) @@ -251,6 +253,26 @@ macro(LYX_COMBO _name _description _default) endif() endmacro() +macro(LYX_STRING _name _description _default) + set(_lyx_name "LYX_${_name}") + list(APPEND LYX_OPTIONS ${_lyx_name}) + set(${_lyx_name}_show_message ON) + set(${_lyx_name}_description "${_description}") + list(APPEND LYX_OPTION_STRINGS ${_lyx_name}) + # Now check the value + # Should not contain ' ' + set(tmp_lyx_name ${${_lyx_name}}) + if (NOT "${${_lyx_name}}" STREQUAL "") + if (NOT "${tmp_lyx_name}" MATCHES "^\\..*$") + set(tmp_lyx_name ".${tmp_lyx_name}") + endif() + if (NOT "${tmp_lyx_name}" MATCHES "^\\.[a-zA-Z_\\.]+$") + message(FATAL_ERROR "Invalid string for lyx suffix (${tmp_lyx_name})") + endif() + endif() + set(${_lyx_name} "${tmp_lyx_name}" CACHE STRING "${_description}" FORCE) +endmacro() + macro(LYX_OPTION_LIST_ALL) if(UNIX) set(run_cmake ${CMAKE_BINARY_DIR}/run_cmake.sh) @@ -268,7 +290,9 @@ macro(LYX_OPTION_LIST_ALL) if(${_option}_show_message OR ${ARGV0} STREQUAL "help") string(SUBSTRING "${_option} " 0 25 _var) get_property(_prop CACHE ${_option} PROPERTY STRINGS) - if(_prop) + list(FIND LYX_OPTION_STRINGS ${_option} _index) + if (${_index} GREATER -1) + #message(STATUS "${_option} is of type string") set(_isset ${${_option}}) elseif(${_option}) set(_isset ON)