CMakeLists.txt 24.5 KB
Newer Older
1
cmake_minimum_required(VERSION 3.8.2)
2

3
cmake_policy(SET CMP0012 NEW)
4
cmake_policy(SET CMP0020 NEW)
5 6 7
if (POLICY CMP0028)
  cmake_policy(SET CMP0028 NEW)
endif()
8 9 10
if (POLICY CMP0042)
  cmake_policy(SET CMP0042 NEW)
endif()
11 12 13
if (POLICY CMP0046)
  cmake_policy(SET CMP0046 NEW)
endif()
14

15 16 17 18 19 20 21 22
#If the user/superbuild hasn't explicitly stated what c++ standard to use
#require C++11
if(NOT DEFINED CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 11)
  set(CMAKE_CXX_STANDARD_REQUIRED True)
  set(CMAKE_CXX_EXTENSIONS FALSE)
endif()

23 24 25
project(SMTK)

# Remove SMTKTargets.cmake at the beginning of each CMake run; each time
26 27
# a library is declared below, the file is appended and we do not want
# to keep appending over multiple runs.
28
file(REMOVE ${PROJECT_BINARY_DIR}/SMTKTargets.cmake)
29

30 31 32
#Add our Cmake directory to the module search path
list(APPEND CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SMTK_SOURCE_DIR}/CMake)

33 34
################################################################################
# SMTK version number
35
include(SMTKVersion)
36 37 38

################################################################################

39 40 41 42 43
# Include GNU install directory module to detect where to install
# files on Linux/Unix systems (e.g., lib vs lib64)
include(GNUInstallDirs)

# Include export header so that we can easily expose symbols
44 45 46
# in dynamic libraries
include(GenerateExportHeader)

47
# Include cmake code that builds automatic header tests,
48 49
# makes targets for unit tests, and makes it easier to generate
# export install targets
50
include(SMTKMacros)
51

52 53 54 55
# include cmake code that allows for easier testing of SMTK classes
# and also provides helpers around create_test_sourcelist
include(CMake/SMTKTestingMacros.cmake)

56 57 58
# Add options for performing code coverage tests.
include(CMake/SMTKCoverage.cmake)

59
# Include mechanism for determining function and bind support
60
include(Function)
61 62

# Include mechanism for determining how to specialize hash<X>()
63
include(FindHashFunctor)
64

David Thompson's avatar
David Thompson committed
65 66 67 68 69
################################################################################
## Paths for output

# Set the directory where the binaries will be stored
set(EXECUTABLE_OUTPUT_PATH
70
  ${PROJECT_BINARY_DIR}/bin)
David Thompson's avatar
David Thompson committed
71 72

# Set the directory where the libraries will be stored
73 74
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
  ${PROJECT_BINARY_DIR}/bin)
David Thompson's avatar
David Thompson committed
75
set(LIBRARY_OUTPUT_PATH
76
  ${PROJECT_BINARY_DIR}/lib)
David Thompson's avatar
David Thompson committed
77

78 79
include(CMakeDependentOption)

80 81 82
################################################################################
# Options that the user controls
################################################################################
83
option(BUILD_SHARED_LIBS "Build SMTK using shared libraries" ON)
84 85
option(SMTK_NO_SYSTEM_BOOST "Allow boost to search for system installed boost" ON)
# Option to build Qt ui compoments for attributes
86
option(SMTK_ENABLE_TESTING "Enable Testing" ON)
87
option(SMTK_ENABLE_EXAMPLES "Enable Examples" OFF)
88
option(SMTK_ENABLE_PYTHON_WRAPPING "Build Python Wrappings" OFF)
89 90 91 92 93 94 95 96 97 98 99
# Provide system packagers with the ability to install SMTK
# to the system's Python site package directory. The default
# is off so that people building relocatable bundles (such as
# CMB) can distribute their own Python interpreter with
# internal packages (e.g., as part of a Mac ".app" bundle).
cmake_dependent_option(
  SMTK_INSTALL_PYTHON_TO_SITE_PACKAGES
  "Install Python modules to the interpreter's site-packages directory or into CMAKE_INSTALL_PREFIX?"
  OFF
  SMTK_ENABLE_PYTHON_WRAPPING OFF)
