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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
project(ITKCommon)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH})
# Version string should not include patch level. The major.minor is
# enough to distinguish available features of the toolkit.
set(ITK_VERSION_STRING "${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}")
include(TestBigEndian)
test_big_endian(CMAKE_WORDS_BIGENDIAN)
include(FindThreads)
set(ITK_USE_WIN32_THREADS 0)
set(ITK_USE_PTHREADS 0)
set(ITK_HP_PTHREADS 0)
if(CMAKE_USE_WIN32_THREADS_INIT)
set(ITK_USE_WIN32_THREADS 1)
elseif(CMAKE_USE_PTHREADS_INIT AND NOT EMSCRIPTEN)
set(ITK_USE_PTHREADS 1)
elseif(CMAKE_HP_PTHREADS_INIT)
set(ITK_HP_PTHREADS 1)
endif()
set(CMAKE_THREAD_LIBS "${CMAKE_THREAD_LIBS_INIT}" CACHE STRING "Thread library used.")
mark_as_advanced(CMAKE_THREAD_LIBS)
#
# See if compiler preprocessor has the __FUNCTION__ directive used by itkExceptionMacro
#
include(CheckCPPDirective)
check_cpp_directive_exists(__FUNCTION__ ITK_CPP_FUNCTION)
include(CheckIncludeFiles)
# check if the platform has the header file "fenv.h" which has been added as part of the C99 standard
check_include_files(fenv.h HAVE_FENV_H)
# check if the platform has some widely used header files
check_include_files("unistd.h" HAVE_UNISTD_H)
# check if the platform has the header file "stdint.h" which has been added as part of the C99 standard
check_include_files("stdint.h" HAVE_STDINT_H)
# every system should have this header
check_include_files("stddef.h" HAVE_STDDEF_H)
check_include_files("sys/types.h" HAVE_SYS_TYPES_H)
# Check if this platform support the sse2 rounding functions for 32 and 64 bits
include(CheckSupportForSSERounding)
# Test for atomics and other compiler intrinsics
include(itkCheckBuiltins)
# Check for atomic functions
include(CheckSymbolExists)
if(WIN32 AND NOT MINGW)
check_symbol_exists(InterlockedAdd "windows.h" ITK_HAS_INTERLOCKEDADD)
endif()
# Check for the new C++11 alignas type specifier for future portable alignment
try_compile( ITK_HAS_CPP11_ALIGNAS
${ITK_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/CMake/itkCheckHasCPP11Alignas.cxx )
# Identify the version of CXX compiler used when ITK was built. This needs to be
# identified so that external applications can identify how ITK was built.
set(ITK_COMPILED_CXX_VERSION 1)
foreach(CXX_TEST_VERSION 199711L 201103L 201402L)
try_compile(ITK_MIN_CXX_LEVEL_TEST
${ITK_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/CMake/itkGetCXXCompilerVersion.cxx
COMPILE_DEFINITIONS -DITK_CXX_TEST_VERSION=${CXX_TEST_VERSION}
OUTPUT_VARIABLE ITK_COMPILED_CXX_VERSION_LOG )
if(ITK_MIN_CXX_LEVEL_TEST)
set(ITK_COMPILED_CXX_VERSION ${CXX_TEST_VERSION})
endif()
endforeach()
# check of the optional TR1 type_traits, alternative boost
# implementation could also be searched for
include(CheckIncludeFileCXX)
check_include_file_cxx( tr1/type_traits ITK_HAS_STLTR1_TR1_TYPE_TRAITS )
check_include_file_cxx( type_traits ITK_HAS_STLTR1_TYPE_TRAITS )
# Check for C++11 type_traits
try_compile( ITK_HAS_CPP11_TYPETRAITS
${ITK_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/CMake/itkCheckCxx11StlTypeTraits.cxx )
try_compile( ITK_HAS_GNU_ATTRIBUTE_ALIGNED
${ITK_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/CMake/itkCheckHasGNUAttributeAligned.cxx
CMAKE_FLAGS "-DCMAKE_BUILD_TYPE:STRING=Debug" )
set(ITK_WINDOWS_EXPORT_ALL_SYMBOLS ${CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS})
configure_file(src/itkConfigure.h.in itkConfigure.h)
set(ITKCommon_INCLUDE_DIRS
${ITKCommon_BINARY_DIR}
)
set(ITKCommon_LIBRARIES ITKCommon)
itk_module_impl()
install(FILES
${ITKCommon_BINARY_DIR}/itkConfigure.h
DESTINATION ${ITKCommon_INSTALL_INCLUDE_DIR}
COMPONENT Development
)
|