source: git/modules/IntegerProgramingMacros.cmake @ 8cc501

spielwiese
Last change on this file since 8cc501 was 8cc501, checked in by Kai Krüger <krueger@…>, 13 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: 1.6 KB
Line 
1# -*- mode: cmake; -*-
2#
3#
4#
5
6function(ip_create_version GET_TARGET GET_FILE)
7  message(STATUS "generate si_gcc_v.h")
8
9  set(_GEN_TARGET "ip-inc")
10  set(_GEN_FILE "${CMAKE_CURRENT_BINARY_DIR}/si_gcc_v.h")
11
12  if(${CMAKE_CXX_COMPILER_MAJOR} EQUAL 2)
13    file(WRITE ${_GEN_FILE} "#define SI_GCC2\n")
14  endif(${CMAKE_CXX_COMPILER_MAJOR} EQUAL 2)
15  if(${CMAKE_CXX_COMPILER_MAJOR} EQUAL 3)
16    file(WRITE ${_GEN_FILE} "#define SI_GCC3\n")
17  endif(${CMAKE_CXX_COMPILER_MAJOR} EQUAL 3)
18  if(${CMAKE_CXX_COMPILER_MAJOR} EQUAL 4)
19    file(WRITE ${_GEN_FILE} "#define SI_GCC4\n")
20  endif(${CMAKE_CXX_COMPILER_MAJOR} EQUAL 4)
21
22  set(${GEN_TARGET} ${_GEN_TARGET} PARENT_SCOPE)
23  set(${GEN_FILE} ${_GEN_FILE} PARENT_SCOPE)
24endfunction()
25
26include(CheckCSourceRuns)
27
28function(ip_create_version2 GEN_TARGET GEN_FILE)
29  message(STATUS "generate si_gcc_v.h")
30
31  set(_GEN_TARGET "ip-inc")
32  set(_GEN_FILE "${CMAKE_CURRENT_BINARY_DIR}/si_gcc_v.h")
33  set(TESTFILE "${CMAKE_CURRENT_BINARY_DIR}/tmp.c")
34  set(_TEST_SOURCE "#include <stdio.h>
35int main() {
36FILE *f=fopen(\"${_GEN_FILE}\",\"w\");
37#ifdef __GNUC__
38char *p=__VERSION__;
39if (p[0]=='2') fprintf(f,\"#define SI_GCC2\\n\");
40else if ((p[0]=='3')||(p[0]=='4')) fprintf(f,\"#define SI_GCC3\\n\");
41#endif
42fclose(f);
43return 0;
44 }
45")
46  CHECK_C_SOURCE_RUNS(${_TEST_SOURCE} RUN_RESULT_VAR)
47  message(STATUS "compile : '${_GEN_FILE}'")
48  message(STATUS "run     : '${RUN_RESULT_VAR}'")
49  message(STATUS "rc     : '${_TEST_SOURCE}'")
50
51  add_custom_target(ip-inc DEPENDS ${_GEN_FILE} )
52  set(${GEN_TARGET} ${_GEN_TARGET} PARENT_SCOPE)
53  set(${GEN_FILE} ${_GEN_FILE} PARENT_SCOPE)
54endfunction()
Note: See TracBrowser for help on using the repository browser.