mark_as_advanced(SMTK_INSTALL_PYTHON_TO_SITE_PACKAGES)
100
option(SMTK_ENABLE_QT_SUPPORT "Build Qt GUI" OFF)
101
cmake_dependent_option(SMTK_ENABLE_APPLICATIONS "Build Qt-enabled applications" ON SMTK_ENABLE_QT_SUPPORT OFF)
T.J. Corona's avatar
T.J. Corona committed
102
option(SMTK_ENABLE_VTK_SUPPORT "Build VTK component" ON)
103
# SMTK uses vxl library for terrain extraction. It also depends on VTK and ParaView.
104
cmake_dependent_option(SMTK_ENABLE_VXL_SUPPORT "Build VXL component" ON
105
  "SMTK_ENABLE_PARAVIEW_SUPPORT;SMTK_ENABLE_QT_SUPPORT;SMTK_ENABLE_VTK_SUPPORT" OFF)
106
option(SMTK_ENABLE_REMUS_SUPPORT "Build Remus components" OFF)
107 108
cmake_dependent_option(SMTK_ENABLE_PARAVIEW_SUPPORT "Build paraview plugins for model sessions" OFF
  SMTK_ENABLE_VTK_SUPPORT OFF)
109

110
option(SMTK_ENABLE_CGM_SESSION "Build CGM component" OFF)
T.J. Corona's avatar
T.J. Corona committed
111 112
cmake_dependent_option(SMTK_ENABLE_DISCRETE_SESSION "Build discrete model session components" OFF
  SMTK_ENABLE_VTK_SUPPORT OFF)
113 114
cmake_dependent_option(SMTK_ENABLE_MOAB_DISCRETE_READER "Build moab reader for discrete model" OFF
  "SMTK_ENABLE_DISCRETE_SESSION" OFF)
T.J. Corona's avatar
T.J. Corona committed
115 116
cmake_dependent_option(SMTK_ENABLE_POLYGON_SESSION "Build Boost.polygon model session." ON
  SMTK_ENABLE_VTK_SUPPORT OFF)
117 118 119 120
cmake_dependent_option(SMTK_ENABLE_EXODUS_SESSION "Build a session to Exodus-II side sets" ON
  SMTK_ENABLE_VTK_SUPPORT OFF)
cmake_dependent_option(SMTK_ENABLE_REMOTE_SESSION "Build a session that allows modeling in a remote process" ON
  SMTK_ENABLE_REMUS_SUPPORT OFF)
T.J. Corona's avatar
T.J. Corona committed
121
option(SMTK_ENABLE_MESH_SESSION
T.J. Corona's avatar
T.J. Corona committed
122 123
  "Build a session that uses smtk::mesh as its backing" ON)
cmake_dependent_option(SMTK_ENABLE_MULTISCALE_SESSION "Build a session to Multiscale data" OFF
124
  "SMTK_ENABLE_VTK_SUPPORT;SMTK_ENABLE_MESH_SESSION;SMTK_ENABLE_PYTHON_WRAPPING" OFF)
T.J. Corona's avatar
T.J. Corona committed
125 126 127
if (SMTK_ENABLE_MULTISCALE_SESSION)
  set(AFRL_DIR "" CACHE PATH "Path to a directory of AFRL data.")
endif()
128

129
option(SMTK_USE_SYSTEM_MOAB "Use the system-installed moab?" OFF)
130

131 132 133 134 135 136
option(SMTK_ENABLE_DOCUMENTATION
  "Include targets for Doxygen- and Sphinx-generated documentation" OFF)
if (SMTK_ENABLE_DOCUMENTATION)
  find_package(Doxygen)
  find_package(Sphinx)
endif()
137

138 139 140 141 142 143
cmake_dependent_option(
  SMTK_ENABLE_CUMULUS_SUPPORT
  "Build cumulus interface and GUI (requires Qt w/OpenSSL support"
  OFF
  SMTK_ENABLE_QT_SUPPORT
  OFF)
144

145 146 147 148 149 150 151 152
################################################################################
# Testing Related Settings
################################################################################

#turn on ctest if we want testing
if (SMTK_ENABLE_TESTING)
  enable_testing()
  include(CTest)
153

