File: csiro.cmake

package info (click to toggle)
plplot 5.15.0%2Bdfsg-19
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 31,312 kB
  • sloc: ansic: 79,707; xml: 28,583; cpp: 20,033; ada: 19,456; tcl: 12,081; f90: 11,431; ml: 7,276; java: 6,863; python: 6,792; sh: 3,274; perl: 828; lisp: 75; makefile: 50; sed: 34; fortran: 5
file content (130 lines) | stat: -rw-r--r-- 5,827 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# cmake/modules/csiro.cmake
#
# Copyright (C) 2006-2019  Alan W. Irwin
#
# This file is part of PLplot.
#
# PLplot is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; version 2 of the License.
#
# PLplot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with the file PLplot; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

# Module for determining all configuration variables for the CSIRO libraries.

option(PL_HAVE_QHULL "Enable use of the Qhull library" ON)
option(WITH_CSA "Enable use of the csa library" ON)

# This logic copied verbatim from csiro.ac for ix86 systems and alpha systems
# with two possible compilers.  In future, this logic will need to be
# expanded to a lot more cases as we gain platform experience.
set(NAN_CFLAGS ${CMAKE_C_FLAGS})
if(PL_HAVE_QHULL OR WITH_CSA)
  if(CMAKE_SYSTEM_PROCESSOR MATCHES "alpha.*")
    set(NAN_CFLAGS "${NAN_CFLAGS} -mieee")
  endif(CMAKE_SYSTEM_PROCESSOR MATCHES "alpha.*")
  if(NOT DEFINED NaNAwareCCompiler)
    message(STATUS "Check for NaN awareness in C compiler")
    try_run(RUN_RESULT COMPILE_RESULT
      ${CMAKE_BINARY_DIR}
      ${CMAKE_SOURCE_DIR}/cmake/modules/TestNaNAware.c
      CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${NAN_CFLAGS} -I\"${CMAKE_SOURCE_DIR}\"/lib/csa ${MATH_LIB}"
      OUTPUT_VARIABLE OUTPUT
      )
    #message(STATUS "COMPILE_RESULT = ${COMPILE_RESULT}")
    #message(STATUS "RUN_RESULT = ${RUN_RESULT}")
    if(COMPILE_RESULT AND NOT RUN_RESULT MATCHES "FAILED_TO_RUN" AND RUN_RESULT)
      set(NaNAwareCCompiler ON)
    else(COMPILE_RESULT AND NOT RUN_RESULT MATCHES "FAILED_TO_RUN" AND RUN_RESULT)
      set(NaNAwareCCompiler OFF)
    endif(COMPILE_RESULT AND NOT RUN_RESULT MATCHES "FAILED_TO_RUN" AND RUN_RESULT)

    if(NaNAwareCCompiler)
      message(STATUS "Check for NaN awareness in C compiler - found")
      file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log
	"Determining whether C compiler is NaN aware succeeded with "
	"the following output:\n${OUTPUT}\n\n"
	)
    else(NaNAwareCCompiler)
      message(STATUS "Check for NaN awareness in C compiler - not found")
      message(STATUS "WARNING: Setting PL_HAVE_QHULL and WITH_CSA to OFF.")
      set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE)
      set(WITH_CSA OFF CACHE BOOL "Enable use of the csa library" FORCE)
      file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
	"Determining whether C compiler is NaN aware failed with "
	"the following output:\n${OUTPUT}\n\n"
	)
    endif(NaNAwareCCompiler)
  endif(NOT DEFINED NaNAwareCCompiler)
endif(PL_HAVE_QHULL OR WITH_CSA)

if(PL_HAVE_QHULL)
  find_package(QHULL)
  if(QHULL_FOUND)
    message(STATUS "QHULL_INCLUDE_DIRS = ${QHULL_INCLUDE_DIRS}")
    message(STATUS "HAS_LIBQHULL_INCLUDE = ${HAS_LIBQHULL_INCLUDE}")
    message(STATUS "QHULL_LIBRARIES = ${QHULL_LIBRARIES}")
    set(QHULL_RPATH ${QHULL_LIBRARY_DIRS})
    filter_rpath(QHULL_RPATH)
    message(STATUS "QHULL_RPATH = ${QHULL_RPATH}")
    include(CheckFunctionExists)
    cmake_push_check_state()
    list(APPEND CMAKE_REQUIRED_LIBRARIES ${QHULL_LIBRARIES})
    check_function_exists(qh_new_qhull QH_NEW_EXIST)
    cmake_pop_check_state()
    if(NOT QH_NEW_EXIST)
      message(STATUS "WARNING: function qh_new_qhull not found.  Setting PL_HAVE_QHULL to OFF.")
      set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE)
    endif(NOT QH_NEW_EXIST)
    if(HAS_LIBQHULL_INCLUDE)
      file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c "#include <libqhull/qhull_a.h>")
    else(HAS_LIBQHULL_INCLUDE)
      file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c "#include <qhull/qhull_a.h>")
    endif(HAS_LIBQHULL_INCLUDE)
    file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c
      "
int main(void)
{
  if ( sizeof ( realT ) != sizeof ( double ) )
    return 1;
  else
    return 0;
}
"
      )
    try_run(RUN_RESULT COMPILE_RESULT
      ${CMAKE_CURRENT_BINARY_DIR}
      ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c
      CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=-I\"${QHULL_INCLUDE_DIRS}\""
      OUTPUT_VARIABLE OUTPUT
      )
    #message(STATUS "Check_realT_size COMPILE_RESULT = ${COMPILE_RESULT}")
    #message(STATUS "Check_realT_size RUN_RESULT = ${RUN_RESULT}")
    if(NOT COMPILE_RESULT OR RUN_RESULT MATCHES "FAILED_TO_RUN")
      message(STATUS "Either could not compile or could not run code to check wrong size for realT in qhull library.  Dropping qhull librarydependency of PLplot.")
      set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE)
    endif(NOT COMPILE_RESULT OR RUN_RESULT MATCHES "FAILED_TO_RUN")

    if(RUN_RESULT)
      message(STATUS "qhull library compiled with incorrect (non-double) size for realT.  Dropping qhull dependency of PLplot.")
      set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE)
    else(RUN_RESULT)
      message(STATUS "qhull library compiled with correct (double) size for realT.")
    endif(RUN_RESULT)

  else(QHULL_FOUND)
    message(STATUS "QHULL_INCLUDE_DIRS = ${QHULL_INCLUDE_DIRS}")
    message(STATUS "QHULL_LIBRARIES = ${QHULL_LIBRARIES}")
    message(STATUS
      "WARNING: at least one of QHULL_INCLUDE_DIRS or QHULL_LIBRARIES is false so setting PL_HAVE_QHULL to OFF."
      )
    set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE)
  endif(QHULL_FOUND)
endif(PL_HAVE_QHULL)