#create the implementation files from the ui files and add them
#to the list of sources
-#usage: LYX_ADD_QT4_UI_FILES(foo_SRCS ${ui_files})
-macro(LYX_ADD_UI_FILES _sources _ui)
+#usage: LYX_ADD_UI_FILES(foo_SRCS ${ui_files})
+macro(LYX_ADD_UI_FILES _sources _ui_files)
+ set(uifiles})
foreach (_current_FILE ${ARGN})
-
get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
get_filename_component(_basename ${_tmp_FILE} NAME_WE)
set(_header ${CMAKE_CURRENT_BINARY_DIR}/ui_${_basename}.h)
# Latest test showed on linux and windows show no bad consequeces,
# so we removed the call to LyXuic.cmake
qt_wrap_uifiles(${_header} ${_tmp_FILE} OPTIONS -tr lyx::qt_)
- set(${_ui} ${${_ui}} ${_header})
- endforeach (_current_FILE)
+ list(APPEND uifiles ${_header})
+ endforeach()
+ set(${_ui_files} ${uifiles})
endmacro(LYX_ADD_UI_FILES)
set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
if (WIN32)
- set(_def -D_WIN32)
+ set(_def -D_WIN32)
+ else()
+ set(_def)
endif()
#set(_moc ${_abs_PATH}/${_current_MOC})
add_custom_command(OUTPUT ${_moc}
else()
lyx_add_info_files(MergedFiles ${${_list}})
endif()
-
+
set(${_file_list} ${_file_const} ${_file_touched} ${lyx_${groupname}_info_files})
foreach (_current_FILE ${${_list}})
macro(LYX_OPTION_INIT)
set(LYX_OPTIONS)
+ set(LYX_OPTION_STRINGS)
endmacro()
set(LYX_${_name}_show_message ${_msg})
endmacro()
+macro(LYX_COMBO _name _description _default)
+ set(_lyx_name "LYX_${_name}")
+ set(${_lyx_name} ${_default} CACHE STRING "${_description}")
+ set(_combo_list ${_default} ${ARGN})
+ set_property(CACHE ${_lyx_name} PROPERTY STRINGS ${_combo_list})
+ list(APPEND LYX_OPTIONS ${_lyx_name})
+ 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)
+ message(FATAL_ERROR "${_lyx_name} set to \"${${_lyx_name}}\", but has to be only one of (${_use_list})")
+ 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_0-9\\.]+$")
+ 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)
file(APPEND ${run_cmake} " -G\"${CMAKE_GENERATOR}\" ${cont}")
foreach(_option ${LYX_OPTIONS})
if(${_option}_show_message OR ${ARGV0} STREQUAL "help")
- string(SUBSTRING "${_option} " 0 25 _var)
- if(${_option})
+ get_property(_prop CACHE ${_option} PROPERTY STRINGS)
+ list(FIND LYX_OPTION_STRINGS ${_option} _index)
+ set(_type "BOOL")
+ if (${_index} GREATER -1)
+ #message(STATUS "${_option} is of type string")
+ set(_isset ${${_option}})
+ set(_type "STRING")
+ elseif(${_option})
set(_isset ON)
else()
set(_isset OFF)
endif()
- string(SUBSTRING "${_isset} " 0 4 _val)
- message(STATUS "${_var}= ${_val} : ${${_option}_description}")
- file(APPEND ${run_cmake} " -D${_option}=${${_option}} ${cont}")
+ string(SUBSTRING "${_option}:${_type} " 0 35 _var)
+ string(SUBSTRING "${_isset} " 0 7 _val)
+ message(STATUS "${_var}= ${_val}: ${${_option}_description}")
+ file(APPEND ${run_cmake} " -D${_option}:${_type}=${${_option}} ${cont}")
endif()
endforeach()
file(APPEND ${run_cmake} "\n")
set_tests_properties(${testname} PROPERTIES LABELS "${_lab_list}")
endmacro()
-macro(setmarkedtestlabel testname reverted)
- if(reverted)
- settestlabel(${testname} "reverted" ${ARGN})
+macro(sortlabellist listout)
+ set(tmplist "")
+ foreach(_lab ${ARGN})
+ list(APPEND tmplist "${depth_${_lab}}${_lab}")
+ endforeach()
+ list(SORT tmplist)
+ string(REGEX REPLACE ";[-0-9]+" ";" ${listout} ";${tmplist}")
+endmacro()
+
+macro(createlabel reslabel first)
+ set(${reslabel} ${first})
+ foreach(_lab ${ARGN})
+ set(${reslabel} "${${reslabel}}:${_lab}")
+ endforeach()
+endmacro()
+
+macro(setmarkedtestlabel testname)
+ sortlabellist(mynewlablelist ${ARGN})
+ createlabel(mynewlabel ${mynewlablelist})
+ settestlabel(${testname} ${mynewlabel})
+endmacro()
+
+macro(lyx_target_link_libraries _target)
+ foreach(_lib ${ARGN})
+ string(TOUPPER ${_lib} _ulib)
+ if(${_ulib}_FOUND)
+ #message(STATUS "target_link_libraries(${_target} ${${_lib}_LIBRARY})")
+ target_link_libraries(${_target} ${${_lib}_LIBRARY})
+ endif()
+ endforeach()
+endmacro()
+
+# Check if python module exists
+# Idea stolen from http://public.kitware.com/pipermail/cmake/2011-January/041666.html
+function(find_python_module module)
+ string(TOUPPER ${module} module_upper)
+ if(NOT LYX_PY_${module_upper})
+ if(ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED")
+ set(LYX_PY_${module}_FIND_REQUIRED TRUE)
+ endif()
+ # A module's location is usually a directory, but for binary modules
+ # it's a .so file.
+ execute_process(COMMAND "${LYX_PYTHON_EXECUTABLE}" "-c"
+ "import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))"
+ RESULT_VARIABLE _${module}_status
+ OUTPUT_VARIABLE _${module}_location
+ ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(NOT _${module}_status)
+ set(LYX_PY_${module_upper} ${_${module}_location} CACHE STRING
+ "Location of Python module ${module}")
+ endif()
+ endif()
+ find_package_handle_standard_args(LYX_PY_${module} DEFAULT_MSG LYX_PY_${module_upper})
+endfunction(find_python_module)
+
+macro(setstripped _varname)
+ if(${ARGC} GREATER 1)
+ string(STRIP "${ARGV1}" _v)
+ if (_v MATCHES "^\\[\(.+\)\\]$")
+ set(_v ${CMAKE_MATCH_1})
+ endif()
+ if(USE_POSIX_PACKAGING)
+ string(TOLOWER ${_v} ${_varname})
+ else()
+ set(${_varname} ${_v})
+ endif()
+ else()
+ set(${_varname})
+ endif()
+endmacro(setstripped)
+
+# Determine the version and build-type
+function(determineversionandbuildtype configfile package version dirs date buildtype)
+ file(STRINGS "${configfile}" _config_lines)
+ foreach(_c_l ${_config_lines} )
+ if(_c_l MATCHES "^AC_INIT\\(\([^,]+\),\([^,]+\), *\\[\([^,]+\)\\] *,\(.*\)")
+ # Not using CMAKE_MATCH_ directly is needed, because
+ # its value is now changed inside macro setstripped
+ set(_PB ${CMAKE_MATCH_1})
+ set(_PV ${CMAKE_MATCH_2})
+ set(_PBU ${CMAKE_MATCH_3})
+ setstripped(PACKAGE_BASE ${_PB})
+ setstripped(PACKAGE_VERSION ${_PV})
+ setstripped(PACKAGE_BUGREPORT ${_PBU})
+ set(${package} ${PACKAGE_BASE} ${PACKAGE_VERSION} ${PACKAGE_BUGREPORT} PARENT_SCOPE)
+ if(PACKAGE_VERSION MATCHES "^\([0-9]+\)\\.\([0-9]+\)\(\\.\([0-9]+\)\(\\.\([0-9]+\)\)?\)?-?\([a-z]*[0-9]*\).*$")
+ set(LYX_MAJOR_VERSION ${CMAKE_MATCH_1})
+ set(LYX_MINOR_VERSION ${CMAKE_MATCH_2})
+ set(LYX_RELEASE_LEVEL ${CMAKE_MATCH_4})
+ set(LYX_RELEASE_PATCH ${CMAKE_MATCH_6})
+ set(LYX_BUILD_TYPE ${CMAKE_MATCH_7})
+ 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")
+ if (NOT LYX_RELEASE_LEVEL)
+ set(LYX_RELEASE_LEVEL 0)
+ endif()
+ if (NOT LYX_RELEASE_PATCH)
+ set(LYX_RELEASE_PATCH 0)
+ endif()
+ set(LYX_VERSION "${LYX_MAJOR_VERSION}.${LYX_MINOR_VERSION}")
+ endif()
+ endif()
+ if(_c_l MATCHES "^AC_SUBST\\( *LYX_DATE *, *\\[\\\"(.*)\\\"\\].*")
+ set(LYX_DATE "${CMAKE_MATCH_1}")
+ endif()
+ endforeach(_c_l)
+ set(${version} ${LYX_VERSION} ${LYX_MAJOR_VERSION} ${LYX_MINOR_VERSION} ${LYX_RELEASE_LEVEL} ${LYX_RELEASE_PATCH} PARENT_SCOPE)
+ set(${dirs} ${LYX_DIR_VER} ${LYX_USERDIR_VER} PARENT_SCOPE)
+ set(${date} ${LYX_DATE} PARENT_SCOPE)
+ if(LYX_BUILD_TYPE MATCHES "^\(dev\)$")
+ set(${buildtype} "development" PARENT_SCOPE)
+ elseif(LYX_BUILD_TYPE MATCHES "^\(alpha|beta|rc|pre\)[0-9]*$")
+ set(${buildtype} "prerelease" PARENT_SCOPE)
+ elseif(LYX_BUILD_TYPE MATCHES "^$")
+ set(${buildtype} "release" PARENT_SCOPE)
else()
- settestlabel(${testname} ${ARGN})
+ set(${buildtype} "unknown" PARENT_SCOPE)
+ message(FATAL_ERROR "\"${configfile}\": Unable to determine build-type from suffix \"${LYX_BUILD_TYPE}\" in AC_INIT macro")
endif()
-endmacro()
+endfunction(determineversionandbuildtype)
+
+# determine known cmake cxx_std features but only if not greater than ${max_desired}
+function(lyxgetknowncmakestd max_desired result)
+ set(tmp_list)
+ set(CXX_STD_LIST)
+ math(EXPR max_desired "${max_desired}+1")
+ if (CMAKE_VERSION VERSION_LESS "3.9")
+ list(APPEND tmp_list 98 11 14)
+ else()
+ foreach(_e ${CMAKE_CXX_COMPILE_FEATURES})
+ if (_e MATCHES "^cxx_std_\(.*)")
+ list(APPEND tmp_list ${CMAKE_MATCH_1})
+ endif()
+ endforeach()
+ endif()
+ list(REVERSE tmp_list)
+ # Filter undesired from list
+ foreach(i ${tmp_list})
+ if (i LESS ${max_desired} OR i GREATER 89)
+ list(APPEND CXX_STD_LIST ${i})
+ endif()
+ endforeach()
+ set(${result} ${CXX_STD_LIST} PARENT_SCOPE)
+endfunction()