1 From a2f0669fac1f8e7183b15cf7d14f0e99a2d8b012 Mon Sep 17 00:00:00 2001
2 From: Samuel Martin <s.martin49@gmail.com>
3 Date: Sat, 11 Jan 2014 21:47:39 +0100
4 Subject: [PATCH 3/6] cmake: do not try to run arithchk when cross-compiling to
7 Instead, use a predefined arith.h if provided, or generate a default one.
9 The arithchk binary is still built (but not installed) to allow the user to
10 run it on its target and use it; so then allowing to build an optimized
13 Signed-off-by: Samuel Martin <s.martin49@gmail.com>
15 F2CLIBS/libf2c/CMakeLists.txt | 38 ++++++++++++++++++++++++++++----------
16 1 file changed, 28 insertions(+), 10 deletions(-)
18 diff --git a/F2CLIBS/libf2c/CMakeLists.txt b/F2CLIBS/libf2c/CMakeLists.txt
19 index f98d66a..45a0804 100644
20 --- a/F2CLIBS/libf2c/CMakeLists.txt
21 +++ b/F2CLIBS/libf2c/CMakeLists.txt
22 @@ -38,17 +38,35 @@ set(TIME dtime_.c etime_.c)
24 # For INTEGER*8 support (which requires system-dependent adjustments to
25 # f2c.h), add ${QINT} to the OFILES assignment below...
26 -add_executable(arithchk arithchk.c)
28 - target_link_libraries(arithchk m)
29 +if(CMAKE_CROSSCOMPILING)
31 + message(STATUS "Using the user-defined '${ARITH_H}' as arith.h header.")
32 + configure_file("${ARITH_H}" "${CMAKE_CURRENT_BINARY_DIR}/arith.h" COPYONLY)
34 + message(STATUS "No user-defined arith.h header.")
35 + if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/arith.h")
36 + message(WARNING "Generating the default non-optimized 'arith.h' header.
38 +To generate and provide a custom arith.h header:
39 +run the cross-compiled arithchk binary on your target,
40 +and use its output to fill your custom arith.h header.")
41 + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arith.h"
42 + "/* default, not optimized arith.h */")
46 + add_executable(arithchk arithchk.c)
48 + target_link_libraries(arithchk m)
50 + set_target_properties(arithchk PROPERTIES COMPILE_DEFINITIONS
51 + "NO_FPINIT;NO_LONG_LONG")
53 + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/arith.h
54 + COMMAND arithchk > ${CMAKE_CURRENT_BINARY_DIR}/arith.h
58 -set_target_properties(arithchk PROPERTIES COMPILE_DEFINITIONS
59 - "NO_FPINIT;NO_LONG_LONG")
61 - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/arith.h
62 - COMMAND arithchk > ${CMAKE_CURRENT_BINARY_DIR}/arith.h
67 set(OFILES ${MISC} ${POW} ${CX} ${DCX} ${REAL} ${DBL} ${INT}