Commit 3258f91c authored by Ben Boeckel's avatar Ben Boeckel Committed by Kitware Robot

Merge topic 'cmake-cleanups'

f0ddcf7c vtkPeriodicDataArray: move to Common/DataModel
aa9af24f cmake: move endian-ness test to its usage location
10799c57 cmake: move a single-use function to its usage location
931dc8fd cmake: move type array logic to its own module
60738e9d cmake: move SMP selection logic to its own module
6a8fe0cc cmake: clean up type list creation
997d43c5 cmake: clean up the array dispatch list creation
a942012c cmake: pass arguments rather than configuring vtkUnicodeString.cmake
...
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Brad King's avatarBrad King <brad.king@kitware.com>
Merge-request: !3578
parents b72a631a f0ddcf7c
# - Check if a C++ function exists
# CHECK_CXX_EXPRESSION_COMPILES(<expression> <files> <variable>)
#
# Check that the <expression> compiles in a program that includes
# <files> and store the result in a <variable>. Specify the list
# of files in one argument as a semicolon-separated list.
#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
#=============================================================================
# Copyright 2003-2011 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
INCLUDE(CheckCXXSourceCompiles)
MACRO(CHECK_CXX_EXPRESSION_COMPILES EXPRESSION FILES VARIABLE)
SET(SOURCE "/* CHECK_CXX_EXPRESSION_COMPILES */\n")
FOREACH(FILE ${FILES})
SET(SOURCE "${SOURCE}#include <${FILE}>\n")
ENDFOREACH()
SET(SOURCE "${SOURCE}\nint main()\n{\n")
SET(SOURCE "${SOURCE} static_cast<void>(${EXPRESSION});\n\n")
SET(SOURCE "${SOURCE} return 0;\n}\n")
CHECK_CXX_SOURCE_COMPILES("${SOURCE}" "${VARIABLE}")
ENDMACRO()
......@@ -19,11 +19,11 @@
# my_list contains a, b, and c, one could provide a dependency graph
# using the following variables:
#
# MY_A_EDGES b
# MY_B_EDGES
# MY_C_EDGES a b
# MY_a_EDGES b
# MY_b_EDGES
# MY_c_EDGES a b
#
# With the involcation of topological_sort shown above and these
# With the invocation of topological_sort shown above and these
# variables, the resulting reverse topological ordering will be b, a,
# c.
......
......@@ -48,20 +48,20 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND
endif ()
# The C and C++ flags added by VTK to the cmake-configured flags.
SET(VTK_REQUIRED_C_FLAGS "@VTK_REQUIRED_C_FLAGS@")
SET(VTK_REQUIRED_CXX_FLAGS "@VTK_REQUIRED_CXX_FLAGS@")
SET(VTK_REQUIRED_EXE_LINKER_FLAGS "@VTK_REQUIRED_EXE_LINKER_FLAGS@")
SET(VTK_REQUIRED_SHARED_LINKER_FLAGS "@VTK_REQUIRED_SHARED_LINKER_FLAGS@")
SET(VTK_REQUIRED_MODULE_LINKER_FLAGS "@VTK_REQUIRED_MODULE_LINKER_FLAGS@")
set(VTK_REQUIRED_C_FLAGS "@VTK_REQUIRED_C_FLAGS@")
set(VTK_REQUIRED_CXX_FLAGS "@VTK_REQUIRED_CXX_FLAGS@")
set(VTK_REQUIRED_EXE_LINKER_FLAGS "@VTK_REQUIRED_EXE_LINKER_FLAGS@")
set(VTK_REQUIRED_SHARED_LINKER_FLAGS "@VTK_REQUIRED_SHARED_LINKER_FLAGS@")
set(VTK_REQUIRED_MODULE_LINKER_FLAGS "@VTK_REQUIRED_MODULE_LINKER_FLAGS@")
# The VTK version number
SET(VTK_MAJOR_VERSION "@VTK_MAJOR_VERSION@")
SET(VTK_MINOR_VERSION "@VTK_MINOR_VERSION@")
SET(VTK_BUILD_VERSION "@VTK_BUILD_VERSION@")
set(VTK_MAJOR_VERSION "@VTK_MAJOR_VERSION@")
set(VTK_MINOR_VERSION "@VTK_MINOR_VERSION@")
set(VTK_BUILD_VERSION "@VTK_BUILD_VERSION@")
# The location of the UseVTK.cmake file.
SET(VTK_CMAKE_DIR "@VTK_CONFIG_CMAKE_DIR@")
SET(VTK_USE_FILE "${VTK_CMAKE_DIR}/UseVTK.cmake")
set(VTK_CMAKE_DIR "@VTK_CONFIG_CMAKE_DIR@")
set(VTK_USE_FILE "${VTK_CMAKE_DIR}/UseVTK.cmake")
# The rendering backend VTK was configured to use.
set(VTK_RENDERING_BACKEND "@VTK_RENDERING_BACKEND@")
......@@ -128,13 +128,13 @@ vtk_module_config(VTK ${VTK_MODULES_REQUESTED})
#-----------------------------------------------------------------------------
# VTK global configuration options.
SET(VTK_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
SET(VTK_LEGACY_REMOVE "@VTK_LEGACY_REMOVE@")
SET(VTK_LEGACY_SILENT "@VTK_LEGACY_SILENT@")
SET(VTK_WRAP_PYTHON "@VTK_WRAP_PYTHON@")
SET(VTK_WRAP_JAVA "@VTK_WRAP_JAVA@")
SET(VTK_QT_VERSION "@VTK_QT_VERSION@")
SET(VTK_ENABLE_KITS "@VTK_ENABLE_KITS@")
set(VTK_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
set(VTK_LEGACY_REMOVE "@VTK_LEGACY_REMOVE@")
set(VTK_LEGACY_SILENT "@VTK_LEGACY_SILENT@")
set(VTK_WRAP_PYTHON "@VTK_WRAP_PYTHON@")
set(VTK_WRAP_JAVA "@VTK_WRAP_JAVA@")
set(VTK_QT_VERSION "@VTK_QT_VERSION@")
set(VTK_ENABLE_KITS "@VTK_ENABLE_KITS@")
# Do not add options or information here that is specific to a
# particular module. Instead set <module>_EXPORT_OPTIONS and/or
......
# See if we need to link the socket library
INCLUDE(CheckLibraryExists)
INCLUDE(CheckSymbolExists)
CHECK_LIBRARY_EXISTS("socket" getsockname "" VTK_HAVE_LIBSOCKET)
IF(NOT DEFINED VTK_HAVE_GETSOCKNAME_WITH_SOCKLEN_T)
IF(VTK_HAVE_LIBSOCKET)
SET(VTK_GETSOCKNAME_LIBS "socket")
ELSE()
SET(VTK_GETSOCKNAME_LIBS)
ENDIF()
MESSAGE(STATUS "Checking for getsockname with socklen_t")
TRY_COMPILE(VTK_HAVE_GETSOCKNAME_WITH_SOCKLEN_T
${VTK_BINARY_DIR}/CMakeTmp/SocklenT
${VTK_CMAKE_DIR}/vtkTestSocklenT.cxx
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=${VTK_GETSOCKNAME_LIBS}"
OUTPUT_VARIABLE OUTPUT)
IF(VTK_HAVE_GETSOCKNAME_WITH_SOCKLEN_T)
MESSAGE(STATUS "Checking for getsockname with socklen_t -- yes")
SET(VTK_HAVE_GETSOCKNAME_WITH_SOCKLEN_T 1 CACHE INTERNAL "Support for getsockname with socklen_t")
FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log
"Determining if getsockname accepts socklen_t type "
"passed with the following output:\n"
"${OUTPUT}\n")
ELSE()
MESSAGE(STATUS "Checking for getsockname with socklen_t -- no")
SET(VTK_HAVE_GETSOCKNAME_WITH_SOCKLEN_T 0 CACHE INTERNAL "Support for getsockname with socklen_t")
FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
"Determining if getsockname accepts socklen_t type "
"failed with the following output:\n"
"${OUTPUT}\n")
ENDIF()
ENDIF()
# e.g. IBM BlueGene/L doesn't have SO_REUSEADDR, because "setsockopt is not needed for
# BlueGene/L applications" according to the BlueGene/L Application Development handbook
CHECK_SYMBOL_EXISTS(SO_REUSEADDR "sys/types.h;sys/socket.h" VTK_HAVE_SO_REUSEADDR)
SET(HAVE_SOCKETS TRUE)
# Cray Xt3/ Catamount doesn't have any socket support
# this could also be determined by doing something like
# check_symbol_exists(socket "sys/types.h;sys/socket.h" HAVE_SOCKETS)
#IF(CMAKE_SYSTEM MATCHES Catamount) #Xt6 and Xt7 at least have sockets, so disable this.
# SET(HAVE_SOCKETS FALSE)
#ENDIF()
# Objective-C++ compile flags.
# CMake has no equivalent of CMAKE_CXX_FLAGS for Objective-C++ (bug #4756)
# so we provide this in case the user needs to specify flags specifically
# for Objective-C++ source files. For example, to build with garbage
# collection support, the -fobjc-gc flag would be used.
set(VTK_OBJCXX_FLAGS_DEFAULT "")
set(VTK_REQUIRED_OBJCXX_FLAGS ${VTK_OBJCXX_FLAGS_DEFAULT} CACHE STRING "Extra flags for Objective-C++ compilation")
mark_as_advanced(VTK_REQUIRED_OBJCXX_FLAGS)
mark_as_advanced(
CMAKE_OSX_ARCHITECTURES
CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_OSX_SYSROOT)
if (CMAKE_OSX_DEPLOYMENT_TARGET AND
CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.7")
message(FATAL_ERROR "Minimum OS X deployment target is 10.7, please update CMAKE_OSX_DEPLOYMENT_TARGET.")
endif ()
# Minimum compiler version check: GCC >= 4.8
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
message(FATAL_ERROR "GCC 4.8 or later is required.")
endif ()
# Minimum compiler version check: LLVM Clang >= 3.3
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
message(FATAL_ERROR "LLVM Clang 3.3 or later is required.")
endif ()
# Minimum compiler version check: Apple Clang >= 5.0 (Xcode 5.0)
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
message(FATAL_ERROR "Apple Clang 5.0 or later is required.")
endif ()
# Minimum compiler version check: Microsoft C/C++ >= 18.0 (aka VS 2013 aka VS 12.0)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0)
message(FATAL_ERROR "Microsoft Visual Studio 2013 or later is required.")
endif ()
# Minimum compiler version check: Intel C++ (ICC) >= 14
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14.0)
message(FATAL_ERROR "Intel C++ (ICC) 14.0 or later is required.")
endif ()
# Make sure we have C++11 enabled.
if(NOT VTK_IGNORE_CMAKE_CXX11_CHECKS)
# Needed to make sure libraries and executables not built by the
# vtkModuleMacros still have the C++11 compiler flags enabled
# Wrap this in an escape hatch for unknown compilers
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS False)
endif()
......@@ -37,4 +37,3 @@ if(CMAKE_COMPILER_IS_GNUCXX)
"${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_WARN} ${CMAKE_CXX_FLAGS_ERROR}")
endif()
endif()
SET(VTK_REQUIRED_C_FLAGS)
SET(VTK_REQUIRED_CXX_FLAGS)
set(VTK_REQUIRED_C_FLAGS)
set(VTK_REQUIRED_CXX_FLAGS)
# make sure Crun is linked in with the native compiler, it is
# not used by default for shared libraries and is required for
# things like java to work.
IF(CMAKE_SYSTEM MATCHES "SunOS.*")
IF(NOT CMAKE_COMPILER_IS_GNUCXX)
FIND_LIBRARY(VTK_SUNCC_CRUN_LIBRARY Crun /opt/SUNWspro/lib)
IF(VTK_SUNCC_CRUN_LIBRARY)
LINK_LIBRARIES(${VTK_SUNCC_CRUN_LIBRARY})
ENDIF()
FIND_LIBRARY(VTK_SUNCC_CSTD_LIBRARY Cstd /opt/SUNWspro/lib)
IF(VTK_SUNCC_CSTD_LIBRARY)
LINK_LIBRARIES(${VTK_SUNCC_CSTD_LIBRARY})
ENDIF()
ENDIF()
ENDIF()
if(CMAKE_SYSTEM MATCHES "SunOS.*")
if(NOT CMAKE_COMPILER_IS_GNUCXX)
find_library(VTK_SUNCC_CRUN_LIBRARY Crun /opt/SUNWspro/lib)
if(VTK_SUNCC_CRUN_LIBRARY)
link_libraries(${VTK_SUNCC_CRUN_LIBRARY})
endif()
find_library(VTK_SUNCC_CSTD_LIBRARY Cstd /opt/SUNWspro/lib)
if(VTK_SUNCC_CSTD_LIBRARY)
link_libraries(${VTK_SUNCC_CSTD_LIBRARY})
endif()
endif()
endif()
# A GCC compiler.
IF(CMAKE_COMPILER_IS_GNUCXX)
IF(VTK_USE_X)
if(CMAKE_COMPILER_IS_GNUCXX)
if(VTK_USE_X)
unset(WIN32)
ENDIF()
IF(WIN32)
endif()
if(WIN32)
# The platform is gcc on cygwin.
SET(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} -mwin32")
SET(VTK_REQUIRED_C_FLAGS "${VTK_REQUIRED_C_FLAGS} -mwin32")
LINK_LIBRARIES(-lgdi32)
ENDIF()
IF(MINGW)
SET(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} -mthreads")
SET(VTK_REQUIRED_C_FLAGS "${VTK_REQUIRED_C_FLAGS} -mthreads")
SET(VTK_REQUIRED_EXE_LINKER_FLAGS "${VTK_REQUIRED_EXE_LINKER_FLAGS} -mthreads")
SET(VTK_REQUIRED_SHARED_LINKER_FLAGS "${VTK_REQUIRED_SHARED_LINKER_FLAGS} -mthreads")
SET(VTK_REQUIRED_MODULE_LINKER_FLAGS "${VTK_REQUIRED_MODULE_LINKER_FLAGS} -mthreads")
ENDIF()
IF(CMAKE_SYSTEM MATCHES "SunOS.*")
set(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} -mwin32")
set(VTK_REQUIRED_C_FLAGS "${VTK_REQUIRED_C_FLAGS} -mwin32")
link_libraries(-lgdi32)
endif()
if(MINGW)
set(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} -mthreads")
set(VTK_REQUIRED_C_FLAGS "${VTK_REQUIRED_C_FLAGS} -mthreads")
set(VTK_REQUIRED_EXE_LINKER_FLAGS "${VTK_REQUIRED_EXE_LINKER_FLAGS} -mthreads")
set(VTK_REQUIRED_SHARED_LINKER_FLAGS "${VTK_REQUIRED_SHARED_LINKER_FLAGS} -mthreads")
set(VTK_REQUIRED_MODULE_LINKER_FLAGS "${VTK_REQUIRED_MODULE_LINKER_FLAGS} -mthreads")
endif()
if(CMAKE_SYSTEM MATCHES "SunOS.*")
# Disable warnings that occur in X11 headers.
IF(DART_ROOT AND BUILD_TESTING)
SET(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} -Wno-unknown-pragmas")
SET(VTK_REQUIRED_C_FLAGS "${VTK_REQUIRED_C_FLAGS} -Wno-unknown-pragmas")
ENDIF()
ENDIF()
ELSE()
IF(CMAKE_ANSI_CFLAGS)
SET(VTK_REQUIRED_C_FLAGS "${VTK_REQUIRED_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
ENDIF()
IF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
SET(VTK_REQUIRED_CXX_FLAGS
if(DART_ROOT AND BUILD_TESTING)
set(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} -Wno-unknown-pragmas")
set(VTK_REQUIRED_C_FLAGS "${VTK_REQUIRED_C_FLAGS} -Wno-unknown-pragmas")
endif()
endif()
else()
if(CMAKE_ANSI_CFLAGS)
set(VTK_REQUIRED_C_FLAGS "${VTK_REQUIRED_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
endif()
if(CMAKE_SYSTEM MATCHES "OSF1-V.*")
set(VTK_REQUIRED_CXX_FLAGS
"${VTK_REQUIRED_CXX_FLAGS} -timplicit_local -no_implicit_include")
ENDIF()
IF(CMAKE_SYSTEM MATCHES "AIX.*")
endif()
if(CMAKE_SYSTEM MATCHES "AIX.*")
# allow t-ypeid and d-ynamic_cast usage (normally off by default on xlC)
SET(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} -qrtti=all")
set(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} -qrtti=all")
# silence duplicate symbol warnings on AIX
SET(VTK_REQUIRED_EXE_LINKER_FLAGS "${VTK_REQUIRED_EXE_LINKER_FLAGS} -bhalt:5")
SET(VTK_REQUIRED_SHARED_LINKER_FLAGS "${VTK_REQUIRED_SHARED_LINKER_FLAGS} -bhalt:5")
SET(VTK_REQUIRED_MODULE_LINKER_FLAGS "${VTK_REQUIRED_MODULE_LINKER_FLAGS} -bhalt:5")
ENDIF()
IF(CMAKE_SYSTEM MATCHES "HP-UX.*")
SET(VTK_REQUIRED_C_FLAGS
set(VTK_REQUIRED_EXE_LINKER_FLAGS "${VTK_REQUIRED_EXE_LINKER_FLAGS} -bhalt:5")
set(VTK_REQUIRED_SHARED_LINKER_FLAGS "${VTK_REQUIRED_SHARED_LINKER_FLAGS} -bhalt:5")
set(VTK_REQUIRED_MODULE_LINKER_FLAGS "${VTK_REQUIRED_MODULE_LINKER_FLAGS} -bhalt:5")
endif()
if(CMAKE_SYSTEM MATCHES "HP-UX.*")
set(VTK_REQUIRED_C_FLAGS
"${VTK_REQUIRED_C_FLAGS} +W2111 +W2236 +W4276")
SET(VTK_REQUIRED_CXX_FLAGS
set(VTK_REQUIRED_CXX_FLAGS
"${VTK_REQUIRED_CXX_FLAGS} +W2111 +W2236 +W4276")
ENDIF()
ENDIF()
endif()
endif()
# figure out whether the compiler might be the Intel compiler
SET(_MAY_BE_INTEL_COMPILER FALSE)
IF(UNIX)
IF(CMAKE_CXX_COMPILER_ID)
IF(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
SET(_MAY_BE_INTEL_COMPILER TRUE)
ENDIF()
ELSE()
IF(NOT CMAKE_COMPILER_IS_GNUCXX)
SET(_MAY_BE_INTEL_COMPILER TRUE)
ENDIF()
ENDIF()
ENDIF()
set(_MAY_BE_INTEL_COMPILER FALSE)
if(UNIX)
if(CMAKE_CXX_COMPILER_ID)
if(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set(_MAY_BE_INTEL_COMPILER TRUE)
endif()
else()
if(NOT CMAKE_COMPILER_IS_GNUCXX)
set(_MAY_BE_INTEL_COMPILER TRUE)
endif()
endif()
endif()
#if so, test whether -i_dynamic is needed
IF(_MAY_BE_INTEL_COMPILER)
INCLUDE(${VTK_CMAKE_DIR}/TestNO_ICC_IDYNAMIC_NEEDED.cmake)
TESTNO_ICC_IDYNAMIC_NEEDED(NO_ICC_IDYNAMIC_NEEDED ${VTK_CMAKE_DIR})
IF(NO_ICC_IDYNAMIC_NEEDED)
SET(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS}")
ELSE()
SET(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} -i_dynamic")
ENDIF()
ENDIF()
if(_MAY_BE_INTEL_COMPILER)
include(${VTK_CMAKE_DIR}/TestNO_ICC_IDYNAMIC_NEEDED.cmake)
testno_icc_idynamic_needed(NO_ICC_IDYNAMIC_NEEDED ${VTK_CMAKE_DIR})
if(NO_ICC_IDYNAMIC_NEEDED)
set(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS}")
else()
set(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} -i_dynamic")
endif()
endif()
IF(CMAKE_CXX_COMPILER_ID STREQUAL "PGI")
if(CMAKE_CXX_COMPILER_ID STREQUAL "PGI")
# --diag_suppress=236 is for constant value asserts used for error handling
# This can be restricted to the implementation and doesn't need to propagate
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --diag_suppress=236")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --diag_suppress=236")
# --diag_suppress=381 is for redundant semi-colons used in macros
# This needs to propagate to anything that includes VTK headers
SET(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} --diag_suppress=381")
ENDIF()
set(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} --diag_suppress=381")
endif()
IF(MSVC)
if(MSVC)
# Use the highest warning level for visual c++ compiler.
SET(CMAKE_CXX_WARNING_LEVEL 4)
IF(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
set(CMAKE_CXX_WARNING_LEVEL 4)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
ENDIF()
ENDIF()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
endif()
# Disable deprecation warnings for standard C and STL functions in VS2005
# and later
IF(MSVC_VERSION EQUAL 1400 OR MSVC_VERSION GREATER 1400 OR MSVC10)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
ENDIF()
if(MSVC_VERSION EQUAL 1400 OR MSVC_VERSION GREATER 1400 OR MSVC10)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
endif()
# Enable /MP flag for Visual Studio 2008 and greator
IF(MSVC_VERSION GREATER 1400)
SET(CMAKE_CXX_MP_FLAG OFF CACHE BOOL "Build with /MP flag enabled")
SET(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}")
SET(CMAKE_CXX_MP_NUM_PROCESSORS CACHE ${PROCESSOR_COUNT} "The maximum number of processes for the /MP flag")
IF (CMAKE_CXX_MP_FLAG)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP${CMAKE_CXX_MP_NUM_PROCESSORS}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP${CMAKE_CXX_MP_NUM_PROCESSORS}")
ENDIF ()
ENDIF()
if(MSVC_VERSION GREATER 1400)
set(CMAKE_CXX_MP_FLAG OFF CACHE BOOL "Build with /MP flag enabled")
set(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}")
set(CMAKE_CXX_MP_NUM_PROCESSORS CACHE ${PROCESSOR_COUNT} "The maximum number of processes for the /MP flag")
if (CMAKE_CXX_MP_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP${CMAKE_CXX_MP_NUM_PROCESSORS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP${CMAKE_CXX_MP_NUM_PROCESSORS}")
endif ()
endif()
#-----------------------------------------------------------------------------
# Add compiler flags VTK needs to work on this platform. This must be
# done after the call to CMAKE_EXPORT_BUILD_SETTINGS, but before any
# try-compiles are done.
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VTK_REQUIRED_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VTK_REQUIRED_CXX_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${VTK_REQUIRED_EXE_LINKER_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${VTK_REQUIRED_SHARED_LINKER_FLAGS}")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${VTK_REQUIRED_MODULE_LINKER_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VTK_REQUIRED_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VTK_REQUIRED_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${VTK_REQUIRED_EXE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${VTK_REQUIRED_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${VTK_REQUIRED_MODULE_LINKER_FLAGS}")
# Full functional CMAKE_CROSSCOMPILING_EMULATOR support for custom_command and
# custom_target is available in CMake 3.8.0
# It was first added in CMake 3.6.0 and later fixed in CMake 3.8.0 (commit e7480d67, CMake issue #16288)
set(_vtk_crosscompiling_emulator_support_custom_target 1)
if(CMAKE_VERSION VERSION_LESS "3.8.0")
set(_vtk_crosscompiling_emulator_support_custom_target 0)
endif()
# Maintain backward compatibility with user setting COMPILE_TOOLS_IMPORTED
if(DEFINED COMPILE_TOOLS_IMPORTED AND NOT DEFINED VTK_COMPILE_TOOLS_IMPORTED)
set(VTK_COMPILE_TOOLS_IMPORTED ${COMPILE_TOOLS_IMPORTED})
unset(COMPILE_TOOLS_IMPORTED)
endif()
# Variable VTK_COMPILE_TOOLS_IMPORTED is preferred
if(NOT DEFINED VTK_COMPILE_TOOLS_IMPORTED)
set(VTK_COMPILE_TOOLS_IMPORTED FALSE)
endif()
if(CMAKE_CROSSCOMPILING
AND NOT VTK_COMPILE_TOOLS_IMPORTED
AND (NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR
OR NOT _vtk_crosscompiling_emulator_support_custom_target)
)
# if CMAKE_CROSSCOMPILING is true and crosscompiling emulator is not available, we need
# to import build-tools targets.
find_package(VTKCompileTools REQUIRED)
set(VTK_COMPILE_TOOLS_IMPORTED TRUE)
endif()
# VTK installation structure
set(vtk_subdir "vtk-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}")
vtk_set_with_default(VTK_INSTALL_RUNTIME_DIR "bin")
vtk_set_with_default(VTK_INSTALL_LIBRARY_DIR "lib")
vtk_set_with_default(VTK_INSTALL_ARCHIVE_DIR "lib")
vtk_set_with_default(VTK_INSTALL_INCLUDE_DIR "include/${vtk_subdir}")
vtk_set_with_default(VTK_INSTALL_DATA_DIR "share/${vtk_subdir}")
vtk_set_with_default(VTK_INSTALL_DOC_DIR "share/doc/${vtk_subdir}")
vtk_set_with_default(VTK_INSTALL_PACKAGE_DIR "${VTK_INSTALL_LIBRARY_DIR}/cmake/${vtk_subdir}")
vtk_set_with_default(VTK_INSTALL_DOXYGEN_DIR "${VTK_INSTALL_DOC_DIR}/doxygen")
vtk_set_with_default(VTK_INSTALL_EXPORT_NAME "VTKTargets")
# Set up our directory structure for output libraries and binaries
vtk_set_with_default(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${VTK_BINARY_DIR}/bin")
if(UNIX)
set(vtk_library_directory "lib")
else()
set(vtk_library_directory "bin")
endif()
vtk_set_with_default(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${VTK_BINARY_DIR}/${vtk_library_directory}")
vtk_set_with_default(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${VTK_BINARY_DIR}/lib")
vtk_set_with_default(VTK_MODULES_DIR "${VTK_BINARY_DIR}/${VTK_INSTALL_PACKAGE_DIR}/Modules")
vtk_set_with_default(VTK_WWW_DIR "${VTK_BINARY_DIR}/www")
if(DEFINED VTK_INSTALL_PYTHON_MODULE_DIR)
message(WARNING
"VTK_INSTALL_PYTHON_MODULE_DIR is no longer supported. "
"Set `VTK_PYTHON_SITE_PACKAGES_SUFFIX` instead, although not needed in most cases.")
endif()
if(DEFINED VTK_BUILD_PYTHON_MODULE_DIR)
message(WARNING
"VTK_BUILD_PYTHON_MODULE_DIR is no longer supported. "
"Set `VTK_PYTHON_SITE_PACKAGES_SUFFIX` instead, although not needed in most cases.")
endif()
# Forbid downloading resources from the network during a build. This helps
# when building on systems without network connectivity to determine which
# resources much be obtained manually and made available to the build.
option(VTK_FORBID_DOWNLOADS "Do not download source code or data from the network" OFF)
mark_as_advanced(VTK_FORBID_DOWNLOADS)
macro(vtk_download_attempt_check _name)
if(VTK_FORBID_DOWNLOADS)
message(SEND_ERROR "Attempted to download ${_name} when VTK_FORBID_DOWNLOADS is ON")
endif()
endmacro()
option(VTK_IOS_BUILD "Build vtk.framework for iOS" OFF)
if (VTK_IOS_BUILD)
include(vtkiOS)
return()
endif()
option(VTK_ANDROID_BUILD "Build VTK for Android" OFF)
if (VTK_ANDROID_BUILD)
include(vtkAndroid)
return()
endif()
# some specific defaults for Andriod to give folks
# a reasonable starting point
if (ANDROID OR APPLE_IOS)
set(CMAKE_REQUIRE_LARGE_FILE_SUPPORT 2 CACHE STRING "Result from TRY_RUN" FORCE)
set(CMAKE_REQUIRE_LARGE_FILE_SUPPORT__TRYRUN_OUTPUT "" CACHE STRING "Output from TRY_RUN" FORCE)
set(KWSYS_LFS_WORKS 2 CACHE STRING "Result from TRY_RUN" FORCE)
set(KWSYS_LFS_WORKS__TRYRUN_OUTPUT "" CACHE STRING "Output from TRY_RUN" FORCE)
if (APPLE_IOS)
unset(OPENGL_INCLUDE_DIR CACHE)
find_path(OPENGL_INCLUDE_DIR ES3/gl.h
${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/OpenGLES.framework/Headers
${_OPENGL_INCLUDE_DIR})
find_library(OPENGL_gl_LIBRARY
NAMES OpenGLES
PATHS
${CMAKE_OSX_SYSROOT}/System/Library/Frameworks
${_OPENGL_LIB_PATH}
)
elseif (ANDROID)
unset(OPENGL_INCLUDE_DIR CACHE)
unset(OPENGL_gl_LIBRARY CACHE)
unset(OPENGL_egl_LIBRARY CACHE)
find_path(OPENGL_INCLUDE_DIR GLES3/gl3.h)
find_library(OPENGL_gl_LIBRARY NAMES GLESv3)
find_library(OPENGL_egl_LIBRARY NAMES EGL)
endif()
else()
# Choose static or shared libraries.
option(BUILD_SHARED_LIBS "Build VTK with shared libraries." ON)
endif()
macro (vtk_set_with_default var value)
if (NOT ${var})
set(${var