]> 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 2bddaaf079645d37fe499bf24b2af57d8bc9e8cf..be7470c93f4e8f6037141e92bc330ebdedab1c91 100644 (file)
@@ -40,7 +40,7 @@ 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})
+#usage: LYX_ADD_UI_FILES(foo_SRCS ${ui_files})
 macro(LYX_ADD_UI_FILES _sources _ui_files)
        set(uifiles})
        foreach (_current_FILE ${ARGN})
@@ -104,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}
@@ -207,6 +209,7 @@ endmacro(lyx_const_touched_files)
 
 macro(LYX_OPTION_INIT)
        set(LYX_OPTIONS)
+       set(LYX_OPTION_STRINGS)
 endmacro()
 
 
@@ -234,9 +237,40 @@ macro(LYX_OPTION _name _description _default _sys)
 endmacro()
 
 macro(LYX_COMBO _name _description _default)
-  set(LYX_${_name} ${_default} CACHE STRING "${_description}")
-  set_property(CACHE LYX_${_name} PROPERTY STRINGS ${_default} ${ARGN})
-  list(APPEND LYX_OPTIONS LYX_${_name})
+  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)
@@ -255,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)
@@ -308,11 +347,35 @@ macro(settestlabel testname)
   set_tests_properties(${testname} PROPERTIES LABELS "${_lab_list}")
 endmacro()
 
-macro(setmarkedtestlabel testname reverted)
-  if(reverted)
-    settestlabel(${testname} "reverted" ${ARGN})
-  else()
-    settestlabel(${testname} ${ARGN})
-  endif()
+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()