154 155 156 157 158 159 160 161 162 163 164
  unset(SMTK_DATA_DIR CACHE)
  file(READ "${CMAKE_CURRENT_SOURCE_DIR}/data/smtk-data" data)
  if (NOT data STREQUAL "\n")
    message(WARNING
      "Testing is enabled, but the data is not available. Use git-lfs in order "
      "to obtain the testing data.")
    set(SMTK_DATA_DIR)
  else ()
    set(SMTK_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data")
  endif ()

165 166 167 168 169
  set(SMTK_COVERAGE_ENABLED OFF)
  if(SMTK_ENABLE_COVERAGE)
    set(SMTK_COVERAGE_ENABLED ON)
  endif()

170 171 172
  # Do not report some warnings from generated code to the dashboard:
  configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/CMake/CTestCustom.cmake.in"
173
    "${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake")
174

175
  # Add a test to check for the copyright statment in all source:
176 177 178 179
  add_test(NAME CopyrightStatement
    COMMAND ${CMAKE_COMMAND}
        "-DSMTK_SOURCE_DIR=${SMTK_SOURCE_DIR}"
        -P "${SMTK_SOURCE_DIR}/CMake/CheckCopyright.cmake")
180 181 182 183 184 185 186
endif()

################################################################################
# Boost Related Settings
################################################################################

# Boost is required for boost::uuids::uuid and, depending
187
# on the platform, for filesystem support.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
#setup if we should use boost static libraries based on if we are
#building static or shared. We need to match boosts library type to ours so
#that we handle symbol visibility properly, plus at the same time we have
#to understand that on some platforms or builds we will only have the static
#libraries so we need to handle that when presented
if(NOT DEFINED Boost_USE_STATIC_LIBS)
  if(${BUILD_SHARED_LIBS})
    set(Boost_USE_STATIC_LIBS OFF)
  else()
    set(Boost_USE_STATIC_LIBS ON)
  endif()
endif()

#if boost is installed as a system library on a machine, we will never
#be able to set the superbuild to use the custom boost version. The solution
#is that when doing a system
set(Boost_NO_SYSTEM_PATHS ${SMTK_NO_SYSTEM_BOOST})

# List of Boost features used:
207
# * Date Time
208 209 210
# * Filesystem
# * String algorithms
# * UUID Generation
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
set(required_boost_components
  date_time filesystem system)

