CMakeLists.txt 6.8 KB
Newer Older
Kitware Robot's avatar
Kitware Robot committed
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

#Specify which tests we want to build.
option(BUILD_SHORT_TESTS "Build short tests (10 second timeout tests)" ON)
option(BUILD_MEDIUM_TESTS "Build medium tests (60 second timeout tests)" ON)
option(BUILD_LONG_TESTS "Build long tests (200 second timeout tests)" ON)

option(BUILD_SHARED_LIBS
      "Global flag to cause add_library to create shared libraries if on."
      ON)

#override the default project source and binary dir so that they
#always point to the same locations no matter where the project
#command was called from
set(ConceptualModelBuilder_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(ConceptualModelBuilder_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})

include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR})#for system header


#Policy CMP0003 deals with how specify link paths, with the policy set to NEW
#we are stating that we shouldn't split link paths into search paths and
#library names, but instead directly link using the full path. You really
#don't want to remove this policy before we set the cmake_minimum_required to
#be 3.X
if(COMMAND cmake_policy)
  cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

# Ensure that SUBDIRS is not used in this project:
# (we need in-order processing so the fixup script for the bundle
#  applications works properly...)
#
macro(SUBDIRS)
  message(FATAL_ERROR "error: do not use SUBDIRS in this project. Use ADD_SUBDIRECTORY instead.")
endmacro(SUBDIRS)

