]> git.lyx.org Git - features.git/blobdiff - development/cmake/modules/LyXMacros.cmake
Cmake build: Allow user defined suffix for program files
[features.git] / development / cmake / modules / LyXMacros.cmake
index 266a76f03c990036729d9a3ae038abbf33478398..be7470c93f4e8f6037141e92bc330ebdedab1c91 100644 (file)
@@ -25,6 +25,8 @@
 #  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 
+include (MacroAddFileDependencies)
+
 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
 
 macro(lyx_add_path _list _prefix)
@@ -38,10 +40,10 @@ endmacro(lyx_add_path _out _prefix)
 
 #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)
@@ -51,11 +53,10 @@ macro(LYX_ADD_UI_FILES _sources _ui)
                # ######
                # Latest test showed on linux and windows show no bad consequeces,
                # so we removed the call to LyXuic.cmake
-               add_custom_command(OUTPUT ${_header}
-        COMMAND ${QT_UIC_EXECUTABLE} -tr lyx::qt_ ${_tmp_FILE} -o ${_header}
-                       MAIN_DEPENDENCY ${_tmp_FILE})
-               set(${_ui} ${${_ui}} ${_header})
-       endforeach (_current_FILE)
+               qt_wrap_uifiles(${_header} ${_tmp_FILE} OPTIONS -tr lyx::qt_)
+               list(APPEND uifiles ${_header})
+       endforeach()
+       set(${_ui_files} ${uifiles})
 endmacro(LYX_ADD_UI_FILES)
 
 
@@ -103,7 +104,9 @@ macro(LYX_AUTOMOC)
 
                                        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}
@@ -173,7 +176,7 @@ macro(lyx_const_touched_files _allinone_name _list)
        else()
                lyx_add_info_files(MergedFiles ${${_list}})
        endif()
-       
+
        set(${_file_list} ${_file_const} ${_file_touched} ${lyx_${groupname}_info_files})
 
        foreach (_current_FILE ${${_list}})
@@ -206,6 +209,7 @@ endmacro(lyx_const_touched_files)
 
 macro(LYX_OPTION_INIT)
        set(LYX_OPTIONS)
+       set(LYX_OPTION_STRINGS)
 endmacro()
 
 
@@ -232,6 +236,42 @@ macro(LYX_OPTION _name _description _default _sys)
        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_\\.]+$")
+      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)
@@ -249,7 +289,12 @@ macro(LYX_OPTION_LIST_ALL)
        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)
+                       if (${_index} GREATER -1)
+                         #message(STATUS "${_option} is of type string")
+                          set(_isset ${${_option}})
+                       elseif(${_option})
                                set(_isset ON)
                        else()
                                set(_isset OFF)
@@ -290,3 +335,47 @@ macro(lyx_find_info_files group files)
        file(GLOB _filelist ${files})
        lyx_add_info_files(${group} ${_filelist})
 endmacro()
+
+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()
+
+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()
+