# Some c++ compilers do not support regex, so we may need Boost's regex library.
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
    (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
      (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9.0")) OR
    (WIN32 AND MSVC))
#we definitely do not need regex support
elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
    CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9.0")
#we definitely need regex support
  list(APPEND required_boost_components regex)
else()
#we may need regex support, but rather than try-compile let's just use boost
  list(APPEND required_boost_components regex)
endif()

229
find_package(Boost 1.64.0
230
             COMPONENTS ${required_boost_components} REQUIRED)
231 232

if(WIN32 AND MSVC)
233 234
  #setup windows exception handling so we can compile properly with boost
  #enabled
235
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
236 237 238 239
  #quiet warnings about printf being potentially unsafe
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
  #quiet warnings about truncating decorated name
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4503")
Ben Boeckel's avatar
Ben Boeckel committed
240
  add_definitions(-DBOOST_ALL_NO_LIB)
241 242
endif()

243 244 245 246 247 248 249 250 251 252
# Setting this ensures that "make install" will leave rpaths to external
# libraries (not part of the build-tree e.g. Qt, ffmpeg, etc.) intact on
# "make install". This ensures that one can install a version of ParaView on the
# build machine without any issues. If this not desired, simply specify
# CMAKE_INSTALL_RPATH_USE_LINK_PATH when configuring and "make install" will
# strip all rpaths, which is default behavior.
if (NOT CMAKE_INSTALL_RPATH_USE_LINK_PATH)
  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif ()

253 254 255 256 257
################################################################################
# JSON Related Settings
################################################################################
find_package(nlohmann_json REQUIRED)

258 259 260
################################################################################
# Moab Related Settings
################################################################################
261 262 263 264 265 266 267 268 269

#if we are not using system moab we will build our own version through
#the thirdparty folder
if (SMTK_USE_SYSTEM_MOAB)
  # Moab is required for building smtk::mesh, as it is the default storage
  # format for meshes.
  find_package(MOAB REQUIRED)
endif()

270

271 272 273 274
################################################################################
# Qt Related Settings
################################################################################

275 276 277 278 279
################################################################################
# NOTE: This has be before any find_package(VTK), because currently ParaView
# and VTK can NOT be easily switched due to modules and macros intermixed
################################################################################
################################################################################
280
# Look for Discrete session discrete model modules
281 282
################################################################################

283
if(SMTK_ENABLE_PARAVIEW_SUPPORT)
284
  # include ParaView and ensure it is using the OpenGL2 backend
T.J. Corona's avatar
T.J. Corona committed
285
  find_package(ParaView)
286 287
endif()

288
################################################################################
289
# VTK Related Settings
290 291
################################################################################

292 293 294 295 296 297
if(SMTK_ENABLE_VTK_SUPPORT AND NOT SMTK_ENABLE_PARAVIEW_SUPPORT)
  # Find the package here so environment variables are set, but
  # be careful not to include the VTK_USE_FILE until inside
  # a subdirectory that requires it; otherwise the list of include
  # paths can become too long for some platforms.
  find_package(VTK REQUIRED)
T.J. Corona's avatar
T.J. Corona committed
298 299 300 301 302 303
endif()

if (SMTK_ENABLE_PARAVIEW_SUPPORT OR SMTK_ENABLE_VTK_SUPPORT)
  if(NOT VTK_RENDERING_BACKEND STREQUAL "OpenGL2")
    message(FATAL_ERROR
      "SMTK requires that VTK be built with the OpenGL2 Rendering backend.")
304
  endif()
305 306 307 308 309 310
endif()

################################################################################
# CGM Related Settings
################################################################################

311
if(SMTK_ENABLE_CGM_SESSION)
312
  find_package(CGM REQUIRED)
313
endif(SMTK_ENABLE_CGM_SESSION)
314 315 316 317 318

################################################################################
# Remus related settings
################################################################################

319
if (SMTK_ENABLE_REMUS_SUPPORT)
320 321 322
  find_package(Remus REQUIRED)
endif()

323 324 325 326 327 328
################################################################################
# Build third party libraries
################################################################################

add_subdirectory(thirdparty)

329 330 331
################################################################################
# Wrapping Related Settings
################################################################################
332
if(SMTK_ENABLE_PYTHON_WRAPPING)
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
  find_package(PythonLibs REQUIRED)
  find_package(PythonInterp 2.7 REQUIRED)

  # Initialize SMTK_PYTHON_MODULEDIR.
  # This stores the location where we'll install SMTK's Python modules.
  # Note that SMTK_PYTHON_MODULEDIR may be provided if SMTK is being
  # built as a submodule or as part of a superbuild.
  if (NOT DEFINED SMTK_PYTHON_MODULEDIR)
    if (SMTK_INSTALL_PYTHON_TO_SITE_PACKAGES)
        execute_process(
          COMMAND
          ${PYTHON_EXECUTABLE}
          -c "import site; print(site.getsitepackages())[-1]"
          RESULT_VARIABLE SMTK_PYTHON_MODULEDIR
          )
    elseif(WIN32)
        set(SMTK_PYTHON_MODULEDIR
          "bin/Lib/site-packages")
    else()
        set(SMTK_PYTHON_MODULEDIR
          "${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
    endif()
  endif()

357

358
  if(SMTK_ENABLE_PYTHON_WRAPPING)
359 360 361 362 363 364 365 366
    if(WIN32)
      set(PYTHON_MODULE_EXTENSION ".pyd")
    else()
      set(PYTHON_MODULE_EXTENSION ".so")
    endif()
    set(PYTHON_MODULE_PREFIX "")
    find_package(pybind11 REQUIRED)

367 368 369 370 371 372
    set(SMTK_PYBIND11_FLAGS " ")
    if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
       CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
       CMAKE_CXX_COMPILER_ID MATCHES "Intel")
      set(SMTK_PYBIND11_FLAGS "${SMTK_PYBIND11_FLAGS} -Wno-shadow")
    endif()
373 374 375
  endif()


376 377
  # Set up environment variables needed to import the python modules for tests.
  if (PYTHONINTERP_FOUND AND SMTK_ENABLE_TESTING)
378 379
    set(required_python_modules)

380 381 382 383
    if (SMTK_ENABLE_PARAVIEW_SUPPORT)
      list(APPEND required_python_modules
        paraview)
      set(paraview_PYTHONPATH
384 385
        "${PARAVIEW_PYTHONPATH}"
        "${PARAVIEW_PYTHONPATH}/vtk")
386 387
      set(paraview_libpath
        "${PARAVIEW_RUNTIME_DIRS}")
388 389 390
    elseif (SMTK_ENABLE_VTK_SUPPORT)
      list(APPEND required_python_modules
        vtk)
391
      # TODO: VTK needs to export a variable for this
392
      set(vtk_PYTHONPATH
393 394
        "${VTK_INSTALL_PREFIX}/lib/python2.7/site-packages"
        "${VTK_INSTALL_PREFIX}/lib")
395
      set(vtk_libpath
396
        "${VTK_INSTALL_PREFIX}/lib")
397
    endif ()
398 399 400 401 402 403

    set(envsep ":")
    if (WIN32)
      set(envsep ";")
    endif ()

404 405 406 407 408 409 410 411 412 413 414 415
    set(libpath_envvar)
    if (WIN32)
      set(libpath_envvar "PATH")
    elseif (APPLE)
      set(libpath_envvar "DYLD_FALLBACK_LIBRARY_PATH")
    elseif (UNIX)
      set(libpath_envvar "LD_LIBRARY_PATH")
    else ()
      message(WARNING "Unknown platform loader path environment variable.")
    endif ()

    function (smtk_test_python_module output_python output_lib module pythonpath libpath)
416 417
      string(REPLACE ";" "${envsep}" pythonpath_env "${pythonpath}")

418
      if (DEFINED ENV{PYTHONPATH})
419 420 421 422
        set(pythonpath_env
          "${pythonpath_env}${envsep}$ENV{PYTHONPATH}")
      endif ()

423 424
      string(REPLACE ";" "${envsep}" libpath_env "${libpath}")

425
      if (DEFINED ENV{${libpath_envvar}})
426 427 428 429
        set(libpath_env
          "${libpath_env}${envsep}$ENV{${libpath_envvar}}")
      endif ()

430 431 432 433 434
      # Test the PYTHONPATH passed in.
      execute_process(
        COMMAND "${CMAKE_COMMAND}"
                -E env
                "PYTHONPATH=${pythonpath_env}"
435
                "${libpath_envvar}=${libpath_env}"
436 437 438 439 440 441 442 443 444
                "${PYTHON_EXECUTABLE}"
                -c "import ${module}"
        RESULT_VARIABLE res
        OUTPUT_VARIABLE out
        ERROR_VARIABLE  err)

      if (res)
        message(SEND_ERROR
          "Failed to import the ${module} Python module. The attempted "
445 446 447 448
          "PYTHONPATH was '${pythonpath_env}' and ${libpath_envvar} set to "
          "'${libpath_env}', but it still failed. Please set the PYTHONPATH "
          "environment to make the ${module} module successfully import. The "
          "error message was '${err}'.")
449 450 451 452 453

        return ()
      endif ()

      # Add to the list of paths required for modules.
454 455
      set("${output_python}"
        ${${output_python}}
456 457
        "${pythonpath}"
        PARENT_SCOPE)
458 459 460 461 462 463

      # Add to the list of paths required for modules.
      set("${output_lib}"
        ${${output_lib}}
        "${libpath}"
        PARENT_SCOPE)
464 465 466 467
    endfunction ()

    set(smtk_pythonpaths
      "$ENV{PYTHONPATH}")
468 469
    set(smtk_libpaths
      "$ENV{${libpath_envvar}}")
470
    foreach (module IN LISTS required_python_modules)
471 472
      smtk_test_python_module(smtk_pythonpaths smtk_libpaths
        "${module}" "${${module}_PYTHONPATH}" "${${module}_libpath}")
473
    endforeach ()
474

475 476 477 478
    # Add the path to the build tree's compiled modules, prioritizing it over
    # the other directories (since the other directories will likely include the
    # location of the module's install).
    list(INSERT smtk_pythonpaths 0
479
      "${PROJECT_BINARY_DIR}${envsep}${PROJECT_BINARY_DIR}/lib")
480
    list(INSERT smtk_libpaths 0
481
      "${PROJECT_BINARY_DIR}/lib")
482
    if (CMAKE_RUNTIME_OUTPUT_DIRECTORY)
483
      list(INSERT smtk_libpaths 0
484 485
        "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
    endif ()
486

487 488 489 490
    # Remove duplicates.
    list(REMOVE_DUPLICATES smtk_pythonpaths)
    list(REMOVE_DUPLICATES smtk_libpaths)

491 492
    string(REPLACE ";" "${envsep}" smtk_pythonpath_env "${smtk_pythonpaths}")
    string(REPLACE ";" "${envsep}" smtk_libpath_env "${smtk_libpaths}")
493 494 495
    if (WIN32)
      string(REPLACE "/" "\\" smtk_libpath_env "${smtk_libpath_env}")
    endif ()
496 497 498
    string(REPLACE ";" "\;" smtk_pythonpath_env "${smtk_pythonpath_env}")
    string(REPLACE ";" "\;" smtk_libpath_env "${smtk_libpath_env}")
    set(smtk_python_test_environment
499
      "PYTHONPATH=${smtk_pythonpath_env}${envsep}${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
500
      "${libpath_envvar}=${smtk_libpath_env}")
501 502 503 504 505 506 507 508 509 510

    function (smtk_add_test_python name file)
      add_test(
        NAME    "${name}"
        COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/${file}"
                ${ARGN})
      set_tests_properties("${name}"
        PROPERTIES
          ENVIRONMENT "${smtk_python_test_environment}")
    endfunction ()
511 512 513 514 515 516 517 518 519 520

    function (smtk_add_test_python_full_path name file)
      add_test(
        NAME    "${name}"
        COMMAND "${PYTHON_EXECUTABLE}" "${file}"
                ${ARGN})
      set_tests_properties("${name}"
        PROPERTIES
          ENVIRONMENT "${smtk_python_test_environment}")
    endfunction ()
521
  endif()
522 523 524 525 526
endif()

################################################################################
# Determine function
################################################################################
527 528 529 530 531 532 533 534 535 536 537 538 539
determineFunctionType(
  FUNCTION_FOUND
  FUNCTION_NAMESPACE
  USING_PLACEHOLDERS
  FUNCTION_TYPE_HEADERS)

if (NOT FUNCTION_FOUND)
  message(FATAL_ERROR
    "
    SMTK requires std::function, std::tr1::function, or boost::function.
    Please examine CMake's logs to see why CMake/function*.cxx won't compile.
    ")
endif()
540 541 542 543 544 545 546

configure_file(
  ${PROJECT_SOURCE_DIR}/CMake/Function.h.in
  ${PROJECT_BINARY_DIR}/smtk/Function.h
  @ONLY)

install (FILES ${PROJECT_BINARY_DIR}/smtk/Function.h
547
  DESTINATION include/smtk/${SMTK_VERSION}/smtk)
548 549 550 551 552

################################################################################
# Determine hash<X> specialization
################################################################################
find_hash_functor(SMTK_HASH_H SMTK_HASH_NS SMTK_HASH_BEGIN_NS SMTK_HASH_END_NS SMTK_HASH_SPECIALIZATION)
553 554 555
if (NOT SMTK_HASH_H)
  message(FATAL_ERROR "Failed to find a header which provides std::hash<> (or equivalent).")
endif ()
556 557 558 559 560 561
configure_file(
  ${PROJECT_SOURCE_DIR}/CMake/HashFunctor.h.in
  ${PROJECT_BINARY_DIR}/smtk/HashFunctor.h
  @ONLY)

install (FILES ${PROJECT_BINARY_DIR}/smtk/HashFunctor.h
562
  DESTINATION include/smtk/${SMTK_VERSION}/smtk)
563

564 565 566 567
find_file(CGM_HAVE_VERSION_H
  NAMES cgm_version.h
  PATHS ${CGM_INCLUDE_DIRS}
  DOC   "Location of CGM's cgm_version.h")
568 569 570 571 572

################################################################################
# Save compile-time options for use by other packages
################################################################################
configure_file(
573
  ${PROJECT_SOURCE_DIR}/CMake/Options.h.in
574
  ${PROJECT_BINARY_DIR}/smtk/Options.h
575 576
  @ONLY)

577
install (FILES ${PROJECT_BINARY_DIR}/smtk/Options.h
578
  DESTINATION include/smtk/${SMTK_VERSION}/smtk)
579 580 581 582 583 584 585 586 587 588


################################################################################
# Install Related Settings
################################################################################

# Install rules for SMTK macros usable by external packages:
install(
  FILES
    ${PROJECT_SOURCE_DIR}/CMake/EncodeCStringFunctions.cmake
589
    ${PROJECT_SOURCE_DIR}/CMake/EncodePyStringFunctions.cmake
590
    ${PROJECT_SOURCE_DIR}/CMake/SMTKOperatorXML.cmake
591
    ${PROJECT_SOURCE_DIR}/CMake/SMTKSessionJSON.cmake
592
  DESTINATION
593
    ${CMAKE_INSTALL_LIBDIR}/cmake/SMTK
594 595 596 597 598 599 600
)

################################################################################
# Include Dirs Settings
################################################################################

# Add the current directory so we can include files like: <smtk/internal/Test.h>
601
# Save the include directories in a variable so that VTK modules
602
# (inside the extension/vtk and bridge/discrete directories) can reuse them.
603 604 605
include_directories(
  "${CMAKE_CURRENT_BINARY_DIR}"
  "${CMAKE_CURRENT_SOURCE_DIR}"
606 607 608
)
include_directories(
  SYSTEM
609 610
  "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty"
  "${CMAKE_CURRENT_BINARY_DIR}/thirdparty"
611 612 613 614 615 616 617 618 619
  "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cJSON"
  "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/pugixml"
  "${Boost_INCLUDE_DIRS}"
)

################################################################################
# Finally build smtk
################################################################################

620
# On Mac OS X, set the dir. included as part of the installed library's path:
621
if (BUILD_SHARED_LIBS AND NOT DEFINED CMAKE_INSTALL_NAME_DIR)
622 623 624
  set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif ()

625 626
add_subdirectory(smtk)

627
# Build SMTK Applications
628
if(SMTK_ENABLE_APPLICATIONS)
629 630 631
  add_subdirectory(applications)
endif()

632
################################################################################
633
# Install a package targets file
634 635 636 637
#
# Setup the exports for the library when used from an installed location
install(
  EXPORT SMTK
638
  DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SMTK
639
  FILE SMTKTargets.cmake
640
)
641

642
export(EXPORT SMTK FILE "${PROJECT_BINARY_DIR}/SMTKTargets.cmake")
643

644 645 646
################################################################################
# Create a build directory package configuration file
#
647 648 649
# Setup the config file for exports that stores what other thirdparty
# packages we need to search for ( MOAB, Remus, etc ) for when using the
# build version of smtk
650 651
#
# Required to happen before we include the docs directory
652
set(MOAB_ROOT_DIR "${MOAB_ROOT_DIR}")
653 654
set(SMTK_VTK_MODULE_DIR "${CMAKE_BINARY_DIR}/lib/cmake/SMTK")
set(SMTK_MODULE_DIR "${PROJECT_SOURCE_DIR}/CMake")
655 656 657 658 659 660
set(SMTK_CONFIG_DIR "${PROJECT_BINARY_DIR}")
configure_file(
  ${PROJECT_SOURCE_DIR}/CMake/SMTKConfig.cmake.in
  ${PROJECT_BINARY_DIR}/SMTKConfig.cmake
  @ONLY)

661 662 663
################################################################################
# Create an install package configuration file
#
664 665 666
# Setup the config file for exports that stores what other thirdparty
# packages we need to search for ( MOAB, Remus, etc ) for when using the
# install version of smtk
667
set(SMTK_VTK_MODULE_DIR "\${CMAKE_CURRENT_LIST_DIR}")
668
set(SMTK_MODULE_DIR "\${CMAKE_CURRENT_LIST_DIR}")
669 670 671 672 673 674 675
set(SMTK_CONFIG_DIR "\${CMAKE_CURRENT_LIST_DIR}")
configure_file(
  ${PROJECT_SOURCE_DIR}/CMake/SMTKConfig.cmake.in
  ${PROJECT_BINARY_DIR}/CMakeFiles/SMTKConfig.cmake
  @ONLY)

install (FILES ${PROJECT_BINARY_DIR}/CMakeFiles/SMTKConfig.cmake
676
         DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SMTK)
677 678 679 680 681 682 683 684 685 686 687

################################################################################
# Build documentation
# This also includes tutorials and other documentation that has its
# source checked against SMTK libraries, so it must come after those
# targets have been declared.
################################################################################

if (SMTK_ENABLE_DOCUMENTATION)
  add_subdirectory(doc)
endif()