https://github.com/yahoojapan/NGT
Tip revision: a9ba21880e212d0be5893098d4fefaafbcae51e4 authored by Masajiro Iwasaki on 26 December 2022, 04:28:27 UTC
update the version
update the version
Tip revision: a9ba218
CMakeLists.txt
if(APPLE)
cmake_minimum_required(VERSION 3.0)
else()
cmake_minimum_required(VERSION 2.8)
endif()
project(ngt)
file(STRINGS "VERSION" ngt_VERSION)
message(STATUS "VERSION: ${ngt_VERSION}")
string(REGEX MATCH "^[0-9]+" ngt_VERSION_MAJOR ${ngt_VERSION})
set(ngt_VERSION ${ngt_VERSION})
set(ngt_SOVERSION ${ngt_VERSION_MAJOR})
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release")
endif (NOT CMAKE_BUILD_TYPE)
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_BUILD_TYPE_LOWER: ${CMAKE_BUILD_TYPE_LOWER}")
if(${UNIX})
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
if(CMAKE_VERSION VERSION_LESS 3.1)
set(BASE_OPTIONS "-Wall -std=gnu++0x -lrt")
if(${NGT_AVX_DISABLED})
message(STATUS "AVX will not be used to compute distances.")
endif()
if(${NGT_OPENMP_DISABLED})
message(STATUS "OpenMP is disabled.")
else()
set(BASE_OPTIONS "${BASE_OPTIONS} -fopenmp")
endif()
if(${NGT_ASSERT_DISABLED})
message(STATUS "assert() is disabled.")
set(BASE_OPTIONS "${BASE_OPTIONS} -DNDEBUG")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "-g ${BASE_OPTIONS}")
if(${NGT_MARCH_NATIVE_DISABLED})
message(STATUS "Compile option -march=native is disabled.")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 ${BASE_OPTIONS}")
else()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native ${BASE_OPTIONS}")
endif()
else()
if (CMAKE_BUILD_TYPE_LOWER STREQUAL "release")
set(CMAKE_CXX_FLAGS_RELEASE "")
if(${NGT_MARCH_NATIVE_DISABLED})
message(STATUS "Compile option -march=native is disabled.")
add_compile_options(-O2 -DNDEBUG)
else()
if(${NGT_AVX2})
add_compile_options(-Ofast -march=haswell -DNDEBUG)
else()
add_compile_options(-Ofast -march=native -DNDEBUG)
endif()
endif()
endif()
add_compile_options(-Wall)
if(${NGT_AVX_DISABLED})
message(STATUS "AVX will not be used to compute distances.")
endif()
if(${NGT_OPENMP_DISABLED})
message(STATUS "OpenMP is disabled.")
else()
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.1.0")
message(FATAL_ERROR "Insufficient AppleClang version")
endif()
cmake_minimum_required(VERSION 3.16)
endif()
find_package(OpenMP REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
set(CMAKE_CXX_STANDARD 11) # for std::unordered_set, std::unique_ptr
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Threads REQUIRED)
if(${NGT_QBG_DISABLED})
message(STATUS "QBG is disabled.")
else()
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
endif()
endif()
add_subdirectory("${PROJECT_SOURCE_DIR}/lib")
add_subdirectory("${PROJECT_SOURCE_DIR}/bin")
add_subdirectory("${PROJECT_SOURCE_DIR}/samples")
endif( ${UNIX} )