set(CMB_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
set(CMAKE_MODULE_PATH "${CMB_CMAKE_DIR}" ${CMAKE_MODULE_PATH})

include(CMBVersion)

Ben Boeckel's avatar
Ben Boeckel committed
42 43
if(NOT APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
  if(NOT CMAKE_CXX_FLAGS MATCHES "-fPIC")
Kitware Robot's avatar
Kitware Robot committed
44 45
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
  endif()
Ben Boeckel's avatar
Ben Boeckel committed
46
  if(NOT CMAKE_C_FLAGS MATCHES "-fPIC")
Kitware Robot's avatar
Kitware Robot committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
  endif()
endif()

message(STATUS "CMAKE_CXX_COMPILER_ID='${CMAKE_CXX_COMPILER_ID}'")
message(STATUS "CMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}'")
message(STATUS "CMAKE_C_FLAGS='${CMAKE_C_FLAGS}'")

add_definitions(-D_CRT_SECURE_NO_WARNINGS)

#########################################################################
# Testing and dashboard setup
if(BUILD_TESTING)
  set(CMB_TEST_DIR ${ConceptualModelBuilder_BINARY_DIR}/Testing/Temporary)
  make_directory(${CMB_TEST_DIR})
62

63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
  unset(CMB_TEST_DATA_ROOT CACHE)
  file(READ "${CMAKE_SOURCE_DIR}/data/cmb-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(CMB_TEST_DATA_ROOT)
  else ()
    file(READ "${CMAKE_SOURCE_DIR}/ThirdParty/SMTK/data/smtk-data" smtk_data)
    if (NOT smtk_data STREQUAL "\n")
      message(WARNING
        "CMB's data is available, but SMTK's is not. Use git-lfs in the "
        "submodule in order to obtain all of the testing data.")
      set(CMB_TEST_DATA_ROOT)
    else ()
      set(CMB_TEST_DATA_ROOT "${CMAKE_SOURCE_DIR}")
    endif ()
  endif ()

82 83 84 85 86
  #add the first test which is for checking the copyright
  add_test(NAME CopyrightStatement
    COMMAND ${CMAKE_COMMAND}
        "-DConceptualModelBuilder_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
        -P "${CMAKE_CURRENT_SOURCE_DIR}/CMake/CheckCopyright.cmake")
Kitware Robot's avatar
Kitware Robot committed
87 88
endif()

89 90 91 92
set(CMB_TEST_PLUGIN_PATHS ${CMB_TEST_PLUGIN_PATHS} CACHE STRING
   "Semi-colon seperated paths for testing plugins.")
mark_as_advanced(CMB_TEST_PLUGIN_PATHS)

Kitware Robot's avatar
Kitware Robot committed
93 94 95 96 97 98 99 100 101 102 103 104 105
#########################################################################

# setup cpack stuff
include(CPackCreate.cmake)
# Setup output directories.
if(NOT DEFINED LIBRARY_OUTPUT_PATH)
  set (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL
    "Single output directory for building all libraries.")
else()
  set (LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH} CACHE INTERNAL
    "Single output directory for building all libraries.")
endif()

106
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
Kitware Robot's avatar
Kitware Robot committed
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

#########################################################################
# include helper functions that projects use
include(CMBHelpers RESULT_VARIABLE CMB_HELPERS_PATH)


#########################################################################
# Search for vxl
find_package(VXL REQUIRED)
if(NOT VXL_RPL_FOUND)
  message(FATAL_ERROR "vxl must be built with BUILD_RPL enabled")
endif()
if(NOT VXL_RPL_RGTL_FOUND)
  message(FATAL_ERROR "vxl must be built with BUILD_RPL_RGTL enabled")
endif()

#########################################################################
# Search for boost
cmb_find_boost()

#########################################################################
# include ParaView here since basically everything links to it
find_package(ParaView REQUIRED)
include("${PARAVIEW_USE_FILE}")
include (ParaViewPlugins)
# We need to add the current value of VTK_MODULES_DIR to the module path
# so that when the plugins are built all the modules can be found. Otherwise,
# modules that aren't loaded as direct dependencies of CMB modules will
# not be found.
list(APPEND CMAKE_MODULE_PATH "${VTK_MODULES_DIR}")


#needs to be before CMBMeshing and pv_process_modules
pv_setup_module_environment("ConceptualModelBuilder")

#------------------------------------------------------------------------------
#We need to call include(CMBInstallRules) as pv_setup_module_environment
#overrides the install variables, and what it sets them too is work. So we
#get to set them all over again.
include(CMBInstallRules)

#########################################################################
# Meshing support
150
#configure meshing components before
Kitware Robot's avatar
Kitware Robot committed
151 152
add_subdirectory(CMBMeshing)

153
find_package(SMTK REQUIRED)
154
find_package(nlohmann_json REQUIRED)
155

Kitware Robot's avatar
Kitware Robot committed
156 157 158
#needs to be after CMBMeshing so that we can link to the MeshServer
pv_process_modules()

159 160 161
#process ModelBridge plugin
add_subdirectory(ModelBridges)

Kitware Robot's avatar
Kitware Robot committed
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
add_subdirectory(VTKExtensions/Client)
add_subdirectory(VTKExtensions/Testing)
add_subdirectory(Applications)

option(BUILD_EXAMPLES "Build CMB Examples" ON)
if(BUILD_EXAMPLES)
  add_subdirectory(Examples)
endif()

#------------------------------------------------------------------------------
# Lastly generate the CMBConfig.cmake so that other projects can depend on
# CMB.
# We create two versions of CMBConfig.cmake for the build tree and the
# install tree.

# For build tree.
configure_file(${ConceptualModelBuilder_SOURCE_DIR}/CMBConfig.cmake.in
  ${ConceptualModelBuilder_BINARY_DIR}/../CMBConfig.cmake @ONLY)
configure_file(CMBConfigVersion.cmake.in CMBConfigVersion.cmake @ONLY)


#-----------------------------------------------------------------------------
# Export all targets at once from the build tree in their final configuration.
# We export these again so that we add CMB's targets to the list.
get_property(_vtk_targets GLOBAL PROPERTY VTK_TARGETS)
if (_vtk_targets)
  list(REMOVE_DUPLICATES _vtk_targets)
Haocheng LIU's avatar
Haocheng LIU committed
189
  export(TARGETS ${_vtk_targets} FILE
Kitware Robot's avatar
Kitware Robot committed
190 191 192
    ${ConceptualModelBuilder_BINARY_DIR}/../CMBTargets.cmake)
endif()
unset(_vtk_targets)