CMakeLists.txt 2.06 KB
Newer Older
1 2
#-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8)
3 4
cmake_policy(SET CMP0002 NEW)   # For cmake >= 3
cmake_policy(SET CMP0057 NEW)   # For cmake >= 3.10.2
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

# Fail if not building out-of-source
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
    message(FATAL_ERROR
        "In-source builds disallowed. Use a separate build directory")
endif()

#-----------------------------------------------------------------------------
# Simple discovery and sanity checks

find_package(ParaView REQUIRED)

# Qualify OpenFOAM/ParaView libraries with -pvMAJ.MIN
# The pv_api can also be used for paraview-MAJ.MIN
if (DEFINED ENV{PARAVIEW_API})
    set(pv_api "$ENV{PARAVIEW_API}")
else()
    if (${ParaView_VERSION} GREATER_EQUAL 5.7)
        string(REGEX MATCH [0-9]+[.][0-9]+ pv_api ${ParaView_VERSION})
        message("The PARAVIEW_API env was unset, "
            "extracted value from version="
            "${ParaView_VERSION} is ${pv_api}")
    else()
        set(pv_api "${PARAVIEW_VERSION_MAJOR}.${ParaView_VERSION_MINOR}")
        message("The PARAVIEW_API env was unset, "
            "assembled from maj/min="
            "${ParaView_VERSION_MAJOR}/${ParaView_VERSION_MINOR} is ${pv_api}")
    endif()
endif()

35 36 37 38 39 40
# Pass through the OpenFOAM API value to the reader
set(foam_api "$ENV{FOAM_API}")
if (NOT "${foam_api}")
    set(foam_api "2.0")
endif()

41
set(foamPvLibQualifier "-pv${pv_api}")
42 43 44 45 46 47

#-----------------------------------------------------------------------------

message("================")
message("Using ParaView = $ENV{ParaView_DIR}")
message("OpenFOAM api   = ${foam_api}, libs = ${foamPvLibQualifier}")
48 49 50 51 52 53

#-----------------------------------------------------------------------------

include(CMakeLists-OpenFOAM.txt)

if (${ParaView_VERSION} GREATER_EQUAL 5.7)
54
  message("================")
55 56
  include(CMakeLists-Project57.txt)
else()
57
  message("================")
58 59 60 61 62
  include(${PARAVIEW_USE_FILE})
  include(CMakeLists-Project.txt)
endif()

#-----------------------------------------------------------------------------