source: git/modules/FactoryMacros.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.2 KB
Line 
1# -*- mode: cmake; -*-
2#
3#
4#
5function(factory_header GEN_H_FILE TEMPLATE_FILE)
6  string(REGEX REPLACE ".template" "" TEMPLATE_BASE ${TEMPLATE_FILE})
7  set(_GEN_H_FILE ${CMAKE_CURRENT_BINARY_DIR}/${TEMPLATE_BASE}.h)
8  set(MAKEHEADER_CMD "${CMAKE_CURRENT_SOURCE_DIR}/bin/makeheader")
9
10  set(_OPT "-I${CMAKE_CURRENT_SOURCE_DIR}")
11  set(_OPT "${_OPT} -I${CMAKE_CURRENT_BINARY_DIR}")
12  add_custom_command(OUTPUT ${_GEN_H_FILE}
13    COMMAND ${MAKEHEADER_CMD} ${_OPT} ${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_FILE} ${_GEN_H_FILE}
14     
15    DEPENDS ${TEMPLATE_FILE}
16    COMMENT "Compiling '${TEMPLATE_FILE}'..."
17    )
18
19  set(${GEN_H_FILE} ${_GEN_H_FILE} PARENT_SCOPE)
20endfunction()
21
22function(factory_gen_gmp_header GEN_TARGET GEN_H_FILE)
23  set(_GEN_H_FILE ${CMAKE_CURRENT_BINARY_DIR}/cf_gmp.h)
24  #try_compile(RESULT_VAR bindir srcdir
25  #            projectName <targetname> [CMAKE_FLAGS <Flags>]
26  #            [OUTPUT_VARIABLE var])
27  #try_compile(RESULT_VAR ${CMAKE_CURRENT_BINARY_DIR}  ${CMAKE_CURRENT_SOURCE_DIR}
28  #  projectName cf_gmp
29  execute_process(COMMAND ${CMAKE_CXX_COMPILER} -M ${CMAKE_CURRENT_SOURCE_DIR}/gen_cf_gmp.cc
30    RESULT_VARIABLE RESULT_VAR
31    OUTPUT_VARIABLE OUTPUT_VAR)
32  string(REGEX REPLACE "gen_cf_gmp.o:" "" OUTPUT_VAR ${OUTPUT_VAR})
33  string(REGEX REPLACE "[\\\n]" " " OUTPUT_VAR ${OUTPUT_VAR})
34  string(REGEX REPLACE "[ ]+" ";" _OUTPUT_VAR ${OUTPUT_VAR})
35 
36  set(_gmp_headers "")
37
38  foreach(_loop_var ${_OUTPUT_VAR})
39    if( ${_loop_var} MATCHES "gmp.*h")
40      message(STATUS "==${_loop_var}=")
41      set(_gmp_headers ${_gmp_headers} ${_loop_var})
42      #list(APPEND _gmp_headers ${_loop_var})
43    endif( ${_loop_var} MATCHES "gmp.*h")
44  endforeach(_loop_var)
45  message(STATUS "'${_gmp_headers}'")
46
47  add_custom_command(OUTPUT ${_GEN_H_FILE}
48    COMMAND cat ${_gmp_headers} | grep -v __GMP_DECLSPEC_XX > ${_GEN_H_FILE}
49   
50    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
51    COMMENT "Create cf_gmp.h"
52    )
53  message(STATUS "====================================")
54  message(STATUS "'${RESULT_VAR}'")
55  #message(STATUS "'${_OUTPUT_VAR}'")
56  message(STATUS "====================================")
57
58  set(${GEN_TARGET} "generate_factory" PARENT_SCOPE)
59  add_custom_target(generate_factory DEPENDS ${_GEN_H_FILE} )
60  set(${GEN_H_FILE} ${_GEN_H_FILE} PARENT_SCOPE)
61endfunction()
Note: See TracBrowser for help on using the repository browser.