2006-09-15 17:05:20 +00:00
|
|
|
|
#
|
2011-01-10 22:47:58 +00:00
|
|
|
|
# Copyright (c) 2006-2011 Peter K<>mmel, <syntheticpp@gmx.net>
|
2006-09-15 17:05:20 +00:00
|
|
|
|
#
|
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
|
# are met:
|
2009-04-12 15:01:08 +00:00
|
|
|
|
#
|
2006-09-15 17:05:20 +00:00
|
|
|
|
# 1. Redistributions of source code must retain the copyright
|
2011-01-10 23:24:00 +00:00
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
2006-09-15 17:05:20 +00:00
|
|
|
|
# 2. Redistributions in binary form must reproduce the copyright
|
2011-01-10 23:24:00 +00:00
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
2009-04-12 15:01:08 +00:00
|
|
|
|
# 3. The name of the author may not be used to endorse or promote products
|
2011-01-10 23:24:00 +00:00
|
|
|
|
# derived from this software without specific prior written permission.
|
2009-04-12 15:01:08 +00:00
|
|
|
|
#
|
2006-09-15 17:05:20 +00:00
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
|
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
|
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2009-04-12 15:01:08 +00:00
|
|
|
|
#
|
2006-06-11 11:57:25 +00:00
|
|
|
|
|
2013-04-21 19:42:53 +00:00
|
|
|
|
include (MacroAddFileDependencies)
|
|
|
|
|
|
2007-08-28 19:54:42 +00:00
|
|
|
|
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
|
|
|
|
|
2006-06-11 11:57:25 +00:00
|
|
|
|
macro(lyx_add_path _list _prefix)
|
2011-01-10 23:24:00 +00:00
|
|
|
|
set(_tmp)
|
|
|
|
|
foreach(_current ${${_list}})
|
|
|
|
|
set(_tmp ${_tmp} ${_prefix}/${_current})
|
|
|
|
|
endforeach(_current)
|
|
|
|
|
set(${_list} ${_tmp})
|
2006-06-11 11:57:25 +00:00
|
|
|
|
endmacro(lyx_add_path _out _prefix)
|
|
|
|
|
|
|
|
|
|
|
2007-08-28 19:54:42 +00:00
|
|
|
|
#create the implementation files from the ui files and add them
|
2011-01-10 23:24:00 +00:00
|
|
|
|
#to the list of sources
|
2014-07-21 06:49:05 +00:00
|
|
|
|
#usage: LYX_ADD_UI_FILES(foo_SRCS ${ui_files})
|
2014-06-07 05:59:52 +00:00
|
|
|
|
macro(LYX_ADD_UI_FILES _sources _ui_files)
|
|
|
|
|
set(uifiles})
|
2011-01-10 23:24:00 +00:00
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
# we need to run uic and replace some things in the generated file
|
|
|
|
|
# this is done by executing the cmake script LyXuic.cmake
|
|
|
|
|
# ######
|
|
|
|
|
# Latest test showed on linux and windows show no bad consequeces,
|
|
|
|
|
# so we removed the call to LyXuic.cmake
|
2013-04-21 19:42:53 +00:00
|
|
|
|
qt_wrap_uifiles(${_header} ${_tmp_FILE} OPTIONS -tr lyx::qt_)
|
2014-06-07 05:59:52 +00:00
|
|
|
|
list(APPEND uifiles ${_header})
|
|
|
|
|
endforeach()
|
|
|
|
|
set(${_ui_files} ${uifiles})
|
2007-08-28 19:54:42 +00:00
|
|
|
|
endmacro(LYX_ADD_UI_FILES)
|
2006-06-11 11:57:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-08-28 19:54:42 +00:00
|
|
|
|
macro(LYX_AUTOMOC)
|
2011-01-10 23:24:00 +00:00
|
|
|
|
set(_matching_FILES)
|
|
|
|
|
foreach (_current_FILE ${ARGN})
|
|
|
|
|
|
|
|
|
|
get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
|
|
|
|
|
# if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
|
|
|
|
|
# here. this is required to make bouic work correctly:
|
|
|
|
|
# we need to add generated .cpp files to the sources (to compile them),
|
|
|
|
|
# but we cannot let automoc handle them, as the .cpp files don't exist yet when
|
|
|
|
|
# cmake is run for the very first time on them -> however the .cpp files might
|
|
|
|
|
# exist at a later run. at that time we need to skip them, so that we don't add two
|
|
|
|
|
# different rules for the same moc file
|
|
|
|
|
get_source_file_property(_skip ${_abs_FILE} SKIP_AUTOMOC)
|
|
|
|
|
|
|
|
|
|
if (EXISTS ${_abs_FILE} AND NOT _skip)
|
|
|
|
|
|
|
|
|
|
file(READ ${_abs_FILE} _contents)
|
|
|
|
|
|
|
|
|
|
get_filename_component(_abs_PATH ${_abs_FILE} PATH)
|
|
|
|
|
|
|
|
|
|
string(REGEX MATCHALL "#include +[\"<]moc_[^ ]+\\.cpp[\">]" _match "${_contents}")
|
|
|
|
|
if (_match)
|
|
|
|
|
foreach (_current_MOC_INC ${_match})
|
|
|
|
|
string(REGEX MATCH "moc_[^ <\"]+\\.cpp" _current_MOC "${_current_MOC_INC}")
|
|
|
|
|
|
|
|
|
|
get_filename_component(_basename ${_current_MOC} NAME_WE)
|
|
|
|
|
|
|
|
|
|
string(LENGTH ${_basename} _length)
|
|
|
|
|
MATH(EXPR _mocless_length ${_length}-4)
|
|
|
|
|
STRING(SUBSTRING ${_basename} 4 ${_mocless_length} _mocless_name )
|
|
|
|
|
|
|
|
|
|
set(_header ${_abs_PATH}/${_mocless_name}.h)
|
|
|
|
|
|
|
|
|
|
#message(STATUS "moc : ${_header}")
|
|
|
|
|
#set(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
|
|
|
|
|
#set(_header ${_abs_PATH}/${_basename}.h)
|
|
|
|
|
|
|
|
|
|
set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
|
|
|
|
|
if (WIN32)
|
2015-12-09 14:37:58 +00:00
|
|
|
|
set(_def -D_WIN32)
|
|
|
|
|
else()
|
|
|
|
|
set(_def)
|
2011-01-10 23:24:00 +00:00
|
|
|
|
endif()
|
|
|
|
|
#set(_moc ${_abs_PATH}/${_current_MOC})
|
|
|
|
|
add_custom_command(OUTPUT ${_moc}
|
|
|
|
|
COMMAND ${QT_MOC_EXECUTABLE}
|
2022-11-19 13:45:03 +00:00
|
|
|
|
ARGS "-DQT_VERSION=${QTx_VERSION}" ${_def} ${_moc_INCS} ${_header} -o ${_moc}
|
2011-01-10 23:24:00 +00:00
|
|
|
|
MAIN_DEPENDENCY ${_header})
|
|
|
|
|
macro_add_file_dependencies(${_abs_FILE} ${_moc})
|
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(${_moc} GENERATED)
|
|
|
|
|
endforeach (_current_MOC_INC)
|
|
|
|
|
else()
|
|
|
|
|
#message(STATUS "moc not found : ${_abs_FILE} ")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endforeach (_current_FILE)
|
2006-06-11 11:57:25 +00:00
|
|
|
|
endmacro (LYX_AUTOMOC)
|
2007-03-20 22:13:21 +00:00
|
|
|
|
|
|
|
|
|
|
2007-04-04 19:21:16 +00:00
|
|
|
|
macro(lyx_const_touched_files _allinone_name _list)
|
2011-01-10 23:24:00 +00:00
|
|
|
|
set(_file_list ${_allinone_name}_files)
|
|
|
|
|
set(_file_const ${CMAKE_CURRENT_BINARY_DIR}/${_allinone_name}_const.C)
|
|
|
|
|
set(_file_touched ${CMAKE_CURRENT_BINARY_DIR}/${_allinone_name}_touched.C)
|
|
|
|
|
|
|
|
|
|
# don't touch exisiting or non-empty file,
|
|
|
|
|
# so a cmake re-run doesn't touch all created files
|
|
|
|
|
set(_rebuild_file_const 0)
|
|
|
|
|
if (NOT EXISTS ${_file_const})
|
|
|
|
|
set(_rebuild_file_const 1)
|
|
|
|
|
else()
|
|
|
|
|
FILE(READ ${_file_const} _file_content)
|
|
|
|
|
if (NOT _file_content)
|
|
|
|
|
set(_rebuild_file_const 1)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(_rebuild_file_touched 0)
|
|
|
|
|
if (NOT EXISTS ${_file_touched})
|
|
|
|
|
set(_rebuild_file_touched 1)
|
|
|
|
|
else()
|
|
|
|
|
FILE(READ ${_file_touched} _file_content)
|
|
|
|
|
if (NOT _file_content)
|
|
|
|
|
set(_rebuild_file_touched 1)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (LYX_MERGE_REBUILD)
|
|
|
|
|
#message(STATUS "Merge files build: rebuilding generated files")
|
|
|
|
|
set(_rebuild_file_const 1)
|
|
|
|
|
set(_rebuild_file_touched 1)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (_rebuild_file_const)
|
|
|
|
|
file(WRITE ${_file_const} "// autogenerated file \n//\n")
|
|
|
|
|
file(APPEND ${_file_const} "// * clear or delete this file to build it again by cmake \n//\n\n")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (_rebuild_file_touched)
|
|
|
|
|
file(WRITE ${_file_touched} "// autogenerated file \n//\n")
|
|
|
|
|
file(APPEND ${_file_touched} "// * clear or delete this file to build it again by cmake \n//\n")
|
|
|
|
|
file(APPEND ${_file_touched} "// * don't touch this file \n//\n\n")
|
|
|
|
|
file(APPEND ${_file_touched} "#define DONT_INCLUDE_CONST_FILES\n")
|
|
|
|
|
file(APPEND ${_file_touched} "#include \"${_file_const}\"\n\n\n")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
#add merged files also to the project so they become editable
|
|
|
|
|
if(${GROUP_CODE} MATCHES "flat")
|
2011-01-10 22:47:58 +00:00
|
|
|
|
lyx_add_info_files_no_group(${${_list}})
|
|
|
|
|
else()
|
|
|
|
|
lyx_add_info_files(MergedFiles ${${_list}})
|
|
|
|
|
endif()
|
2014-06-07 08:45:13 +00:00
|
|
|
|
|
2011-01-10 23:24:00 +00:00
|
|
|
|
set(${_file_list} ${_file_const} ${_file_touched} ${lyx_${groupname}_info_files})
|
|
|
|
|
|
|
|
|
|
foreach (_current_FILE ${${_list}})
|
|
|
|
|
get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
|
|
|
|
|
# don't include any generated files in the final-file
|
|
|
|
|
# because then cmake will not know the dependencies
|
|
|
|
|
get_source_file_property(_isGenerated ${_abs_FILE} GENERATED)
|
|
|
|
|
if (_isGenerated)
|
|
|
|
|
list(APPEND ${_file_list} ${_abs_FILE})
|
|
|
|
|
else()
|
|
|
|
|
GET_FILENAME_COMPONENT(_file_name ${_abs_FILE} NAME_WE)
|
|
|
|
|
STRING(REGEX REPLACE "-" "_" _file_name "${_file_name}")
|
|
|
|
|
set(__macro_name ${_file_name}___ASSUME_CONST)
|
|
|
|
|
|
|
|
|
|
if (_rebuild_file_const)
|
|
|
|
|
file(APPEND ${_file_const} "#define ${__macro_name}\n")
|
|
|
|
|
file(APPEND ${_file_const} "#if defined(${__macro_name}) && !defined(DONT_INCLUDE_CONST_FILES)\n")
|
|
|
|
|
file(APPEND ${_file_const} "#include \"${_abs_FILE}\"\n")
|
|
|
|
|
file(APPEND ${_file_const} "#endif\n\n")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (_rebuild_file_touched)
|
|
|
|
|
file(APPEND ${_file_touched} "#ifndef ${__macro_name}\n")
|
|
|
|
|
file(APPEND ${_file_touched} "#include \"${_abs_FILE}\"\n")
|
|
|
|
|
file(APPEND ${_file_touched} "#endif\n\n")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endforeach (_current_FILE)
|
2007-03-30 20:29:23 +00:00
|
|
|
|
endmacro(lyx_const_touched_files)
|
2007-03-20 22:13:21 +00:00
|
|
|
|
|
2011-01-22 09:27:06 +00:00
|
|
|
|
macro(LYX_OPTION_INIT)
|
|
|
|
|
set(LYX_OPTIONS)
|
2016-06-05 14:26:59 +00:00
|
|
|
|
set(LYX_OPTION_STRINGS)
|
2011-01-22 09:27:06 +00:00
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
|
|
2010-07-07 22:26:36 +00:00
|
|
|
|
macro(LYX_OPTION _name _description _default _sys)
|
|
|
|
|
set(_msg OFF)
|
|
|
|
|
if(${_sys} MATCHES "GCC")
|
|
|
|
|
set(_system CMAKE_COMPILER_IS_GNUCXX)
|
2011-05-15 13:37:18 +00:00
|
|
|
|
elseif(${_sys} MATCHES "MAC")
|
|
|
|
|
set(_system APPLE)
|
2010-07-07 22:26:36 +00:00
|
|
|
|
else()
|
|
|
|
|
set(_system ${_sys})
|
|
|
|
|
endif()
|
|
|
|
|
if(${_system} MATCHES "ALL")
|
|
|
|
|
option(LYX_${_name} ${_description} ${_default})
|
|
|
|
|
set(_msg ON)
|
|
|
|
|
else()
|
|
|
|
|
if(${${_system}})
|
|
|
|
|
option(LYX_${_name} ${_description} ${_default})
|
|
|
|
|
set(_msg ON)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2011-01-22 09:27:06 +00:00
|
|
|
|
list(APPEND LYX_OPTIONS LYX_${_name})
|
|
|
|
|
set(LYX_${_name}_description ${_description})
|
|
|
|
|
set(LYX_${_name}_show_message ${_msg})
|
|
|
|
|
endmacro()
|
|
|
|
|
|
2014-06-07 08:45:13 +00:00
|
|
|
|
macro(LYX_COMBO _name _description _default)
|
2014-06-09 08:03:56 +00:00
|
|
|
|
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})")
|
2016-06-05 14:26:59 +00:00
|
|
|
|
list(APPEND LYX_OPTION_STRINGS ${_lyx_name})
|
2014-06-09 08:03:56 +00:00
|
|
|
|
# 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()
|
2014-06-07 08:45:13 +00:00
|
|
|
|
endmacro()
|
2011-01-22 09:27:06 +00:00
|
|
|
|
|
2016-06-05 14:26:59 +00:00
|
|
|
|
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()
|
2017-04-30 14:58:41 +00:00
|
|
|
|
if (NOT "${tmp_lyx_name}" MATCHES "^\\.[a-zA-Z_0-9\\.]+$")
|
2016-06-05 14:26:59 +00:00
|
|
|
|
message(FATAL_ERROR "Invalid string for lyx suffix (${tmp_lyx_name})")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
set(${_lyx_name} "${tmp_lyx_name}" CACHE STRING "${_description}" FORCE)
|
|
|
|
|
endmacro()
|
|
|
|
|
|
2011-01-22 09:27:06 +00:00
|
|
|
|
macro(LYX_OPTION_LIST_ALL)
|
2011-07-08 20:53:59 +00:00
|
|
|
|
if(UNIX)
|
|
|
|
|
set(run_cmake ${CMAKE_BINARY_DIR}/run_cmake.sh)
|
2011-07-08 21:30:13 +00:00
|
|
|
|
file(WRITE ${run_cmake} "#!/bin/bash \n")
|
2011-07-08 20:53:59 +00:00
|
|
|
|
execute_process(COMMAND chmod 755 ${run_cmake})
|
2011-07-08 21:30:13 +00:00
|
|
|
|
set(cont "\\\n")
|
|
|
|
|
elseif(WIN32)
|
|
|
|
|
set(run_cmake ${CMAKE_BINARY_DIR}/run_cmake.bat)
|
|
|
|
|
file(WRITE ${run_cmake} "")
|
|
|
|
|
set(cont "<nul ^\n")
|
2011-07-08 20:53:59 +00:00
|
|
|
|
endif()
|
2011-07-08 21:30:13 +00:00
|
|
|
|
file(APPEND ${run_cmake} "cmake ${CMAKE_SOURCE_DIR} ${cont}")
|
|
|
|
|
file(APPEND ${run_cmake} " -G\"${CMAKE_GENERATOR}\" ${cont}")
|
2011-01-22 09:27:06 +00:00
|
|
|
|
foreach(_option ${LYX_OPTIONS})
|
2011-05-10 20:25:31 +00:00
|
|
|
|
if(${_option}_show_message OR ${ARGV0} STREQUAL "help")
|
2014-06-07 19:00:46 +00:00
|
|
|
|
get_property(_prop CACHE ${_option} PROPERTY STRINGS)
|
2016-06-05 14:26:59 +00:00
|
|
|
|
list(FIND LYX_OPTION_STRINGS ${_option} _index)
|
2020-10-28 22:12:03 +00:00
|
|
|
|
set(_type "BOOL")
|
2016-06-05 14:26:59 +00:00
|
|
|
|
if (${_index} GREATER -1)
|
|
|
|
|
#message(STATUS "${_option} is of type string")
|
2014-06-07 19:00:46 +00:00
|
|
|
|
set(_isset ${${_option}})
|
2020-10-28 22:12:03 +00:00
|
|
|
|
set(_type "STRING")
|
2014-06-07 19:00:46 +00:00
|
|
|
|
elseif(${_option})
|
2011-01-22 09:27:06 +00:00
|
|
|
|
set(_isset ON)
|
|
|
|
|
else()
|
|
|
|
|
set(_isset OFF)
|
|
|
|
|
endif()
|
2020-10-28 22:12:03 +00:00
|
|
|
|
string(SUBSTRING "${_option}:${_type} " 0 35 _var)
|
|
|
|
|
string(SUBSTRING "${_isset} " 0 7 _val)
|
2019-07-14 09:12:55 +00:00
|
|
|
|
message(STATUS "${_var}= ${_val}: ${${_option}_description}")
|
2020-10-28 22:12:03 +00:00
|
|
|
|
file(APPEND ${run_cmake} " -D${_option}:${_type}=${${_option}} ${cont}")
|
2011-07-08 20:53:59 +00:00
|
|
|
|
endif()
|
2011-01-22 09:27:06 +00:00
|
|
|
|
endforeach()
|
2011-07-08 21:30:13 +00:00
|
|
|
|
file(APPEND ${run_cmake} "\n")
|
|
|
|
|
message(STATUS)
|
|
|
|
|
message(STATUS "CMake command with options is available in shell script")
|
|
|
|
|
message(STATUS " '${run_cmake}'")
|
2010-07-06 19:47:16 +00:00
|
|
|
|
endmacro()
|
|
|
|
|
|
2011-01-10 22:47:58 +00:00
|
|
|
|
macro(lyx_add_info_files group)
|
|
|
|
|
foreach(_it ${ARGN})
|
|
|
|
|
if(NOT IS_DIRECTORY ${_it})
|
|
|
|
|
get_filename_component(name ${_it} NAME)
|
|
|
|
|
if(NOT ${_it} MATCHES "^/\\\\..*$;~$")
|
2011-02-23 18:53:56 +00:00
|
|
|
|
set_source_files_properties(${_it} PROPERTIES HEADER_FILE_ONLY TRUE)
|
2011-01-10 22:47:58 +00:00
|
|
|
|
set(lyx_${group}_info_files ${lyx_${group}_info_files} ${_it})
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
2011-01-10 23:01:13 +00:00
|
|
|
|
set(check_group ${group}) #cmake bug?
|
|
|
|
|
if(check_group)
|
2011-01-10 22:47:58 +00:00
|
|
|
|
source_group(${group} FILES ${lyx_${group}_info_files})
|
|
|
|
|
endif()
|
|
|
|
|
set(lyx_info_files ${lyx_info_files} ${lyx_${group}_info_files})
|
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
|
macro(lyx_add_info_files_no_group)
|
|
|
|
|
lyx_add_info_files( "" ${ARGN})
|
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
|
macro(lyx_find_info_files group files)
|
|
|
|
|
file(GLOB _filelist ${files})
|
|
|
|
|
lyx_add_info_files(${group} ${_filelist})
|
|
|
|
|
endmacro()
|
2013-09-07 06:58:21 +00:00
|
|
|
|
|
|
|
|
|
macro(settestlabel testname)
|
|
|
|
|
get_property(_lab_list TEST ${testname} PROPERTY LABELS)
|
|
|
|
|
if(_lab_list)
|
|
|
|
|
list(APPEND _lab_list "${ARGN}")
|
|
|
|
|
else()
|
|
|
|
|
set(_lab_list "${ARGN}")
|
|
|
|
|
endif()
|
|
|
|
|
list(REMOVE_DUPLICATES _lab_list)
|
|
|
|
|
set_tests_properties(${testname} PROPERTIES LABELS "${_lab_list}")
|
|
|
|
|
endmacro()
|
|
|
|
|
|
2015-12-02 21:18:43 +00:00
|
|
|
|
macro(sortlabellist listout)
|
|
|
|
|
set(tmplist "")
|
|
|
|
|
foreach(_lab ${ARGN})
|
|
|
|
|
list(APPEND tmplist "${depth_${_lab}}${_lab}")
|
|
|
|
|
endforeach()
|
|
|
|
|
list(SORT tmplist)
|
2016-03-26 12:06:14 +00:00
|
|
|
|
string(REGEX REPLACE ";[-0-9]+" ";" ${listout} ";${tmplist}")
|
2013-09-07 06:58:21 +00:00
|
|
|
|
endmacro()
|
|
|
|
|
|
2015-12-02 21:18:43 +00:00
|
|
|
|
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()
|
2014-06-12 17:02:29 +00:00
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
2016-07-24 09:20:08 +00:00
|
|
|
|
# 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
|
2020-10-28 22:12:03 +00:00
|
|
|
|
"Location of Python module ${module}")
|
2016-07-24 09:20:08 +00:00
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
find_package_handle_standard_args(LYX_PY_${module} DEFAULT_MSG LYX_PY_${module_upper})
|
|
|
|
|
endfunction(find_python_module)
|
2020-07-12 14:27:45 +00:00
|
|
|
|
|
|
|
|
|
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)
|
2023-07-27 05:10:32 +00:00
|
|
|
|
if(PACKAGE_VERSION MATCHES "^\([0-9]+\)\\.\([0-9]+\)\(\\.\([0-9]+\)\(\\.\([0-9]+\)\)?\)?[-~]?\([A-Za-z]+[0-9]*\).*$")
|
2020-10-28 22:12:03 +00:00
|
|
|
|
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})
|
2023-06-19 06:00:08 +00:00
|
|
|
|
set(LYX_BUILD_TYPE_MATCH ${CMAKE_MATCH_7})
|
|
|
|
|
string(TOLOWER "${LYX_BUILD_TYPE_MATCH}" LYX_BUILD_TYPE)
|
2020-10-28 22:12:03 +00:00
|
|
|
|
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}")
|
2020-07-12 14:27:45 +00:00
|
|
|
|
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)
|
2024-01-13 09:49:14 +00:00
|
|
|
|
if(LYX_BUILD_TYPE MATCHES "^\(dev(el)?\)$")
|
2020-07-12 14:27:45 +00:00
|
|
|
|
set(${buildtype} "development" PARENT_SCOPE)
|
2020-12-29 19:27:19 +00:00
|
|
|
|
elseif(LYX_BUILD_TYPE MATCHES "^\(alpha|beta|rc|pre\)[0-9]*$")
|
2020-07-12 14:27:45 +00:00
|
|
|
|
set(${buildtype} "prerelease" PARENT_SCOPE)
|
|
|
|
|
elseif(LYX_BUILD_TYPE MATCHES "^$")
|
|
|
|
|
set(${buildtype} "release" PARENT_SCOPE)
|
|
|
|
|
else()
|
|
|
|
|
set(${buildtype} "unknown" PARENT_SCOPE)
|
|
|
|
|
message(FATAL_ERROR "\"${configfile}\": Unable to determine build-type from suffix \"${LYX_BUILD_TYPE}\" in AC_INIT macro")
|
|
|
|
|
endif()
|
|
|
|
|
endfunction(determineversionandbuildtype)
|
2020-10-28 22:12:03 +00:00
|
|
|
|
|
|
|
|
|
# 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()
|
|
|
|
|
|