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 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119
|
#
# copyright : (c) 2010 Maxime Lenoir and Alain Coulais
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
# create version string based on git metadata (based on https://github.com/nocnokneo/cmake-git-versioning-example)
# in case version.hpp does not exist (it is shipped in GDL tarballs but not stored in the repo)
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/src/version.hpp")
find_package(Git REQUIRED)
add_custom_target(version
${CMAKE_COMMAND} -D SRC=${CMAKE_SOURCE_DIR}/src/version.hpp.in
-D DST=${CMAKE_BINARY_DIR}/version.hpp
-D GIT_EXECUTABLE=${GIT_EXECUTABLE}
-P ${CMAKE_SOURCE_DIR}/CMakeModules/GenerateVersionHeader.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endif()
# Set some policies to fix warnings in newer versions of cmake
# Since VERSION_GREATER_EQUAL is available only since 3.7, we use
# VERSION_GREATER combined with VERSION_EQUAL to achieve what we want
if (CMAKE_MINOR_VERSION GREATER 12)
if (CMAKE_VERSION VERSION_GREATER "3.12.0" OR CMAKE_VERSION VERSION_EQUAL "3.12.0")
cmake_policy(SET CMP0075 NEW)
endif(CMAKE_VERSION VERSION_GREATER "3.12.0" OR CMAKE_VERSION VERSION_EQUAL "3.12.0")
if (CMAKE_VERSION VERSION_GREATER "3.13.0" OR CMAKE_VERSION VERSION_EQUAL "3.13.0")
cmake_policy(SET CMP0077 NEW)
endif(CMAKE_VERSION VERSION_GREATER "3.13.0" OR CMAKE_VERSION VERSION_EQUAL "3.13.0")
endif (CMAKE_MINOR_VERSION GREATER 12)
project(GDL)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 99)
# advice by Orion, mandatory for FC 28
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
enable_testing()
# cf issue 511, managing MultiArch on Debian ...
include(GNUInstallDirs)
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
include(CheckLibraryExists)
include(CheckFunctionExists)
include(CheckSymbolExists)
include(CheckCSourceRuns)
include(CheckCXXSourceCompiles)
include(FindPkgConfig)
include(FindPackageHandleStandardArgs)
include(TestBigEndian)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeModules)
#### GDL is an interactive tool. Normally INTERACTIVE_GRAPHICS must be set
set(INTERACTIVE_GRAPHICS ON CACHE BOOL "GDL: Disable checking existence of a suited graphics driver in plplot. Only file output may be available, and 3D graphics may NOT work.")
### compile basic sources monolithically or not, make compilation slow
set(SPLIT_SOURCES_FILES ON CACHE BOOL "GDL: Force a single compilation for all templates, avoid symbol duplication")
#### Default cached values
set(GDLDEV OFF CACHE BOOL "GDL: Enable GDL developer mode (includes work-in-progress tests)")
set(PYTHON_MODULE OFF CACHE BOOL "GDL: Build GDL as a Python module ?")
set(X11 OFF CACHE BOOL "GDL: Enable X11 ?")
set(X11DIR "" CACHE PATH "GDL: Specify X11 directory tree")
# Only GNU Readline since May 2020 (too complex to manage BSD Editline. See #754)
set(READLINE ON CACHE BOOL "GDL: Enable GNU Readline ?")
set(READLINEDIR "" CACHE PATH "GDL: Specify the GNU Readline directory tree")
set(GSLDIR "" CACHE PATH "GDL: Specify the GSL directory tree")
set(ZLIBDIR "" CACHE PATH "GDL: Specify the Zlib directory tree")
set(WXWIDGETS ON CACHE BOOL "GDL: Enable WxWidgets ?")
set(WXWIDGETSDIR "" CACHE PATH "GDL: Specify WxWidgets directory tree")
set(UDUNITS2 ON CACHE BOOL "GDL: Enable UDUNITS-2 ?")
set(UDUNITS2DIR "" CACHE PATH "GDL: Specify the UDUNITS-2 directory tree")
set(EIGEN3 ON CACHE BOOL "GDL: Enable Eigen3 ?")
set(EIGEN3DIR "" CACHE PATH "GDL: Specify the Eigen3 directory tree")
set(PNGLIB ON CACHE BOOL "GDL: Enable libpng ?")
set(PNGLIBDIR "" CACHE PATH "GDL: Specify the libpng directory tree")
set(GRIB ON CACHE BOOL "GDL: Enable GRIB ?")
set(GRIBDIR "" CACHE PATH "GDL: Specify the ECMWF ecCodes directory tree")
set(QHULL ON CACHE BOOL "GDL: Enable Qhull ?")
set(QHULLDIR "" CACHE PATH "GDL: Specify the QHULL directory tree")
set(GLPK ON CACHE BOOL "GDL: Enable GLPK (for function SIMPLEX) ?")
set(GLPKDIR "" CACHE PATH "GDL: Specify the GLPK directory tree")
# GraphicsMagick is a good alternative to ImageMagick, if GM OK, we don't look for IM
set(GRAPHICSMAGICK ON CACHE BOOL "GDL: Enable GraphicsMagick ?")
set(GRAPHICSMAGICKDIR "" CACHE PATH "GDL: Specify the GraphicsMagick directory tree")
set(MAGICK ON CACHE BOOL "GDL: Enable ImageMagick ?")
set(MAGICKDIR "" CACHE PATH "GDL: Specify the ImageMagick directory tree")
set(TIFF ON CACHE BOOL "GDL: Enable libtiff ?")
set(TIFFDIR "" CACHE PATH "GDL: Specify the libtiff directory tree")
if(TIFF)
set(GEOTIFF ON CACHE BOOL "GDL: Enable libgeotiff ?")
set(GEOTIFFDIR "" CACHE PATH "GDL: Specify the libgeotiff directory tree")
endif(TIFF)
set(NETCDF ON CACHE BOOL "GDL: Enable NetCDF ?")
set(NETCDFDIR "" CACHE PATH "GDL: Specify the netCDF directory tree")
set(HDF ON CACHE BOOL "GDL: Enable HDF ?")
set(HDFDIR "" CACHE PATH "GDL: Specify the HDF directory tree")
set(HDF5 ON CACHE BOOL "GDL: Enable HDF5 ?")
set(HDF5DIR "" CACHE PATH "GDL: Specify the HDF5 directory tree")
set(FFTW ON CACHE BOOL "GDL: Enable FFTW ?")
set(FFTWDIR "" CACHE PATH "GDL: Specify the FFTW directory tree")
set(LIBPROJ ON CACHE BOOL "GDL: Enable PROJ ?")
set(LIBPROJDIR "" CACHE PATH "GDL: Specifiy the PROJ directory tree")
set(MPI OFF CACHE BOOL "GDL: Enable MPI ?")
set(MPIDIR "" CACHE PATH "GDL: Specify the MPI (experimental) directory tree")
set(PYTHON ON CACHE BOOL "GDL: Enable Python ?")
set(PYTHONDIR "" CACHE PATH "GDL: Specify the use Python directory tree")
set(PYTHONVERSION "" CACHE STRING "GDL: Specify the Python version to use")
set(SHAPELIB ON CACHE BOOL "GDL: Enable SHAPELIB (for IDLffShape, MAP_CONTINENTS and all geographic data?)")
set(SHAPELIBDIR "" CACHE PATH "GDL: Specify the SHAPELIB directory tree")
set(EXPAT ON CACHE BOOL "GDL: Enable EXPAT (for IDLffXMLSAX)")
set(EXPATDIR "" CACHE PATH "GDL: Specify the libEXPAT-devel directory tree")
if(NOT WIN32)
set(NCURSESDIR "" CACHE PATH "GDL: Specify the ncurses (or curses) directory tree")
endif(NOT WIN32)
set(OPENMP ON CACHE BOOL "GDL: Enable OpenMP ?")
# Third party libraries
set(JASPERDIR "" CACHE PATH "GDL: Specify the JasPer directory tree")
set(JPEGDIR "" CACHE PATH "GDL: Specify the JPEG directory tree")
set(SZIPDIR "" CACHE PATH "GDL: Specify the SZip directory tree")
set(GDL_DATA_DIR "/share/gnudatalanguage" CACHE PATH "GDL: data directory relative to CMAKE_INSTALL_PREFIX")
set(GDL_LIB_DIR "" CACHE PATH "GDL: library directory relative to CMAKE_INSTALL_PREFIX")
# check for 64-bit OS
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(HAVE_64BIT_OS 1)
endif(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
# check for endianness, and set macro in case it is big.
TEST_BIG_ENDIAN(IS_BIGENDIAN)
#### check headers and libraries
# dl
check_library_exists(dl dlopen "" HAVE_DL)
if(HAVE_DL)
set(LIBRARIES ${LIBRARIES} dl)
endif(HAVE_DL)
# malloc stats
check_function_exists(malloc_zone_statistics HAVE_MALLOC_ZONE_STATISTICS)
check_function_exists(sbrk HAVE_SBRK)
check_function_exists(mallinfo HAVE_MALLINFO)
check_function_exists(mallinfo2 HAVE_MALLINFO2)
# mallocs
check_include_file(malloc.h HAVE_MALLOC_H)
check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
# locale
check_include_file(locale.h HAVE_LOCALE_H)
# std includes..
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stdlib.h HAVE_STDLIB_H)
check_include_file(string.h HAVE_STRING_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(unistd.h HAVE_UNISTD_H)
#check_include_file(ext/stdio_filebuf.h HAVE_EXT_STDIO_FILEBUF_H)
#sometimes it compiles but stdio_filebuf is only in gcc-x-y-z directory tree...
# would be silly not to use this functionality if present, so recheck:
if (HAVE_EXT_STDIO_FILEBUF_H)
else (HAVE_EXT_STDIO_FILEBUF_H)
check_cxx_source_compiles("
#include <ext/stdio_filebuf.h>
int main(int argc, char **argv) {
int i=0;
i+=1;
}" REALLY_HAVE_EXT_STDIO_FILEBUF_H)
endif (HAVE_EXT_STDIO_FILEBUF_H)
if (REALLY_HAVE_EXT_STDIO_FILEBUF_H)
message(STATUS "INFO: will use GNU extensions for STDIO (useful for compressed I/O) since it seems accepted by your c++ compiler.")
set (HAVE_EXT_STDIO_FILEBUF_H 1)
endif (REALLY_HAVE_EXT_STDIO_FILEBUF_H)
# dlfcn.h
check_include_file(dlfcn.h HAVE_DLFCN_H)
# inttypes.h
check_include_file(inttypes.h HAVE_INTTYPES_H)
# nexttoward
check_library_exists(m nexttoward "" HAVE_NEXTTOWARD)
# mpi
check_include_file(mpi.h HAVE_MPI_H)
if (NOT WIN32)
# Ncurses MANDATORY for readline on POSIX
# -DNCURSESDIR=DIR
set(CMAKE_PREFIX_PATH ${NCURSESDIR})
set(CURSES_NEED_NCURSES TRUE)
find_package(Curses QUIET COMPONENTS initscr)
mark_as_advanced(CURSES_CURSES_H_PATH CURSES_FORM_LIBRARY CURSES_HAVE_CURSES_H)
if(CURSES_FOUND)
set(HAVE_LIBNCURSES 1)
set(LIBRARIES ${LIBRARIES} ${CURSES_LIBRARIES})
include_directories(${CURSES_INCLUDE_DIR})
else(CURSES_FOUND)
# search for curses
set(CURSES_NEED_NCURSES FALSE)
find_package(Curses COMPONENTS initscr)
set(HAVE_LIBCURSES ${CURSES_FOUND})
if(CURSES_FOUND)
set(LIBRARIES ${LIBRARIES} ${CURSES_LIBRARIES})
include_directories(${CURSES_INCLUDE_DIR})
else(CURSES_FOUND)
message(FATAL_ERROR "(N)Curses was not found.\n"
"Use -DNCURSESDIR=DIR to specify the curses directory tree.\n"
"(suitable Debian/Ubuntu package: libncurses-dev)\n")
endif(CURSES_FOUND)
endif(CURSES_FOUND)
endif (NOT WIN32)
# -DREADLINE=ON|OFF
# -DREADLINEDIR=DIR
if(READLINE)
set(CMAKE_PREFIX_PATH ${READLINEDIR})
find_package(Readline QUIET)
set(HAVE_LIBREADLINE ${READLINE_FOUND})
if(READLINE_FOUND)
if(NOT WIN32)
# readline needs (n)curses (not on Windows)
set(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARIES})
endif(NOT WIN32)
check_library_exists("${READLINE_LIBRARIES}" rl_get_screen_size "" RL_GET_SCREEN_SIZE)
if(NOT RL_GET_SCREEN_SIZE)
message(STATUS "WARNING: Older GNU readline without rl_get_screen_size was found.\n"
"For resized terminals the size might not be updated correctly.\n"
"If this is a problem please install a recent version of readline.")
endif(NOT RL_GET_SCREEN_SIZE)
set(LIBRARIES ${LIBRARIES} ${READLINE_LIBRARIES})
include_directories(${READLINE_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES)
else(READLINE_FOUND)
message(FATAL_ERROR "GNU readline was not found.\n"
"Use -DREADLINE=no to explicitely disable it.\n"
"(suitable Debian/Ubuntu package: libreadline-gplv2-dev or libreadline-dev)\n"
"(suitable Fedora/CentOS package: readline-devel)")
endif(READLINE_FOUND)
endif(READLINE)
# zlib MANDATORY
# -DZLIBDIR=DIR
set(CMAKE_PREFIX_PATH ${ZLIBDIR})
find_package(ZLIB QUIET)
set(HAVE_LIBZ ${ZLIB_FOUND})
if(ZLIB_FOUND)
set(LIBRARIES ${LIBRARIES} ${ZLIB_LIBRARIES})
include_directories(${ZLIB_INCLUDE_DIR})
else(ZLIB_FOUND)
message(FATAL_ERROR "ZLib library is required but was not found.\n"
"Use -DZLIBDIR=DIR to specify the zlib directory tree.\n"
"(suitable Debian/Ubuntu package: zlib1g-dev)\n"
"(suitable Fedora/CentOS package: zlib-devel)")
endif(ZLIB_FOUND)
# GSL MANDATORY
# -DGSLDIR=DIR
set(CMAKE_PREFIX_PATH ${GSLDIR})
find_package(GSL QUIET)
set(HAVE_LIBGSL ${GSL_FOUND})
set(HAVE_LIBGSLCBLAS ${GSL_FOUND})
if(GSL_FOUND)
set(LIBRARIES ${LIBRARIES} ${GSL_LIBRARIES})
include_directories(${GSL_INCLUDE_DIR})
else(GSL_FOUND)
message(FATAL_ERROR "Gnu Scientific library (1.7 or higher) and libgslcblas are mandatory.\n"
"Use -DGSLDIR=DIR to specify the gsl directory tree.\n"
"(suitable Debian/Ubuntu package: libgsl-dev)\n"
"(suitable Fedora/CentOS package: gsl-devel)")
endif(GSL_FOUND)
#RPC or XDR MANDATORY
if(UNIX)
set(CMAKE_PREFIX_PATH ${RPCDIR})
find_package(RPC QUIET)
set(HAVE_RPC ${RPC_FOUND})
if(RPC_FOUND)
set(LIBRARIES ${LIBRARIES} ${RPC_LIBRARIES})
include_directories(${RPC_INCLUDE_DIR})
else(RPC_FOUND)
message(FATAL_ERROR "RPC support is mandatory.\n"
"Note that SunRPC has been removed in glibc-2.26 and later, "
"while being optional in earlier versions. Consider using the "
"recommended and more modern libtirpc instead.\n"
"Use -DRPCDIR=DIR to specify the rpc directory tree.\n")
endif(RPC_FOUND)
elseif (WIN32)
set(CMAKE_PREFIX_PATH ${XDRDIR})
find_package(Xdr)
set(HAVE_LIBXDR ${XDR_FOUND})
if(XDR_FOUND)
set(LIBRARIES ${LIBRARIES} ${XDR_LIBRARIES})
include_directories(${XDR_INCLUDE_DIR})
else(XDR_FOUND)
message(FATAL_ERROR "bsd-xdr library is required but was not found.\n"
"Use -DXDRDIR=DIR to specify the bsd-xdr directory tree.")
endif(XDR_FOUND)
set(CMAKE_PREFIX_PATH ${PCREDIR})
find_package(PCRE)
set(HAVE_LIBPCRE ${PCRE_FOUND})
if(PCRE_FOUND)
set(LIBRARIES ${LIBRARIES} ${PCRE_LIBRARIES})
include_directories(${PCRE_INCLUDE_DIR})
else(PCRE_FOUND)
message(FATAL_ERROR "pcre library is required but was not found.\n"
"Use -DPCREDIR=DIR to specify the pcre directory tree.")
endif(PCRE_FOUND)
LINK_LIBRARIES(shlwapi)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
add_compile_options(-Wa,-mbig-obj)
message(STATUS "-Wa,-mbig-obj added to compiler options ")
endif()
endif()
if (NOT SPLIT_SOURCES_FILES)
set(ONE_DATAFILE 1)
endif (NOT SPLIT_SOURCES_FILES)
#---------------------------------------OPTIONAL MODULES----------------------
# libpng
# -DPNGLIB=ON|OFF
# -DPNGLIBDIR=DIR
if(PNGLIB)
set(CMAKE_PREFIX_PATH ${PNGLIBDIR})
find_package(PNG QUIET)
set(USE_PNGLIB ${PNG_FOUND})
if(PNG_FOUND)
set(LIBRARIES ${LIBRARIES} ${PNG_LIBRARIES})
set(LINK_DIRECTORIES ${LINK_DIRECTORIES} ${PNG_LIBRARY_DIRS})
include_directories(${PNG_INCLUDE_DIRS})
else(PNG_FOUND)
message(FATAL_ERROR "libpng is required but was not found.\n"
"Use -DPNGLIBDIR=DIR to specify the libpng directory tree.\n"
"Use -DPNGLIB=OFF to not use it.\n"
"(suitable Debian/Ubuntu package: libpng-dev)\n"
"(suitable Fedora/CentOS package: libpng-devel)")
endif(PNG_FOUND)
endif(PNGLIB)
# openmp
# -DOPENMP=ON|OFF
if(OPENMP)
find_package(OpenMP QUIET)
set(USE_OPENMP ${OPENMP_FOUND})
if(OPENMP_FOUND)
if(MSVC)
set(LIBRARIES ${LIBRARIES} vcomp)
elseif(WIN32)
set(LIBRARIES ${LIBRARIES} gomp pthread)
else()
set(LIBRARIES ${LIBRARIES} ${OpenMP_CXX_FLAGS})
endif()
if(APPLE)
link_directories(/usr/local/lib)
endif()
else(OPENMP_FOUND)
message(FATAL_ERROR "Your compiler does not support OpenMP or OpenMP was not found"
"note that disabling OpenMP will incur significant performance penalty !\n"
"Use -DCMAKE_CXX_COMPILER=PATH and -DCMAKE_C_COMPILER=PATH to specify the compiler path."
"(find_package(OpenMP) will find OpenMP only if both are set !)\n"
"Use -DOPENMP=OFF to not use it.\n"
"(suitable Homebrew compiler package: llvm)"
"(suitable Homebrew library package: libomp)")
endif(OPENMP_FOUND)
else(OPENMP)
# we need to define those semaphore posix symbols, do it with threads libs
find_package(Threads)
if(THREADS_FOUND)
set(LIBRARIES ${LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
else(THREADS_FOUND)
check_library_exists(rt sem_unlink "" HAVE_RT)
if(HAVE_RT)
set(LIBRARIES ${LIBRARIES} rt)
else(HAVE_RT)
message(FATAL_ERROR "Missing a POSIX semaphore symbols (rt or threads).\n")
endif(HAVE_RT)
endif(THREADS_FOUND)
endif(OPENMP)
# wxWidgets: should be the one graphics library. Presence test is 'WXWIDGETS_FOUND'
#
# I suggest to have wxWidgets a 'main' dependency.
# thus removing the need of X11 for unix/linux/MacOS, as well as xwin and wingcc/wingdi.
# Behavior of plots, either in a WIDGET_DRAW or in a WINDOW, will be identical.
# Provided wxWidgets library exist, the graphic device will be 'X' on all platforms.
#
# -DWXWIDGETS=ON|OFF
# -DWXWIDGETSDIR=DIR
if(WXWIDGETS)
set(CMAKE_PREFIX_PATH ${WXWIDGETSDIR})
find_package(wxWidgets 3.0.0 COMPONENTS base core adv )
set(HAVE_LIBWXWIDGETS ${WXWIDGETS_FOUND})
if(WXWIDGETS_FOUND)
set(LIBRARIES ${LIBRARIES} ${wxWidgets_LIBRARIES})
set(LINK_DIRECTORIES ${LINK_DIRECTORIES} ${wxWidgets_LIBRARY_DIRS})
foreach(WXDEF ${wxWidgets_DEFINITIONS})
add_definitions(-D${WXDEF})
endforeach(WXDEF ${wxWidgets_DEFINITIONS})
include_directories(${wxWidgets_INCLUDE_DIRS})
#plplot-minimum: enable wxwidgets static driver
set (PLD_wxwidgets ON)
else(WXWIDGETS_FOUND)
message(FATAL_ERROR "wxWidgets are required but were not found.\n"
"Use -DWXWIDGETSDIR=DIR to specify the wxWidgets directory tree.\n"
"Use -DWXWIDGETS=OFF to not use it.\n"
"(suitable Debian/Ubuntu package: libwxgtk3.0-gtk3-dev)\n"
"(suitable Fedora/CentOS package: wxGTK-devel)")
set (PLD_wxwidgets OFF)
endif(WXWIDGETS_FOUND)
else (WXWIDGETS)
if (INTERACTIVE_GRAPHICS AND WIN32)
message(FATAL_ERROR "wxWidgets are required on Windows.")
endif (INTERACTIVE_GRAPHICS AND WIN32)
#forcibly not used, no need to build and install our own copy of drivers, below
set (PLD_wxwidgets OFF)
endif(WXWIDGETS)
# X11 : OFF by default since wxWidgets SHOULD take preference in ALL builds.
# Note that X11 is not present under native WIN32. Presence test is 'X11_FOUND'
if(CYGWIN OR NOT WIN32)
if(X11)
set(CMAKE_PREFIX_PATH ${X11DIR})
find_package(X11 QUIET)
set(HAVE_X ${X11_FOUND})
if(X11_FOUND)
set(LIBRARIES ${LIBRARIES} ${X11_LIBRARIES})
include_directories(${X11_INCLUDE_DIR})
#plplot-minimum: enable xwin static driver
set (PLD_xwin ON)
else(X11_FOUND)
message(FATAL_ERROR "X11 is required but was not found.\n"
"Use -DX11DIR=DIR to specify the X11 directory tree.\n"
"Use -DX11=OFF to not use it.\n"
"(suitable Fedora/CentOS package xorg-x11-devel)\n")
set (PLD_xwin OFF)
endif(X11_FOUND)
else(X11)
set (PLD_xwin OFF)
endif(X11)
if (X11_FOUND AND NOT WXWIDGETS_FOUND)
message(STATUS "WARNING: GDL is BEST with wxWidgets instead of X11, please consider installing wxWidgets")
endif (X11_FOUND AND NOT WXWIDGETS_FOUND)
else(CYGWIN OR NOT WIN32)
set (PLD_xwin OFF)
endif(CYGWIN OR NOT WIN32)
# GraphicsMagick (GM) is an alternative to the classical ImageMagick Lib (IM).
# It was experienced that GM was more stable in time than IM
#
# -DGRAPHICSMAGICK=ON|OFF
# -DGRAPHICSMAGICKDIR=DIR
#
if(GRAPHICSMAGICK)
set(CMAKE_PREFIX_PATH ${GRAPHICSMAGICKDIR})
find_package(GraphicsMagick QUIET)
set(USE_MAGICK ${GRAPHICSMAGICK_FOUND})
if(GRAPHICSMAGICK_FOUND)
include_directories(${GRAPHICSMAGICK_INCLUDE_DIR})
set(LIBRARIES ${LIBRARIES} ${GRAPHICSMAGICK_LIBRARIES})
else(GRAPHICSMAGICK_FOUND)
message( STATUS
"GRAPHICSMAGICK is strongly suggested but was not found.
Use -DGRAPHICSMAGICKDIR=DIR to specify the GraphicsMagick directory tree.
Use -DGRAPHICSMAGICK=OFF to not use it.
(suitable Fedora/CentOS package: GraphicsMagick-c++-devel
Debian/Ubuntu package: libgraphicsmagick++1-dev)\n")
message( STATUS
"Looking for ImageMagick")
endif(GRAPHICSMAGICK_FOUND)
endif(GRAPHICSMAGICK)
#
# if GM found, we do not look for IM
#
if(GRAPHICSMAGICK_FOUND)
if (MAGICK)
message(STATUS "INFO: We prefer to use GraphicsMagick than ImageMagick")
set(MAGICK OFF)
endif(MAGICK)
endif(GRAPHICSMAGICK_FOUND)
# ImageMagick
# -DMAGICK=ON|OFF
# -DMAGICKDIR=DIR
if(MAGICK)
set(CMAKE_PREFIX_PATH ${MAGICKDIR})
find_package(ImageMagick QUIET COMPONENTS Magick++ MagickWand MagickCore)
mark_as_advanced(ImageMagick_EXECUTABLE_DIR ImageMagick_Magick++_INCLUDE_DIR ImageMagick_Magick++_LIBRARY
ImageMagick_MagickCore_INCLUDE_DIR ImageMagick_MagickCore_LIBRARY ImageMagick_MagickWand_INCLUDE_DIR ImageMagick_MagickWand_LIBRARY)
set(USE_MAGICK ${ImageMagick_FOUND})
set(HAS_IMAGEMAGICK ${ImageMagick_FOUND})
if(ImageMagick_FOUND)
find_program(MAGICKXXCONFIG Magick++-config)
if(MAGICKXXCONFIG)
execute_process(COMMAND ${MAGICKXXCONFIG} "--libs" OUTPUT_VARIABLE MAGICKXXCONFIGLIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LIBRARIES ${LIBRARIES} ${MAGICKXXCONFIGLIBS})
execute_process(COMMAND ${MAGICKXXCONFIG} "--cxxflags" OUTPUT_VARIABLE MAGICKXXCONFIGCXXFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MAGICKXXCONFIGCXXFLAGS}")
else(MAGICKXXCONFIG)
message(FATAL_ERROR "ImageMagick is required but was not found (Magick++-config).\n"
"Use -DMAGICKDIR=DIR to specify the ImageMagick directory.\n"
"Use -DMAGICK=OFF to not use it.\n"
"(suitable Debian/Ubuntu package: libmagick++-dev)\n"
"(suitable Fedora/CentOS package: ImageMagick-c++-devel)")
endif(MAGICKXXCONFIG)
set(LIBRARIES ${LIBRARIES} ${ImageMagick_LIBRARIES})
include_directories(${ImageMagick_INCLUDE_DIRS} ${ImageMagick_MagickCore_INCLUDE_DIRS})
set(MAGICK_LIBRARIES ${ImageMagick_LIBRARIES})
else(ImageMagick_FOUND)
message(FATAL_ERROR "ImageMagick is required but was not found.\n"
"Use -DMAGICKDIR=DIR to specify the ImageMagick directory.\n"
"Use -DMAGICK=OFF to not use it.\n"
"(suitable Debian/Ubuntu package: libmagick++-dev)\n"
"(suitable Fedora/CentOS package: ImageMagick-c++-devel)")
endif(ImageMagick_FOUND)
endif(MAGICK)
# libtiff
# -DTIFF=ON|OFF
# -DTIFFDIR=DIR
if(TIFF)
set(CMAKE_PREFIX_PATH ${TIFFDIR})
find_package(TIFF 4.0.3 QUIET)
set(USE_TIFF ${TIFF_FOUND})
if(TIFF_FOUND)
include_directories(${TIFF_INCLUDE_DIR})
set(LIBRARIES ${LIBRARIES} ${TIFF_LIBRARIES})
else(TIFF_FOUND)
message(FATAL_ERROR
"libtiff v4.0.3 or newer is required for TIFF support but was not found.\n"
"Use -DTIFFDIR=DIR to specify the libtiff directory tree.\n"
"Use -DTIFF=OFF to not use it.")
endif(TIFF_FOUND)
endif(TIFF)
# libgeotiff
# -DGEOTIFF=ON|OFF
# -DGEOTIFFDIR=DIR
if(GEOTIFF AND USE_TIFF)
set(CMAKE_PREFIX_PATH ${GEOTIFFDIR})
find_package(GeoTIFF QUIET)
set(USE_GEOTIFF ${GEOTIFF_FOUND})
if(GEOTIFF_FOUND)
include_directories(${GEOTIFF_INCLUDE_DIR})
set(LIBRARIES ${LIBRARIES} ${GEOTIFF_LIBRARIES})
else(GEOTIFF_FOUND)
message(FATAL_ERROR
"libgeotiff is required for GeoTIFF support but was not found.\n"
"Use -DGEOTIFFDIR=DIR to specify the libgeotiff directory tree.\n"
"Use -DGEOTIFF=OFF to not use it.\n"
"(suitable Debian/Ubuntu package: libgeotiff-dev)\n"
"(suitable Fedora/CentOS package: libgeotiff-devel)")
endif(GEOTIFF_FOUND)
endif(GEOTIFF AND USE_TIFF)
# netCDF
# -DNETCDF=ON|OFF
# -DNETCDFDIR=DIR
if(NETCDF)
set(CMAKE_PREFIX_PATH ${NETCDFDIR})
find_package(NetCDF QUIET)
if(NETCDF_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${NETCDF_INCLUDE_DIRS})
check_include_file_cxx(netcdf.h HAVE_NETCDF_H)
if(HAVE_NETCDF_H)
set(LIBRARIES ${LIBRARIES} ${NETCDF_LIBRARIES})
set(LINK_DIRECTORIES ${LINK_DIRECTORIES} ${NETCDF_LIBRARY_DIRS})
include_directories(${NETCDF_INCLUDE_DIRS})
set(USE_NETCDF 1)
else(HAVE_NETCDF_H)
message(FATAL_ERROR "NetCDF installation seems not to be usable.\n"
"This suggests a conflicting netCDF-HDF4 installation e.g.\n"
"- Uninstalling HDF4 after installation of NetCDF.\n"
"- Installing NetCDF before HDF4.")
endif(HAVE_NETCDF_H)
set(CMAKE_REQUIRED_INCLUDES)
#
# are extensions NetCDF-4 available ??
check_library_exists("${NETCDF_LIBRARIES}" nc_inq_grps "" HAVE_NETCDF4)
if(HAVE_NETCDF4)
set(USE_NETCDF4 1)
else(HAVE_NETCDF4)
message(STATUS "warning, you don't have NetCDF-4 version\n"
"some new NetCDF capabilities in NetCDF-4 (related to Groups) will not be usable")
endif(HAVE_NETCDF4)
else(NETCDF_FOUND)
message(FATAL_ERROR "NetCDF version 3.5.1 or later is required but was not found.\n"
"Use -DNETCDFDIR=DIR to specify the netcdf directory tree.\n"
"Use -DNETCDF=OFF to not use it.\n"
"(suitable Debian/Ubuntu package: libnetcdf-dev)\n"
"(suitable Fedora/CentOS package: netcdf-devel)")
endif(NETCDF_FOUND)
endif(NETCDF)
# hdf4
# -DHDF=ON|OFF
# -DHDFDIR=DIR
if(HDF)
set(CMAKE_PREFIX_PATH ${HDFDIR} ${JPEGDIR} ${SZIPDIR})
find_package(HDF QUIET)
set(USE_HDF ${HDF_FOUND})
if(HDF_FOUND)
if(NETCDF)
set(CMAKE_REQUIRED_LIBRARIES ${HDF_EXTRA_LIBRARIES})
check_library_exists("${HDF_LIBRARIES};${RPC_LIBRARIES}" sd_nccreate "" SD_NCCREATE)
if(NOT SD_NCCREATE)
message(FATAL_ERROR "HDF4 needs to be configured with the --disable-netcdf option "
"in order to be used with the original netCDF library.")
endif(NOT SD_NCCREATE)
set(CMAKE_REQUIRED_LIBRARIES)
endif(NETCDF)
set(HDF_LIBRARIES ${HDF_LIBRARIES} ${HDF_EXTRA_LIBRARIES})
set(LIBRARIES ${LIBRARIES} ${HDF_LIBRARIES})
include_directories(${HDF_INCLUDE_DIR})
else(HDF_FOUND)
message(FATAL_ERROR "HDF4 libraries were not found.\n"
"Use -DHDFDIR=DIR to specify the HDF directory tree.\n"
"Use -DHDF=OFF to not use it.\n"
"(suitable Debian/Ubuntu package: libhdf4-alt-dev)\n"
"(suitable Fedora/CentOS package: hdf-devel)\n"
"You can use -DJPEGDIR=DIR to specify the JPEG directory tree. "
"You can also use -DSZIPDIR=DIR to specify SZip directory tree if "
"HDF was compiled with SZip support.")
endif(HDF_FOUND)
endif(HDF)
# hdf5
# -DHDF5=ON|OFF
# -DHDF5DIR=DIR
if(HDF5)
set(CMAKE_PREFIX_PATH ${HDF5DIR} ${SZIPDIR})
find_package(HDF5 QUIET)
set(USE_HDF5 ${HDF5_FOUND})
if(HDF5_FOUND)
set(LIBRARIES ${LIBRARIES} ${HDF5_LIBRARIES})
include_directories(${HDF5_INCLUDE_DIRS})
find_package(MPI QUIET)
if(MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH})
set(LIBRARIES ${LIBRARIES} ${MPI_LIBRARIES})
endif(MPI_FOUND)
else(HDF5_FOUND)
message(FATAL_ERROR "HDF version 5 is required but was not found.\n"
"Use -DHDF5DIR=DIR to specify the HDF5 directory tree.\n"
"Use -DHDF5=OFF to not use it.\n"
"(suitable Debian/Ubuntu package: libhdf5-serial-dev)\n"
"(suitable Fedora/CentOS package: hdf5-devel)")
endif(HDF5_FOUND)
endif(HDF5)
# fftw
# -DFFTW=ON|OFF
# -DFFTWDIR=DIR
if(FFTW)
set(CMAKE_PREFIX_PATH ${FFTWDIR})
find_package(FFTW QUIET)
set(USE_FFTW ${FFTW_FOUND})
if(FFTW_FOUND)
set(LIBRARIES ${LIBRARIES} ${FFTW_LIBRARIES})
include_directories(${FFTW_INCLUDE_DIR})
else(FFTW_FOUND)
message(FATAL_ERROR "FFTW3 is required but was not found.\n"
"Use -DFFTWDIR=DIR to specify the FFTW directory tree.\n"
"Use -DFFTW=OFF to not use it.\n"
"(suitable Debian/Ubuntu package: libfftw3-dev)\n"
"(suitable Fedora/CentOS package: fftw-devel)")
endif(FFTW_FOUND)
endif(FFTW)
# PROJ
# -DLIBPROJ=ON|OFF
# -DLIBPROJDIR=DIR
if(LIBPROJ)
set(CMAKE_PREFIX_PATH ${LIBPROJDIR})
find_package(LIBPROJ)
set(USE_LIBPROJ ${LIBPROJ_FOUND})
if(LIBPROJ_FOUND)
set(LIBRARIES ${LIBRARIES} ${LIBPROJ_LIBRARIES})
include_directories(${LIBPROJ_INCLUDE_DIR})
set(LIBPROJ_MAJOR_VERSION ${LIBPROJ_MAJOR_VERSION})
else(LIBPROJ_FOUND)
message(FATAL_ERROR "PROJ is required but was not found.\n"
"Use -DLIBPROJDIR=DIR to specify the PROJ directory tree.\n"
"Use -DLIBPROJ=OFF to not use it.\n"
"(suitable Debian/Ubuntu package: libproj-dev)\n"
"(suitable Fedora/CentOS package: proj-devel)")
endif(LIBPROJ_FOUND)
endif(LIBPROJ)
# MPI (experimental)
# -DMPI=ON|OFF
# -DMPIDIR=DIR
if(MPI)
set(CMAKE_PREFIX_PATH ${MPIDIR})
find_package(MPI QUIET)
set(USE_MPI ${MPI_FOUND})
if(MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH})
set(LIBRARIES ${LIBRARIES} ${MPI_LIBRARIES})
else(MPI_FOUND)
message(FATAL_ERROR "MPI is required but was not found.\n"
"(on Fedora, running `module load mpi` is required prior to run CMake)\n"
"Use -DMPIDIR=DIR to specify the MPI directory tree.\n"
"Use -DMPI=OFF to not use it.")
endif(MPI_FOUND)
endif(MPI)
# python
# -DPYTHON=ON|OFF
# -DPYTHON_MODULE
# -DPYTHONDIR=DIR
# -DPYTHONVERSION=VERSION
if(PYTHON OR PYTHON_MODULE)
if(PYTHON)
set(PYTHONMSG "Use -DPYTHON=OFF to disable Python support.\n")
endif(PYTHON)
if(PYTHON_MODULE)
set(PYTHON_MODULEMSG "Use -DPYTHON_MODULE=OFF to disable Python module.\n")
endif(PYTHON_MODULE)
if (${CMAKE_VERSION} VERSION_LESS "3.14")
if (DEFINED ENV{PYTHON_EXECUTABLE})
set(PYTHON_EXECUTABLE $ENV{PYTHON_EXECUTABLE})
endif()
find_package(PythonInterp ${PYTHONVERSION})
find_package(PythonLibs ${PYTHONVERSION})
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import numpy as np; print(np.get_include())" RESULT_VARIABLE ret OUTPUT_VARIABLE Python_NumPy_INCLUDE_DIRS ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
set(Python_LIBRARIES ${PYTHON_LIBRARIES})
set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})
set(Python_Interpreter_FOUND ${PYTHONINTERP_FOUND})
set(Python_Development_FOUND ${PYTHONLIBS_FOUND})
endif()
if (ret EQUAL 0)
set(Python_NumPy_FOUND TRUE)
endif()
else()
if (DEFINED ENV{PYTHON_EXECUTABLE})
set(Python_EXECUTABLE $ENV{PYTHON_EXECUTABLE})
endif()
find_package(Python ${PYTHONVERSION} COMPONENTS Interpreter Development NumPy)
endif()
if(Python_Interpreter_FOUND AND Python_Development_FOUND)
if(NOT Python_NumPy_FOUND)
message(FATAL_ERROR "Python NumPy package was not found.\n"
"${PYTHONMSG} ${PYTHON_MODULEMSG}")
endif()
set(USE_PYTHON ${Python_NumPy_FOUND})
set(LIBRARIES ${LIBRARIES} ${Python_LIBRARIES})
include_directories(${Python_INCLUDE_DIRS} ${Python_NumPy_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Python is required but was not found.\n"
"Use -DPYTHONDIR=DIR to specify the Python directory tree.\n"
"Use -DPYTHONVERSION=VERSION to help searching for the right version.\n"
"(suitable Debian/Ubuntu package: python-dev)\n"
"(suitable Fedora/CentOS package: python-devel)\n"
"${PYTHONMSG} ${PYTHON_MODULEMSG}")
endif()
endif(PYTHON OR PYTHON_MODULE)
# udunits-2
# -DUDUNITS2=ON|OFF
# -DUDUNITS2DIR=DIR
if(UDUNITS2)
set(CMAKE_PREFIX_PATH ${UDUNITS2DIR})
find_package(Udunits2 QUIET)
set(USE_UDUNITS ${UDUNITS2_FOUND})
if(UDUNITS2_FOUND)
set(LIBRARIES ${LIBRARIES} ${UDUNITS2_LIBRARIES})
include_directories(${UDUNITS2_INCLUDE_DIR})
else(UDUNITS2_FOUND)
message(FATAL_ERROR "UDUNITS-2 is required but was not found.\n"
"Use -DUDUNITS2DIR=DIR to specify the Udunits2 directory tree.\n"
"Use -DUDUNITS2=OFF to not use it.\n"
"(suitable Debian/Ubuntu package: libudunits2-dev)\n"
"(suitable Fedora/CentOS package: udunits2-devel)")
endif(UDUNITS2_FOUND)
endif(UDUNITS2)
# eigen3
# -DEIGEN3=ON|OFF
# -DEIGEN3DIR=DIR
if(EIGEN3)
# cleaning Cache ...
if (EIGEN3DIR)
unset(EIGEN3_INCLUDE_DIR CACHE)
endif(EIGEN3DIR)
#
set(CMAKE_PREFIX_PATH ${EIGEN3DIR})
find_package(Eigen3 3.2.4 QUIET)
if(EIGEN3_TOO_OLD)
# on iCore 3/5/7 we must have Eigen >=3.2.4 to avoid fatal error in "test_matrix_multiply.pro"
message(FATAL_ERROR "\nEIGEN3 is required but the version found is TOO OLD."
" Please download a recent version (>=3.2.4) in a local directory."
" Then use -DEIGEN3DIR=DIR to specify the Eigen3 local directory tree.\n"
"Use -DEIGEN3=OFF to not use it.\n")
else(EIGEN3_TOO_OLD)
set(USE_EIGEN ${EIGEN3_FOUND})
if(EIGEN3_FOUND)
include_directories(${EIGEN3_INCLUDE_DIR})
if(MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-ipa-cp-clone")
endif(MINGW)
else(EIGEN3_FOUND)
message(FATAL_ERROR "EIGEN3 is required but was not found.\n"
"Use -DEIGEN3DIR=DIR to specify the Eigen3 directory tree.\n"
"Use -DEIGEN3=OFF to not use it.\n"
"(suitable Fedora/CentOS package: eigen3-devel)\n"
"(suitable Debian/Ubuntu package: libeigen3-dev)")
endif(EIGEN3_FOUND)
endif(EIGEN3_TOO_OLD)
endif(EIGEN3)
# grib
# -DGRIB=ON|OFF
# -DGRIBDIR=DIR
if(GRIB)
set(CMAKE_PREFIX_PATH ${GRIBDIR} ${JASPERDIR} ${JPEGDIR})
find_package(Grib QUIET)
set(USE_GRIB ${GRIB_FOUND})
if(GRIB_FOUND)
set(LIBRARIES ${LIBRARIES} ${GRIB_LIBRARIES})
include_directories(${GRIB_INCLUDE_DIR})
else(GRIB_FOUND)
message(FATAL_ERROR "ECMWF ecCodes is required but was not found.\n"
"Use -DGRIBDIR=DIR to specify the ecCodes or GRIB API directory tree.\n"
"Use -DGRIB=OFF to not use it.\n"
"Use -DJASPERDIR=DIR and|or -DJPEGDIR=DIR to specify "
"the directory trees of JasPer and openJPEG libraries.\n"
"(suitable Debian/Ubuntu package: libeccodes-dev)\n"
"(suitable Fedora/CentOS package: eccodes-devel)\n"
"(suitable Homebrew package: eccodes)\n")
endif(GRIB_FOUND)
endif(GRIB)
# Qhull (enable TRIANGULATE and QHULL commands)
# -DQHULL=ON|OFF
# -DQHULLDIR=DIR
if(QHULL)
set(CMAKE_PREFIX_PATH ${QHULLDIR})
find_package(QHULL QUIET)
set(HAVE_QHULL ${QHULL_FOUND})
set(USE_QHULL ${QHULL_FOUND})
if(QHULL_FOUND)
set(LIBRARIES ${LIBRARIES} ${QHULL_LIBRARIES})
include_directories(${QHULL_INCLUDE_DIR})
else(QHULL_FOUND)
message(FATAL_ERROR "QHULL is required but was not found.\n"
"Use -DQHULLDIR=DIR to specify the QHULL directory tree.\n"
"Use -DQHULL=OFF to not use it.\n"
"(suitable Fedora/CentOS package libqhull-devel)\n"
"(suitable Homebrew package: qhull)\n"
"On some Ubuntu distributions this library is missing from the apt package.\n"
"You might need to compile Qhull from github source (https://github.com/qhull/qhull)\n"
"and specify the directory to cmake with option -DQHULLDIR"
)
endif(QHULL_FOUND)
endif(QHULL)
# GLPK for Simplex ( Linear programming )
# GLPK (enable SIMPLEX command)
# -DGLPK=ON|OFF
# -DGLPKDIR=DIR
if(GLPK)
set(CMAKE_PREFIX_PATH ${GLPKDIR})
find_package(GLPK QUIET)
set(USE_GLPK ${GLPK_FOUND})
if(GLPK_FOUND)
set(LIBRARIES ${LIBRARIES} ${GLPK_LIBRARIES})
include_directories(${GLPK_INCLUDE_DIR})
else(GLPK_FOUND)
message(FATAL_ERROR "GLPK (Gnu Linear Programming Kit) is required but was not found.\n"
"Use -DGLPKDIR=DIR to specify the GLPK-devel directory tree.\n"
"Use -DGLPK=OFF to not use it.\n"
"(suitable Debian/Ubuntu package: libglpk-dev)\n"
"(suitable Fedora/CentOS package: glpk-devel)\n")
endif(GLPK_FOUND)
endif(GLPK)
#check_include_file(glpk.h HAVE_GLPK)
# SHAPELIB for all geo/gra/phy/sical data (shapelib format, IDLffShape
# -DSHAPELIB=ON|OFF
# -DSHAPELIBDIR=DIR
if(SHAPELIB)
set(CMAKE_PREFIX_PATH ${SHAPELIBDIR})
find_package(SHAPELIB QUIET)
set(USE_SHAPELIB ${SHAPELIB_FOUND})
if(SHAPELIB_FOUND)
set(LIBRARIES ${LIBRARIES} ${SHAPELIB_LIBRARIES})
include_directories(${SHAPELIB_INCLUDE_DIR})
else(SHAPELIB_FOUND)
message(FATAL_ERROR "SHAPELIB (http://shapelib.maptools.org/) is required but was not found.\n"
"Use -DSHAPELIBDIR=DIR to specify the SHAPELIB-devel directory tree.\n"
"Use -DSHAPELIB=OFF to not use it.\n"
"shapelib is often in package libshp-devel.\n"
"(suitable Debian/Ubuntu package: libshp-dev)\n"
"(suitable Fedora/CentOS package: shapelib-devel)\n")
endif(SHAPELIB_FOUND)
endif(SHAPELIB)
# EXPAT for IDLffXMLSAX and IDLffXMLDOM
# -DEXPAT=ON|OFF
# -DEXPATDIR=DIR
if(EXPAT)
set(CMAKE_PREFIX_PATH ${EXPATDIR})
find_package(EXPAT QUIET)
set(USE_EXPAT ${EXPAT_FOUND})
if(EXPAT_FOUND)
set(LIBRARIES ${LIBRARIES} ${EXPAT_LIBRARIES})
include_directories(${EXPAT_INCLUDE_DIR})
else(EXPAT_FOUND)
message(FATAL_ERROR "EXPAT is required but was not found.\n"
"Use -DEXPATDIR=DIR to specify the LibXML2-devel directory tree.\n"
"Use -DEXPAT=OFF to not use it.\n"
"EXPAT is often in package libEXPAT-devel."
"(suitable Debian/Ubuntu package: libexpat1-dev)\n"
"(suitable Fedora/CentOS package: expat-devel)\n")
endif(EXPAT_FOUND)
endif(EXPAT)
#currently duplicates src/plplot/modules/freetype as
find_package(Freetype)
if (FREETYPE_FOUND)
set(LIBRARIES ${LIBRARIES} ${FREETYPE_LIBRARIES})
include_directories(${FREETYPE_INCLUDE_DIRS})
message(STATUS "Found Freetype.")
endif(FREETYPE_FOUND)
#plplot minimum local
set (ENABLE_cxx ON)
#add_subdirectory(src/plplot)
#rest of gdl
add_subdirectory(src)
if (TARGET version)
add_dependencies(gdl version)
endif()
add_subdirectory(testsuite)
install(FILES ${CMAKE_SOURCE_DIR}/AUTHORS ${CMAKE_SOURCE_DIR}/README DESTINATION ${CMAKE_INSTALL_PREFIX}/${GDL_DATA_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/doc/gdl.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1)
# substitute variables in config.h.cmake and move it to config.h
configure_file(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
# display macro
macro(MODULE MOD LIBNAME NAME)
if(${MOD})
if(${LIBNAME}_INCLUDE_DIR)
message("${NAME} ON (libs:${${LIBNAME}_LIBRARIES}; headers:${${LIBNAME}_INCLUDE_DIR})")
else()
message("${NAME} ON (libs:${${LIBNAME}_LIBRARIES}; headers:${${LIBNAME}_INCLUDE_DIRS})")
endif()
else(${MOD})
message("${NAME} OFF")
endif(${MOD})
endmacro(MODULE)
# python
if(PYTHON_MODULE)
set(BUILDTYPE "Python Module")
else(PYTHON_MODULE)
set(BUILDTYPE "Standalone")
endif(PYTHON_MODULE)
#
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
if(MSVC)
SET(MACHINE_ARCH ${MSVC_C_ARCHITECTURE_ID})
IF(NOT MACHINE_ARCH)
SET(MACHINE_ARCH ${MSVC_CXX_ARCHITECTURE_ID})
ENDIF(NOT MACHINE_ARCH)
set_target_properties(gdl PROPERTIES LINK_FLAGS "/machine:${MACHINE_ARCH}")
endif(MSVC)
# AC, 12-oct-2011, solved by Marc
# set_target_properties(gdl PROPERTIES LINK_FLAGS "-Wl,-z,muldefs")
# set_target_properties(gdl PROPERTIES LINK_FLAGS "-z muldefs")
#
if(CMAKE_BUILD_TYPE STREQUAL None OR NOT CMAKE_BUILD_TYPE)
set(FLAGS ${CMAKE_CXX_FLAGS})
elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
# set(FLAGS ${CMAKE_CXX_FLAGS_DEBUG})
set(FLAGS "-O1 -g") # fix for 'file too big'
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
set(FLAGS ${CMAKE_CXX_FLAGS_RELEASE})
elseif(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
set(FLAGS ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
elseif(CMAKE_BUILD_TYPE STREQUAL MinSizeRel)
set(FLAGS ${CMAKE_CXX_FLAGS_MINSIZEREL})
endif(CMAKE_BUILD_TYPE STREQUAL None OR NOT CMAKE_BUILD_TYPE)
message(STATUS
"Summary
GDL - GNU DATA LANGUAGE [${BUILDTYPE}]
System ${CMAKE_HOST_SYSTEM}
Files generated ${CMAKE_GENERATOR}
Installation prefix ${CMAKE_INSTALL_PREFIX}
C++ compiler ${CMAKE_CXX_COMPILER} ${FLAGS}")
message("")
message(STATUS "Options")
message("")
message("Interactive plots: ${INTERACTIVE_GRAPHICS}")
message("Widgets support: ${WXWIDGETS_FOUND}")
message("")
if(OPENMP AND OPENMP_FOUND)
message("OpenMP support ON (flag: ${OpenMP_CXX_FLAGS})")
else(OPENMP AND OPENMP_FOUND)
message("OpenMP support OFF")
endif(OPENMP AND OPENMP_FOUND)
module(WXWIDGETS wxWidgets "WxWidgets ")
if (GRAPHICSMAGICK_FOUND)
module(GRAPHICSMAGICK GRAPHICSMAGICK "GRAPHICSMAGICK")
else (GRAPHICSMAGICK_FOUND)
module(MAGICK MAGICK "ImageMagick ")
endif (GRAPHICSMAGICK_FOUND)
module(TIFF TIFF "TIFF ")
module(GEOTIFF GEOTIFF "GeoTIFF ")
module(NETCDF NETCDF "NetCDF ")
module(HDF HDF "HDF4 ")
module(HDF5 HDF5 "HDF5 ")
module(FFTW FFTW "FFTW ")
module(MPI MPI "MPI ")
module(LIBPROJ LIBPROJ "PROJ ")
module(PYTHON Python "Python ")
module(UDUNITS2 UDUNITS2 "UDUNITS-2 ")
module(EIGEN3 EIGEN3 "EIGEN3 ")
module(GRIB GRIB "GRIB ")
module(QHULL QHULL "QHULL ")
module(GLPK GLPK "GLPK ")
module(SHAPELIB SHAPELIB "SHAPELIB ")
module(EXPAT EXPAT "EXPAT ")
if (INTERACTIVE_GRAPHICS)
if( CYGWIN OR NOT WIN32 )
module(X11 X11 "Xlib ")
endif( CYGWIN OR NOT WIN32)
endif (INTERACTIVE_GRAPHICS)
module(PNGLIB PNG "libpng ")
message("")
message(STATUS "Mandatory modules")
set(READLINE ON)
set(GSL ON)
set(ZLIB ON)
if(NOT WIN32)
set(CURSES ON)
set(RPC ON)
endif(NOT WIN32)
module(READLINE READLINE "GNU Readline ")
module(GSL GSL "GSL ")
module(ZLIB ZLIB "Zlib ")
if(NOT WIN32)
module(CURSES CURSES "(N)curses ")
module(RPC RPC "RPC ")
endif(NOT WIN32)
message("")
message("GDLDEV mode: ${GDLDEV} (use -DGDLDEV=ON to enable work-in-progress tests)")
if (NOT SPLIT_SOURCES_FILES)
message("Not splitting some template definition for quick compilation.")
endif (NOT SPLIT_SOURCES_FILES)
message("")
# do we have a Conda env. around ? see issues #780
if ((DEFINED ENV{CONDA_PREFIX}) OR (DEFINED ENV{CONDA_EXE}))
message("==========================================================================\n"
"== WARNING !! {Ana|mini|}conda activated env. detected ! ==\n"
"== To avoid possible conflicts between local libs. and the sytem libs, ==\n"
"== we advice you to remove Conda related paths from you $PATH ==\n"
"== or run this CMake file in a clean terminal without Conda Env. ==\n"
"==========================================================================\n")
endif()
|