2022-11-24 02:08:04 +01:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
2020-09-03 13:05:49 +02:00
|
|
|
|
2022-11-24 02:08:04 +01:00
|
|
|
project(cnorxz)
|
2017-02-17 18:10:03 +01:00
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# LIB VERSION
|
|
|
|
|
|
|
|
set(VERSION_PART "pre")
|
|
|
|
set(VERSION_TAG_HASH "6857e3fc7d0af25db3a925791d1cabc6342b930a")
|
|
|
|
|
|
|
|
# OPTIONS
|
|
|
|
|
|
|
|
option(SCALAR_BUILD "" OFF)
|
|
|
|
|
|
|
|
# INCLUDES
|
|
|
|
|
2023-11-20 00:41:37 +01:00
|
|
|
include(cmake/check_avx.cmake)
|
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# GIT VARIABLES
|
|
|
|
|
2023-02-22 02:38:51 +01:00
|
|
|
execute_process(COMMAND bash "-c" "git rev-parse HEAD" OUTPUT_VARIABLE GIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2024-01-02 20:43:05 +01:00
|
|
|
execute_process(COMMAND bash "-c" "git rev-parse --abbrev-ref HEAD" OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
|
|
|
# BUILD / CHECK VERSION STRING
|
|
|
|
|
2023-08-31 12:30:46 +02:00
|
|
|
message(STATUS "${GIT_HASH}")
|
2024-01-02 20:43:05 +01:00
|
|
|
message(STATUS "${VERSION_PART}")
|
|
|
|
message(STATUS "${VERSION_TAG_HASH}")
|
|
|
|
set(VERSION "${VERSION_PART}")
|
|
|
|
if(NOT ("${GIT_BRANCH}" EQUAL "release"))
|
|
|
|
if(NOT ("${GIT_HASH}" EQUAL "${VERSION_TAG_HASH}"))
|
2023-08-31 12:50:29 +02:00
|
|
|
string(SUBSTRING ${GIT_HASH} 0 7 GIT_HASH_SHORT)
|
2024-01-02 20:43:05 +01:00
|
|
|
set(VERSION "${VERSION}-${GIT_BRANCH}-${GIT_HASH_SHORT}")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if(NOT ("${GIT_HASH}" EQUAL "${VERSION_TAG_HASH}"))
|
|
|
|
message(FATAL_ERROR "version mash-up, do not use, contact maintainer")
|
2023-08-31 12:50:29 +02:00
|
|
|
endif()
|
2023-02-22 02:38:51 +01:00
|
|
|
endif()
|
2023-08-31 13:16:56 +02:00
|
|
|
message(STATUS "version = ${VERSION}")
|
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# CHECK COMPILER
|
|
|
|
|
2020-09-03 13:05:49 +02:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0)
|
|
|
|
message(FATAL_ERROR "require gcc version >= 7.0")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message(WARNING "compiler ${CMAKE_CXX_COMPILER_ID} officially not supported")
|
|
|
|
endif()
|
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# FLAGS
|
|
|
|
|
2022-12-04 21:57:18 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -std=c++17 -Wpedantic -O2 -march=native -faligned-new -funroll-loops -fopenmp")
|
2017-02-17 18:10:03 +01:00
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# TESTING
|
|
|
|
|
2017-03-23 21:05:40 +01:00
|
|
|
enable_testing()
|
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# INSTALL PATH
|
|
|
|
|
2018-11-05 15:43:31 +01:00
|
|
|
if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
set(INSTALL_PATH ${CMAKE_INSTALL_PREFIX})
|
|
|
|
else()
|
|
|
|
#set(INSTALL_PATH ${CMAKE_SOURCE_DIR}/install)
|
|
|
|
get_filename_component(INSTALL_PATH ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX} ABSOLUTE)
|
|
|
|
endif()
|
2022-11-24 02:08:04 +01:00
|
|
|
message(STATUS "found absolute install path '${INSTALL_PATH}'")
|
2018-02-14 16:44:55 +01:00
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# SCALAR / INTRINSICS
|
|
|
|
|
2023-11-20 00:41:37 +01:00
|
|
|
if(NOT ${SCALAR_BUILD})
|
|
|
|
message(STATUS "check for intrinsics")
|
|
|
|
check_avx()
|
|
|
|
if(AVX_AVAIL)
|
|
|
|
message(STATUS "AVX available")
|
|
|
|
add_definitions("-DCXZ_HAVE_AVX")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
|
|
|
else()
|
|
|
|
message(STATUS "AVX not available")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# CHECK LIBRARIES : GTest
|
|
|
|
|
2023-11-20 00:41:37 +01:00
|
|
|
message(STATUS "check for libraries")
|
2017-02-17 18:10:03 +01:00
|
|
|
find_package( GTest REQUIRED )
|
|
|
|
if(GTest_FOUND)
|
|
|
|
include_directories(${GTEST_INCLUDE_DIRS})
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "GTest not found")
|
|
|
|
endif()
|
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# CHECK LIBRARIES : Threads
|
|
|
|
|
2017-11-20 22:30:07 +01:00
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
if(Threads_FOUND)
|
2017-12-18 14:02:37 +01:00
|
|
|
#include_directories(${Threads_INCLUDE_DIRS})
|
2017-11-20 22:30:07 +01:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Threads not found")
|
|
|
|
endif()
|
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# CHECK LIBRARIES : hdf5
|
|
|
|
|
2023-01-13 01:40:19 +01:00
|
|
|
if(DEFINED ENABLE_hdf5)
|
|
|
|
set(ENABLE_hdf5 ${ENABLE_hdf5} CACHE BOOL "enable hdf5")
|
|
|
|
else()
|
|
|
|
set(ENABLE_hdf5 TRUE CACHE BOOL "enable hdf5")
|
|
|
|
endif()
|
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# CHECK LIBRARIES : cereal
|
|
|
|
|
2023-02-27 20:09:06 +01:00
|
|
|
if(DEFINED ENABLE_cereal)
|
|
|
|
set(ENABLE_cereal ${ENABLE_cereal} CACHE BOOL "enable hdf5")
|
|
|
|
else()
|
|
|
|
set(ENABLE_cereal TRUE CACHE BOOL "enable hdf5")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(cereal QUIET)
|
|
|
|
if(cereal_FOUND)
|
|
|
|
message(STATUS "found cereal")
|
2023-05-09 16:22:25 +02:00
|
|
|
if(ENABLE_cereal)
|
|
|
|
message(STATUS "enable cereal")
|
|
|
|
add_definitions(-DHAVE_CEREAL)
|
|
|
|
endif()
|
2023-02-27 20:09:06 +01:00
|
|
|
else()
|
|
|
|
message(STATUS "no cereal")
|
|
|
|
if(ENABLE_cereal)
|
|
|
|
message(FATAL_ERROR "cereal has been enabled but the cereal library has not been found")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# DEFINES
|
|
|
|
|
2023-02-22 02:38:51 +01:00
|
|
|
add_definitions(-DVERSION="${VERSION}")
|
|
|
|
add_definitions(-DGIT_COMMIT="${GIT_HASH}")
|
|
|
|
add_definitions(-DCXX_FLAGS="${CMAKE_CXX_FLAGS}")
|
|
|
|
|
2024-01-02 20:43:05 +01:00
|
|
|
# CONTINUE WITH SUB-DIRECTORIES
|
|
|
|
|
2018-02-14 16:44:55 +01:00
|
|
|
add_subdirectory(src)
|