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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
|
# bindings/f77/CMakeLists.txt
### Process this file with cmake to produce Makefile
###
# Copyright (C) 2006 Andrew Ross
#
# 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 PLplot; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
if(ENABLE_f77)
## Generate source files depending on type of PLFLT
## Note: sed will possibly fail on windows. Would this be better
## done using the cmake configure_file option eventually?
## Answer: no. The configuration option requires @ placeholders
## throughout the f77 source files which make them extremely hard
## to understand/maintain. Instead, we ask those Windows users who
## want the single-precision library to install sed (from MSYS or
## wherever).
if(PL_DOUBLE)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sfstubs.f
COMMAND ${CMAKE_COMMAND}
-E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/sfstubs.fm4 ${CMAKE_CURRENT_BINARY_DIR}/sfstubs.f
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sfstubs.fm4
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.h
COMMAND ${CMAKE_COMMAND}
-E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/plplot_parameters.fm4 ${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.h
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/plplot_parameters.fm4
)
else(PL_DOUBLE)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sfstubs.f
COMMAND sed
-f ${CMAKE_CURRENT_SOURCE_DIR}/double2single.sed ${CMAKE_CURRENT_SOURCE_DIR}/sfstubs.fm4 > ${CMAKE_CURRENT_BINARY_DIR}/sfstubs.f
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/double2single.sed
${CMAKE_CURRENT_SOURCE_DIR}/sfstubs.fm4
)
# For this case, use more extensive examples/f77 sed script since
# have double-precision floating-point constants to convert.
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.h
COMMAND sed
-f ${CMAKE_SOURCE_DIR}/examples/f77/double2single.sed ${CMAKE_CURRENT_SOURCE_DIR}/plplot_parameters.fm4 > ${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.h
DEPENDS
${CMAKE_SOURCE_DIR}/examples/f77/double2single.sed
${CMAKE_CURRENT_SOURCE_DIR}/plplot_parameters.fm4
)
endif(PL_DOUBLE)
add_custom_target(build_plplot_parameters_h ALL
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.h
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.h
DESTINATION ${F77_INCLUDE_DIR}
)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/sfstubs.f
PROPERTIES GENERATED ON)
if(WIN32)
# Set the flags for the C compiler. The C stubs need to have the
# correction case and calling convention for the Fortran compiler
IF(TARGET_FORTRAN MATCHES "IVF")
SET(DEFFILE "_ifort")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DIVF")
ELSEIF(TARGET_FORTRAN MATCHES "CVF")
SET(DEFFILE "")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DCVF")
ENDIF(TARGET_FORTRAN MATCHES "IVF")
endif(WIN32)
if(F77_CMD_LINE)
set(HAVE_F77PARSE_CL_FALSE C)
else(F77_CMD_LINE)
set(HAVE_F77PARSE_CL_TRUE C)
endif(F77_CMD_LINE)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/configurable.f.cmake
${CMAKE_CURRENT_BINARY_DIR}/configurable.f
)
# Set the include path
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/lib/qsastime
${CMAKE_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/include
)
## Build C part of F77 bindings
# Check consistency of plplot_parameters.fm4.
add_custom_target(
check_f77_parameters
COMMAND ${CMAKE_COMMAND} -E remove -f
${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.fm4_compare
COMMAND
sed -f ${CMAKE_CURRENT_SOURCE_DIR}/global_defines.sed <
${CMAKE_SOURCE_DIR}/bindings/swig-support/plplotcapi.i >
${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.fm4_compare
COMMAND
${CMAKE_COMMAND} -E echo "Check that plplot_parameters.fm4 is consistent with the #defines in bindings/swig-support/plplotcapi.i"
COMMAND
cmp ${CMAKE_CURRENT_SOURCE_DIR}/plplot_parameters.fm4
${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.fm4_compare
)
set(plplotf77c${LIB_TAG}_LIB_SRCS
sc3d.c
sccont.c
scstubs.c
)
if(BUILD_SHARED_LIBS)
SET_SOURCE_FILES_PROPERTIES( ${plplotf77c${LIB_TAG}_LIB_SRCS}
PROPERTIES COMPILE_FLAGS "-DUSINGDLL" )
endif(BUILD_SHARED_LIBS)
add_library(plplotf77c${LIB_TAG} ${plplotf77c${LIB_TAG}_LIB_SRCS})
target_link_libraries(plplotf77c${LIB_TAG} plplot${LIB_TAG})
if(USE_RPATH)
get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH)
set_target_properties(plplotf77c${LIB_TAG}
PROPERTIES
SOVERSION ${plplotf77_SOVERSION}
VERSION ${plplotf77_VERSION}
INSTALL_RPATH "${LIB_INSTALL_RPATH}"
INSTALL_NAME_DIR "${LIB_DIR}"
)
else(USE_RPATH)
set_target_properties(plplotf77c${LIB_TAG}
PROPERTIES
SOVERSION ${plplotf77_SOVERSION}
VERSION ${plplotf77_VERSION}
INSTALL_NAME_DIR "${LIB_DIR}"
)
endif(USE_RPATH)
# Set the path and the suffix for the (shared) libraries
if(CYGWIN)
if(BUILD_SHARED_LIBS)
set(SHLIB_DIR "${BIN_DIR}")
endif(BUILD_SHARED_LIBS)
set(VERSION_SUFFIX "-${plplotf77_VERSION}")
else(CYGWIN)
set(VERSION_SUFFIX "")
endif(CYGWIN)
install(TARGETS plplotf77c${LIB_TAG}
EXPORT export_plplot
ARCHIVE DESTINATION ${LIB_DIR}
LIBRARY DESTINATION ${LIB_DIR}
RUNTIME DESTINATION ${BIN_DIR}
)
## Build fortran part of F77 bindings
if(STATIC_OPTS)
# Put the file configurable.f in a separate static library
set(plplotf77opts${LIB_TAG}_LIB_SRCS
configurable.f
)
set(plplotf77${LIB_TAG}_LIB_SRCS
strutil.f
sfstubs.f
)
else(STATIC_OPTS)
set(plplotf77${LIB_TAG}_LIB_SRCS
strutil.f
sfstubs.f
configurable.f
)
endif(STATIC_OPTS)
if(WIN32 AND BUILD_SHARED_LIBS AND NOT CYGWIN AND NOT MINGW)
SET(plplotf77${LIB_TAG}_LIB_SRCS ${plplotf77${LIB_TAG}_LIB_SRCS} plplotf77${DEFFILE}.def)
endif(WIN32 AND BUILD_SHARED_LIBS AND NOT CYGWIN AND NOT MINGW)
add_library(plplotf77${LIB_TAG} ${plplotf77${LIB_TAG}_LIB_SRCS})
if(STATIC_OPTS)
add_library(plplotf77opts${LIB_TAG} STATIC ${plplotf77opts${LIB_TAG}_LIB_SRCS})
target_link_libraries(plplotf77${LIB_TAG} plplotf77c${LIB_TAG})
target_link_libraries(plplotf77opts${LIB_TAG} plplotf77${LIB_TAG} plplotf77c${LIB_TAG})
else(STATIC_OPTS)
target_link_libraries(plplotf77${LIB_TAG} plplotf77c${LIB_TAG})
endif(STATIC_OPTS)
if(USE_RPATH)
set_target_properties(plplotf77${LIB_TAG}
PROPERTIES
SOVERSION ${plplotf77_SOVERSION}
VERSION ${plplotf77_VERSION}
INSTALL_RPATH "${LIB_INSTALL_RPATH}"
INSTALL_NAME_DIR "${LIB_DIR}"
)
else(USE_RPATH)
set_target_properties(plplotf77${LIB_TAG}
PROPERTIES
SOVERSION ${plplotf77_SOVERSION}
VERSION ${plplotf77_VERSION}
INSTALL_NAME_DIR "${LIB_DIR}"
)
endif(USE_RPATH)
install(TARGETS plplotf77${LIB_TAG}
EXPORT export_plplot
ARCHIVE DESTINATION ${LIB_DIR}
LIBRARY DESTINATION ${LIB_DIR}
RUNTIME DESTINATION ${BIN_DIR}
)
if(STATIC_OPTS)
install(TARGETS plplotf77opts${LIB_TAG}
EXPORT export_plplot
ARCHIVE DESTINATION ${LIB_DIR}
LIBRARY DESTINATION ${LIB_DIR}
RUNTIME DESTINATION ${BIN_DIR}
)
endif(STATIC_OPTS)
# Configure pkg-config *.pc file corresponding to libplplotf77${LIB_TAG}
if(PKG_CONFIG_EXECUTABLE)
if(LIB_TAG)
set(PC_PRECISION "double")
else(LIB_TAG)
set(PC_PRECISION "single")
endif(LIB_TAG)
# Each list element must consist of a colon-separated string with the
# following fields which are parsed out in the foreach loop below and
# used to configure the corresponding pkg-config *.pc file.
# BINDING - ENABLE_${BINDING} keeps track of whether a
# binding has been enabled (ON) or not (OFF).
# Also, ${BINDING} used to determine PC_FILE_SUFFIX
# which helps to determine name of configured
# *.pc file.
# PC_SHORT_NAME - Used in *.pc NAME: field
# PC_LONG_NAME - Used in *.pc Description: field
# PC_LIBRARY_NAME - Used in *.pc Libs: field
# Also used to determine PC_LINK_FLAGS and
# PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
# fields.
set(PC_DATA "f77:F77:F77 bindings, :plplotf77${LIB_TAG}${VERSION_SUFFIX}")
string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
set(PC_FILE_SUFFIX "-${BINDING}")
set(PC_REQUIRES "plplot${LIB_TAG}")
string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
set(PC_COMPILE_FLAGS "-I${F77_INCLUDE_DIR} ${PC_COMPILE_FLAGS}")
set(PC_LINK_FLAGS
"-l${PC_LIBRARY_NAME} -lplplotf77c${LIB_TAG}${VERSION_SUFFIX} ${PC_LINK_FLAGS}"
)
set(PC_CONFIGURED_FILE
${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
)
configure_file(
${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
${PC_CONFIGURED_FILE}
@ONLY
)
install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
endif(PKG_CONFIG_EXECUTABLE)
endif(ENABLE_f77)
|