Cmake build: Allow user defined suffix for program files

This commit is contained in:
Kornel Benko 2016-06-05 16:26:59 +02:00
parent c2433d8b8f
commit 7c0eba4d75
2 changed files with 31 additions and 2 deletions

View File

@ -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 *, *\\[\\\"(.*)\\\"\\].*")

View File

@ -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)