source: git/modules/LibMacros.cmake @ fec53d

fieker-DuValspielwiese
Last change on this file since fec53d was 8cc501, checked in by Kai Krüger <krueger@…>, 14 years ago
Added files to compile with cmake. Still experimental. Might not work git-svn-id: file:///usr/local/Singular/svn/trunk@13240 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.3 KB
Line 
1# -*- mode: cmake; -*-
2#
3# This file contains a convenience macro for the use with the SMC state machine compiler
4#
5
6function(unpack_library GEN_FILELIST GEN_TARGET SUBDIR NAME)
7  set(_GEN_FILES "NIL")
8  set(_GEN_TARGET "unpack-${NAME}")
9  set(AR ar)
10  get_target_property(loc ${NAME} LOCATION)
11  message(STATUS "Merge-Unpack ${NAME} target='${_GEN_TARGET}' - '${_GEN_FILES}'")
12  #add_custom_command(
13  #  COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIR}
14  #  )
15  execute_process(
16    COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIR}
17    COMMENT "Merge:Unpack:mkdir ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIR}"
18    )
19  add_custom_target(${_GEN_TARGET}
20    COMMAND ${AR} x ${loc}
21    COMMAND ls -l 
22    DEPENDS ${NAME}
23    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIR}
24    COMMENT "Merge:Unpack library ${NAME}")
25
26  set(${GEN_TARGET} ${_GEN_TARGET} PARENT_SCOPE)
27  set(${GEN_FILELIST} ${_GEN_FILES} PARENT_SCOPE)
28endfunction()
29
30function(merge_libraries GEN_TARGET GEN_LIB_A LIB_NAME LIBFILES)
31
32  set(_GEN_TARGET "${LIB_NAME}-add")
33  set(_GEN_LIB_A "${CMAKE_CURRENT_BINARY_DIR}/lib${LIB_NAME}.a" )
34
35  message(STATUS "  Merging libraries into ${LIB_NAME}.a")
36  message(STATUS "  Have ARGC=${ARGC} arguments")
37  message(STATUS "  Have ARGN=${ARGN} arguments")
38  message(STATUS "CBD: '${CMAKE_CURRENT_BINARY_DIR}'")
39
40  add_custom_target(${_GEN_TARGET})
41  set(i 0)
42  foreach(loop_var ${ARGV})
43    math(EXPR i ${i}+1)
44    if( ${i} GREATER 3)
45      get_target_property(loc ${loop_var} LOCATION)
46      message(STATUS "    Argument ${i}: '${loop_var}' '${loc}'.")
47      unpack_library(FILE_${loop_var} _GEN_TARGET_${loop_var} ${loop_var} ${loop_var})
48      file(GLOB nlin_srsc ${loop_var}/*.o)
49      message(STATUS "    -> filevar:FILE_${loop_var}='${FILE_${loop_var}}' target='${_GEN_TARGET_${loop_var}}'")
50      add_dependencies(${_GEN_TARGET} ${_GEN_TARGET_${loop_var}})
51      #set(arg "ARG${loop_var}")
52    #message(STATUS "    Argument ${loop_var}: '${arg2}'.")
53    #string(STRIP ${loop_var} FUNC)
54    #string(TOUPPER ${loop_var} VAR)
55    #check_function_exists(${FUNC} HAVE_${VAR})
56    endif()
57  endforeach(loop_var)
58
59  add_custom_command(TARGET ${_GEN_TARGET}
60    COMMAND echo "FileS: ${FILE_${loop_var}}'"
61    COMMENT "Merge: rebuild library"
62    )
63  set(${GEN_TARGET} ${_GEN_TARGET} PARENT_SCOPE)
64  set(${GEN_LIB_A} ${_GEN_LIB_A} PARENT_SCOPE)
65endfunction()
Note: See TracBrowser for help on using the repository browser.