Commit 6b7ee1c2 authored by Gregory C. Sharp's avatar Gregory C. Sharp

Initial commit; copied from plastimatch hash b3dcfe25dddea02b5b3d9adf97f054f4882b056b

parents
This diff is collapsed.
##---------------------------------------------------------------------------
## See COPYRIGHT.TXT and LICENSE.TXT for copyright and license information
##---------------------------------------------------------------------------
macro (check_char_sign _out_var)
try_run (RUN_RESULT_VAR COMPILE_RESULT_VAR
${PLM_BINARY_DIR}
${PLM_SOURCE_DIR}/cmake/char_is_signed.cxx
RUN_OUTPUT_VARIABLE ${_out_var})
endmacro ()
##---------------------------------------------------------------------------
## See COPYRIGHT.TXT and LICENSE.TXT for copyright and license information
##---------------------------------------------------------------------------
macro (check_epsilon _out_var)
try_run (RUN_RESULT_VAR COMPILE_RESULT_VAR
${PLM_BINARY_DIR}
${PLM_SOURCE_DIR}/cmake/test_eps.cxx
RUN_OUTPUT_VARIABLE ${_out_var})
endmacro ()
##---------------------------------------------------------------------------
## See COPYRIGHT.TXT and LICENSE.TXT for copyright and license information
##---------------------------------------------------------------------------
include (CheckCXXSourceCompiles)
macro (CHECK_QT QT_TEST_COMPILE_SUCCEEDED)
# It took forever to get the quoting correct on this.
# Thanks to sakra @ http://stackoverflow.com/questions/25726853
try_compile (COMPILE_RESULT_VAR
${CMAKE_BINARY_DIR}/helpme
${CMAKE_SOURCE_DIR}/cmake/test_qt.cxx
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES:STRING=${QT_INCLUDES}"
"-DLINK_LIBRARIES:STRING=${QT_QTCORE_LIBRARIES}"
OUTPUT_VARIABLE OUT_VAR
)
set (${QT_TEST_COMPILE_SUCCEEDED} ${COMPILE_RESULT_VAR})
endmacro ()
##-----------------------------------------------------------------------------
## Patch stock ITK 3.20.0 to make it work on gcc 4.6
##-----------------------------------------------------------------------------
execute_process (
COMMAND "${CMAKE_COMMAND}"
-E copy "${PLM_SOURCE_DIR}/libs/itk-3.20.0/metaUtils.cxx"
"${PLM_TARGET_DIR}/${proj_itk}/Utilities/MetaIO/metaUtils.cxx"
)
execute_process (
COMMAND "${CMAKE_COMMAND}"
-E copy "${PLM_SOURCE_DIR}/libs/itk-3.20.0/itkImageIORegion.h"
"${PLM_TARGET_DIR}/${proj_itk}/Code/IO/itkImageIORegion.h"
)
execute_process (
COMMAND "${CMAKE_COMMAND}"
-E copy "${PLM_SOURCE_DIR}/libs/itk-3.20.0/itkImageIOBase.h"
"${PLM_TARGET_DIR}/${proj_itk}/Code/IO/itkImageIOBase.h"
)
# Detect development libraries for Advantech I/O card.
# These variables are set:
#
# ADVANTECH_FOUND
# ADVANTECH_INCLUDE_DIR
# ADVANTECH_LIBRARIES
#
# Only works on Windows
if (ADVANTECH_INCLUDE_DIR)
# Already in cache, be silent
set (Advantech_FIND_QUIETLY TRUE)
endif ()
FIND_PATH (ADVANTECH_INCLUDE_DIR "Driver.h"
"C:/Program Files/Advantech/Adsapi/Include"
DOC "Path to ADVANTECH include files.")
FIND_PATH (ADVANTECH_LIBRARY_PATH "ADSDEV.lib"
"C:/Program Files/Advantech/Adsapi/Lib"
DOC "Path to ADVANTECH libraries.")
FIND_LIBRARY(ADVANTECH_ADS841_LIB ADS841 ${ADVANTECH_LIBRARY_PATH})
FIND_LIBRARY(ADVANTECH_Adsapi32_LIB Adsapi32 ${ADVANTECH_LIBRARY_PATH})
FIND_LIBRARY(ADVANTECH_Adsapi32bcb_LIB Adsapi32bcb ${ADVANTECH_LIBRARY_PATH})
FIND_LIBRARY(ADVANTECH_Adscomm_LIB Adscomm ${ADVANTECH_LIBRARY_PATH})
FIND_LIBRARY(ADVANTECH_ADSDEV_LIB ADSDEV ${ADVANTECH_LIBRARY_PATH})
FIND_LIBRARY(ADVANTECH_adsdnet_LIB adsdnet ${ADVANTECH_LIBRARY_PATH})
if (ADVANTECH_Adscomm_LIB AND ADVANTECH_Adsapi32_LIB)
set (ADVANTECH_LIBRARIES ${ADVANTECH_Adscomm_LIB} ${ADVANTECH_Adsapi32_LIB})
else ()
set (ADVANTECH_LIBRARIES)
endif ()
INCLUDE (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (Advantech DEFAULT_MSG
ADVANTECH_LIBRARIES ADVANTECH_INCLUDE_DIR)
MARK_AS_ADVANCED (
ADVANTECH_ADS841_LIB
ADVANTECH_Adsapi32_LIB
ADVANTECH_Adsapi32bcb_LIB
ADVANTECH_Adscomm_LIB
ADVANTECH_ADSDEV_LIB
ADVANTECH_adsdnet_LIB)
# Bitflow lib and include path
# These variables are set:
#
# BITFLOW_FOUND
# BITFLOW_INCLUDE_DIR
# BITFLOW_LIBRARIES
#
# Only works on Windows
if (BITFLOW_INCLUDE_DIR)
# Already in cache, be silent
set (Bitflow_FIND_QUIETLY TRUE)
endif ()
FIND_PATH (BITFLOW_SDK_DIR "include/BFApi.h" "C:/BitFlow SDK 4.00"
DOC "Path to Bitflow SDK")
FIND_PATH (BITFLOW_INCLUDE_DIR "BFApi.h"
"${BITFLOW_SDK_DIR}/include"
"C:/BitFlow SDK 4.00/include"
DOC "Path to Bitflow include files")
FIND_PATH (BITFLOW_LIBRARY_PATH "BFD.lib"
"${BITFLOW_SDK_DIR}/lib"
"C:/BitFlow SDK 4.00/lib"
DOC "Path to Bitflow libraries.")
FIND_LIBRARY (BITFLOW_BFD_LIB BFD ${BITFLOW_LIBRARY_PATH})
FIND_LIBRARY (BITFLOW_R2D_LIB R2d ${BITFLOW_LIBRARY_PATH})
FIND_LIBRARY (BITFLOW_DISPSURF_LIB DispSurf ${BITFLOW_LIBRARY_PATH})
if (BITFLOW_BFD_LIB AND BITFLOW_R2D_LIB AND BITFLOW_DISPSURF_LIB)
set (BITFLOW_LIBRARIES
${BITFLOW_BFD_LIB} ${BITFLOW_R2D_LIB} ${BITFLOW_DISPSURF_LIB})
else ()
set (BITFLOW_LIBRARIES)
endif ()
INCLUDE (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (Bitflow DEFAULT_MSG
BITFLOW_LIBRARIES BITFLOW_INCLUDE_DIR)
MARK_AS_ADVANCED (
BITFLOW_INCLUDE_DIR
BITFLOW_LIBRARY_PATH
BITFLOW_BFD_LIB
BITFLOW_R2D_LIB
BITFLOW_DISPSURF_LIB)
# - Wrapper around FindCUDA
if (MINGW)
# Cuda doesn't work with mingw at all
set (CUDA_FOUND FALSE)
elseif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)
# FindCuda is included with CMake 2.8
set (CUDA_FOUND FALSE)
else ()
# GCS 2011.03.16
# Make nvcc less whiny
if (CMAKE_COMPILER_IS_GNUCC)
set (CUDA_PROPAGATE_HOST_FLAGS OFF)
endif ()
# GCS 2012-05-11: We need to propagate cxx flags to nvcc, but
# the flag -ftest-coverage causes nvcc to barf, so exclude that one
if (CMAKE_COMPILER_IS_GNUCC)
string (REPLACE "-ftest-coverage" "" TMP "${CMAKE_CXX_FLAGS}")
string (REPLACE " " "," TMP "${TMP}")
set (CUDA_CXX_FLAGS ${CUDA_CXX_FLAGS} ${TMP})
endif ()
# GCS 2012-05-07: Workaround for poor, troubled FindCUDA
set (CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE FALSE)
find_package (CUDA QUIET)
# GCS 2016-12-23: Tell FindCUDA to tell nvcc to use the c++ compiler,
# which it doesn't do even if CUDA_HOST_COMPILATION_CPP is true.
# This has to be done after calling FindCUDA, because FindCUDA overwrites
# the variable. PS: Merry Christmas!
if (NOT MSVC)
set (CUDA_HOST_COMPILER "${CMAKE_CXX_COMPILER}")
endif ()
endif ()
# 14-5-2016 PAOLO: WORKAROUND GCC 6.1 AND CUDA 7.5 INCOMPATIBILITY
if (CMAKE_COMPILER_IS_GNUCC
AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0))
set (CUDA_CXX_FLAGS "${CUDA_CXX_FLAGS},-std=c++98")
endif ()
# ITK headers cannot be processed by nvcc, so we define
# PLM_CUDA_COMPILE for the purpose of guarding
# (see base/plmbase.h)
if (CUDA_CXX_FLAGS)
set (CUDA_CXX_FLAGS "${CUDA_CXX_FLAGS},-DPLM_CUDA_COMPILE=1")
else ()
set (CUDA_CXX_FLAGS "-DPLM_CUDA_COMPILE=1")
endif ()
# GCS 2012-09-25 - Seems this is needed too
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
set (CUDA_CXX_FLAGS "${CUDA_CXX_FLAGS},-fPIC")
endif ()
if (CUDA_CXX_FLAGS)
list (APPEND CUDA_NVCC_FLAGS --compiler-options ${CUDA_CXX_FLAGS})
endif ()
set (CUDA_FOUND ${CUDA_FOUND} CACHE BOOL "Did we find cuda?")
if (CUDA_FOUND)
cuda_include_directories (
${CMAKE_CURRENT_SOURCE_DIR}
)
endif ()
# GCS 2012-05-22 -- viscous fluid registration requires CUDA SDK.
if (NOT CUDA_SDK_ROOT_DIR)
# Try some obvious paths not searched by stock FindCUDA
find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h
"$ENV{HOME}/NVIDIA_GPU_Computing_SDK/C"
"/usr/local/NVIDIA_GPU_Computing_SDK/C"
)
endif ()
if (CUDA_SDK_ROOT_DIR)
find_path (CUDA_CUT_INCLUDE_DIR
cutil.h
PATHS ${CUDA_SDK_SEARCH_PATH}
PATH_SUFFIXES "common/inc" "C/common/inc"
DOC "Location of cutil.h"
NO_DEFAULT_PATH
)
if (CUDA_CUT_INCLUDE_DIR)
cuda_include_directories (
${CUDA_CUT_INCLUDE_DIR}
)
endif ()
endif ()
# JAS 08.25.2010
# Check to make sure nvcc has gcc-4.3 for compiling.
# This script will modify CUDA_NVCC_FLAGS if system default is not gcc-4.3
include (nvcc-check)
# GCS 2017-10-24: Let CUDA work with gcc 6 and CUDA 8
if (CUDA_VERSION_MAJOR EQUAL "8"
AND CMAKE_COMPILER_IS_GNUCC
AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
list (APPEND CUDA_NVCC_FLAGS
--compiler-options -D__GNUC__=5)
endif ()
# JAS 2010.12.09
# Build code for all known compute capabilities by default.
# When developing, it is sometimes nice to turn this off in order
# to speed up the build processes (since you only have 1 GPU in your machine).
set (PLM_CUDA_ALL_DEVICES ON CACHE BOOL
"Generate GPU code for all compute capabilities?")
if (PLM_CUDA_ALL_DEVICES)
message (STATUS "CUDA Build Level: ALL Compute Capabilities")
if (CUDA_VERSION_MAJOR LESS "7")
message (STATUS " >> Generation 1: [X]")
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}
-gencode arch=compute_11,code=sm_11
-gencode arch=compute_12,code=sm_12
-gencode arch=compute_13,code=sm_13
)
if (CUDA_VERSION_MAJOR EQUAL "6")
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}
--Wno-deprecated-gpu-targets)
if (CUDA_VERSION_MINOR LESS "5")
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}
-gencode arch=compute_10,code=sm_10)
endif ()
else ()
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}
-gencode arch=compute_10,code=sm_10)
endif ()
else()
message (STATUS " >> Generation 1: [ ]")
endif()
if (CUDA_VERSION_MAJOR GREATER "2")
message (STATUS " >> Generation 2: [X]")
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}
-gencode arch=compute_20,code=sm_20
)
else()
message (STATUS " >> Generation 2: [ ]")
endif()
if (CUDA_VERSION_MAJOR GREATER "4")
message (STATUS " >> Generation 3: [X]")
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}
-gencode arch=compute_30,code=sm_30
)
else()
message (STATUS " >> Generation 3: [ ]")
endif()
if (CUDA_VERSION_MAJOR GREATER "5")
message (STATUS " >> Generation 5: [X]")
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}
-gencode arch=compute_50,code=sm_50
-gencode arch=compute_50,code=compute_50
)
else()
message (STATUS " >> Generation 5: [ ]")
endif()
#MESSAGE(STATUS "<<-->>: CUDA_NVCC_FLAGS set to \"${CUDA_NVCC_FLAGS}\"")
else ()
message (STATUS "CUDA Build Level: Build system Compute Capability ONLY!")
endif ()
# - find DCMTK libraries
#
# DCMTK_INCLUDE_DIR - Directories to include to use DCMTK
# DCMTK_LIBRARIES - Files to link against to use DCMTK
# DCMTK_FOUND - If false, don't try to use DCMTK
# DCMTK_DIR - (optional) Source directory for DCMTK
#
# DCMTK_VERSION_STRING - Like "3.5.4" or "3.6.0"
#
# DCMTK_DIR can be used to make it simpler to find the various include
# directories and compiled libraries if you've just compiled it in the
# source tree. Just set it to the root of the tree where you extracted
# the source.
#
# Written for VXL by Amitha Perera.
#
# On debian, require the following packages:
# libdcmtk1-dev
# libpng12-dev
# libtiff4-dev
# libwrap0-dev
include(CheckLibraryExists)
include(FindThreads)
set (DCMTK_DIR "" CACHE PATH "Root of DCMTK install tree (optional).")
find_package (ZLIB)
if (ZLIB_FOUND)
message (STATUS "Looking for ZLIB - found")
else ()
message (STATUS "Looking for ZLIB - not found")
endif ()
find_package (PNG)
if (PNG_FOUND)
message (STATUS "Looking for PNG - found")
else ()
message (STATUS "Looking for PNG - not found")
endif ()
find_package (TIFF)
if (TIFF_FOUND)
message (STATUS "Looking for TIFF - found")
else ()
message (STATUS "Looking for TIFF - not found")
endif ()
find_library (SSL_LIBRARY ssl)
if (SSL_LIBRARY)
message (STATUS "Looking for SSL - found: ${SSL_LIBRARY}")
else ()
message (STATUS "Looking for SSL - not found")
endif ()
find_path (DCMTK_INCLUDE_DIR
NAMES dcmtk/config/osconfig.h
HINTS
${DCMTK_DIR}/include
/usr/local/dicom/include
)
if (UNIX)
find_file (DCMTK_HAVE_CFUNIX_H dcmtk/config/cfunix.h
${DCMTK_DIR}/include
/usr/local/dicom/include
)
else ()
set (DCMTK_HAVE_CFUNIX_H FALSE)
endif ()
find_library (DCMTK_dcmimgle_LIBRARY
NAMES dcmimgle
HINTS
${DCMTK_DIR}/dcmimgle/libsrc
${DCMTK_DIR}/dcmimgle/libsrc/Release
${DCMTK_DIR}/dcmimgle/libsrc/Debug
${DCMTK_DIR}/dcmimgle/Release
${DCMTK_DIR}/dcmimgle/Debug
${DCMTK_DIR}/lib
/usr/lib/dcmtk
/usr/local/dicom/lib
)
# This is gone in 3.6
find_library (DCMTK_imagedb_LIBRARY
NAMES imagedb dcmimage
HINTS
${DCMTK_DIR}/imagectn/libsrc/Release
${DCMTK_DIR}/imagectn/libsrc/
${DCMTK_DIR}/imagectn/libsrc/Debug
${DCMTK_DIR}/lib/
/usr/lib/dcmtk
/usr/local/dicom/lib
)
find_library (DCMTK_dcmtls_LIBRARY
NAMES dcmtls
HINTS
${DCMTK_DIR}/dcmnet/libsrc/Release
${DCMTK_DIR}/dcmnet/libsrc/Debug
${DCMTK_DIR}/dcmnet/libsrc
${DCMTK_DIR}/dcmtls/libsrc/Release
${DCMTK_DIR}/dcmtls/libsrc/Debug
${DCMTK_DIR}/dcmtls/libsrc
${DCMTK_DIR}/lib
/usr/lib/dcmtk
/usr/local/dicom/lib
)
find_library (DCMTK_dcmnet_LIBRARY
NAMES dcmnet
HINTS
${DCMTK_DIR}/dcmnet/libsrc/Release
${DCMTK_DIR}/dcmnet/libsrc/Debug
${DCMTK_DIR}/dcmnet/libsrc/
${DCMTK_DIR}/lib/
/usr/lib/dcmtk
/usr/local/dicom/lib
)
find_library (DCMTK_dcmdata_LIBRARY
NAMES dcmdata
HINTS
${DCMTK_DIR}/dcmdata/libsrc
${DCMTK_DIR}/dcmdata/libsrc/Release
${DCMTK_DIR}/dcmdata/libsrc/Debug
${DCMTK_DIR}/dcmdata/Release
${DCMTK_DIR}/dcmdata/Debug
${DCMTK_DIR}/lib
/usr/lib/dcmtk
/usr/local/dicom/lib
)
# Quick hack: dcmtk 3.6.0
find_library (DCMTK_oflog_LIBRARY
NAMES oflog
HINTS
${DCMTK_DIR}/lib
/usr/lib/dcmtk
/usr/local/dicom/lib
)
find_library (DCMTK_ofstd_LIBRARY
NAMES ofstd
HINTS
${DCMTK_DIR}/ofstd/libsrc
${DCMTK_DIR}/ofstd/libsrc/Release
${DCMTK_DIR}/ofstd/libsrc/Debug
${DCMTK_DIR}/ofstd/Release
${DCMTK_DIR}/ofstd/Debug
${DCMTK_DIR}/lib
/usr/lib/dcmtk
/usr/local/dicom/lib
)
if (DCMTK_INCLUDE_DIR
AND DCMTK_dcmnet_LIBRARY