diff options
Diffstat (limited to 'cmake/modules')
-rw-r--r-- | cmake/modules/GUDHI_compilation_flags.cmake | 72 | ||||
-rw-r--r-- | cmake/modules/GUDHI_third_party_libraries.cmake | 22 | ||||
-rw-r--r-- | cmake/modules/GUDHI_user_version_target.cmake | 6 |
3 files changed, 88 insertions, 12 deletions
diff --git a/cmake/modules/GUDHI_compilation_flags.cmake b/cmake/modules/GUDHI_compilation_flags.cmake new file mode 100644 index 00000000..a01d6e13 --- /dev/null +++ b/cmake/modules/GUDHI_compilation_flags.cmake @@ -0,0 +1,72 @@ +# This files manage compilation flags required by GUDHI + +include(TestCXXAcceptsFlag) +include(CheckCXXSourceCompiles) + +# add a compiler flag only if it is accepted +macro(add_cxx_compiler_flag _flag) + string(REPLACE "-" "_" _flag_var ${_flag}) + check_cxx_accepts_flag("${_flag}" CXX_COMPILER_${_flag_var}_OK) + if(CXX_COMPILER_${_flag_var}_OK) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}") + endif() +endmacro() + +function(can_cgal_use_cxx11_thread_local) + # This is because of https://github.com/CGAL/cgal/blob/master/Installation/include/CGAL/tss.h + # CGAL is using boost thread if thread_local is not ready (requires XCode 8 for Mac). + # The test in https://github.com/CGAL/cgal/blob/master/Installation/include/CGAL/config.h + # #if __has_feature(cxx_thread_local) || \ + # ( (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L ) || \ + # ( _MSC_VER >= 1900 ) + # #define CGAL_CAN_USE_CXX11_THREAD_LOCAL + # #endif + set(CGAL_CAN_USE_CXX11_THREAD_LOCAL " + int main() { + #ifndef __has_feature + #define __has_feature(x) 0 // Compatibility with non-clang compilers. + #endif + #if __has_feature(cxx_thread_local) || \ + ( (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L ) || \ + ( _MSC_VER >= 1900 ) + bool has_feature_thread_local = true; + #else + // Explicit error of compilation for CMake test purpose - has_feature_thread_local is not defined + #endif + bool result = has_feature_thread_local; + } ") + check_cxx_source_compiles("${CGAL_CAN_USE_CXX11_THREAD_LOCAL}" CGAL_CAN_USE_CXX11_THREAD_LOCAL_RESULT) +endfunction() + +set (CMAKE_CXX_STANDARD 11) + +enable_testing() + +if(MSVC) + # Turn off some VC++ warnings + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4668 /wd4311 /wd4800 /wd4820 /wd4503 /wd4244 /wd4345 /wd4996 /wd4396 /wd4018") +endif() + +add_cxx_compiler_flag("-Wall") + +if (DEBUG_TRACES) + # For programs to be more verbose + message(STATUS "DEBUG_TRACES are activated") + add_definitions(-DDEBUG_TRACES) +endif() + +set(GUDHI_CAN_USE_CXX11_THREAD_LOCAL " + int main() { + thread_local int result = 0; + return result; + } ") +check_cxx_source_compiles("${GUDHI_CAN_USE_CXX11_THREAD_LOCAL}" GUDHI_CAN_USE_CXX11_THREAD_LOCAL_RESULT) +if (GUDHI_CAN_USE_CXX11_THREAD_LOCAL_RESULT) + add_definitions(-DGUDHI_CAN_USE_CXX11_THREAD_LOCAL) +endif() + +if(CMAKE_BUILD_TYPE MATCHES Debug) + message("++ Debug compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}") +else() + message("++ Release compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") +endif() diff --git a/cmake/modules/GUDHI_third_party_libraries.cmake b/cmake/modules/GUDHI_third_party_libraries.cmake index 419c2581..7433f2f3 100644 --- a/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/cmake/modules/GUDHI_third_party_libraries.cmake @@ -54,23 +54,27 @@ if(CGAL_FOUND) endforeach(CGAL_INCLUDE_DIR ${CGAL_INCLUDE_DIRS}) endif(NOT CGAL_VERSION VERSION_GREATER 4.9.0) - if (NOT CGAL_VERSION VERSION_GREATER 4.11.0) + if (CGAL_VERSION VERSION_LESS 4.11.0) # For dev version include_directories(BEFORE "src/common/include/gudhi_patches") # For user version include_directories(BEFORE "include/gudhi_patches") - endif (NOT CGAL_VERSION VERSION_GREATER 4.11.0) + endif () endif() endif() +option(WITH_GUDHI_USE_TBB "Build with Intel TBB parallelization" ON) + # Find TBB package for parallel sort - not mandatory, just optional. -set(TBB_FIND_QUIETLY ON) -find_package(TBB) -if (TBB_FOUND) - include(${TBB_USE_FILE}) - message("TBB found in ${TBB_LIBRARY_DIRS}") - add_definitions(-DGUDHI_USE_TBB) -endif() +if(WITH_GUDHI_USE_TBB) + set(TBB_FIND_QUIETLY ON) + find_package(TBB) + if (TBB_FOUND) + include(${TBB_USE_FILE}) + message("TBB found in ${TBB_LIBRARY_DIRS}") + add_definitions(-DGUDHI_USE_TBB) + endif() +endif(WITH_GUDHI_USE_TBB) set(CGAL_WITH_EIGEN3_VERSION 0.0.0) find_package(Eigen3 3.1.0) diff --git a/cmake/modules/GUDHI_user_version_target.cmake b/cmake/modules/GUDHI_user_version_target.cmake index 4abc2574..1205966a 100644 --- a/cmake/modules/GUDHI_user_version_target.cmake +++ b/cmake/modules/GUDHI_user_version_target.cmake @@ -48,10 +48,10 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.11) copy_directory ${CMAKE_SOURCE_DIR}/src/GudhUI ${GUDHI_USER_VERSION_DIR}/GudhUI) set(GUDHI_DIRECTORIES "doc;example;concept;utilities") - if (NOT CGAL_VERSION VERSION_GREATER 4.11.0) - set(GUDHI_INCLUDE_DIRECTORIES "include/gudhi;include/gudhi_patches") + if (CGAL_VERSION VERSION_LESS 4.11.0) + set(GUDHI_INCLUDE_DIRECTORIES "include/gudhi;include/Miniball;include/gudhi_patches") else () - set(GUDHI_INCLUDE_DIRECTORIES "include/gudhi") + set(GUDHI_INCLUDE_DIRECTORIES "include/gudhi;include/Miniball") endif () foreach(GUDHI_MODULE ${GUDHI_MODULES_FULL_LIST}) |