dev #2

Merged
chizeta merged 32 commits from dev into main 2024-02-02 20:36:53 +01:00
Showing only changes of commit ab13d97b03 - Show all commits

View file

@ -2,27 +2,44 @@ cmake_minimum_required(VERSION 3.0)
project(cnorxz) project(cnorxz)
# LIB VERSION
set(VERSION_PART "pre")
set(VERSION_TAG_HASH "6857e3fc7d0af25db3a925791d1cabc6342b930a")
# OPTIONS
option(SCALAR_BUILD "" OFF)
# INCLUDES
include(cmake/check_avx.cmake) include(cmake/check_avx.cmake)
# GIT VARIABLES
execute_process(COMMAND bash "-c" "git rev-parse HEAD" OUTPUT_VARIABLE GIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND bash "-c" "git rev-parse HEAD" OUTPUT_VARIABLE GIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND bash "-c" "git tag -l --sort=refname 'v*' | tail -n1" OUTPUT_VARIABLE GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND bash "-c" "git rev-parse --abbrev-ref HEAD" OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND bash "-c" "git rev-list -n 1 ${GIT_TAG}" OUTPUT_VARIABLE GIT_TAG_HASH OUTPUT_STRIP_TRAILING_WHITESPACE)
# BUILD / CHECK VERSION STRING
message(STATUS "${GIT_HASH}") message(STATUS "${GIT_HASH}")
option(RUN_PIPELINE "" OFF) message(STATUS "${VERSION_PART}")
option(SCALAR_BUILD "" OFF) message(STATUS "${VERSION_TAG_HASH}")
if(RUN_PIPELINE) set(VERSION "${VERSION_PART}")
set(VERSION "v0.0.0-test") if(NOT ("${GIT_BRANCH}" EQUAL "release"))
else() if(NOT ("${GIT_HASH}" EQUAL "${VERSION_TAG_HASH}"))
message(STATUS "${GIT_TAG}")
message(STATUS "${GIT_TAG_HASH}")
string(SUBSTRING "${GIT_TAG}" 1 -1 VERSION)
if(NOT ("${GIT_HASH}" EQUAL "${GIT_TAG_HASH}"))
string(SUBSTRING ${GIT_HASH} 0 7 GIT_HASH_SHORT) string(SUBSTRING ${GIT_HASH} 0 7 GIT_HASH_SHORT)
set(VERSION "${VERSION}-${GIT_HASH_SHORT}") 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")
endif() endif()
endif() endif()
message(STATUS "version = ${VERSION}") message(STATUS "version = ${VERSION}")
# CHECK COMPILER
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0) if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0)
message(FATAL_ERROR "require gcc version >= 7.0") message(FATAL_ERROR "require gcc version >= 7.0")
@ -31,10 +48,16 @@ else()
message(WARNING "compiler ${CMAKE_CXX_COMPILER_ID} officially not supported") message(WARNING "compiler ${CMAKE_CXX_COMPILER_ID} officially not supported")
endif() endif()
# FLAGS
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -std=c++17 -Wpedantic -O2 -march=native -faligned-new -funroll-loops -fopenmp") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -std=c++17 -Wpedantic -O2 -march=native -faligned-new -funroll-loops -fopenmp")
# TESTING
enable_testing() enable_testing()
# INSTALL PATH
if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}")
set(INSTALL_PATH ${CMAKE_INSTALL_PREFIX}) set(INSTALL_PATH ${CMAKE_INSTALL_PREFIX})
else() else()
@ -43,6 +66,8 @@ else()
endif() endif()
message(STATUS "found absolute install path '${INSTALL_PATH}'") message(STATUS "found absolute install path '${INSTALL_PATH}'")
# SCALAR / INTRINSICS
if(NOT ${SCALAR_BUILD}) if(NOT ${SCALAR_BUILD})
message(STATUS "check for intrinsics") message(STATUS "check for intrinsics")
check_avx() check_avx()
@ -55,6 +80,8 @@ if(NOT ${SCALAR_BUILD})
endif() endif()
endif() endif()
# CHECK LIBRARIES : GTest
message(STATUS "check for libraries") message(STATUS "check for libraries")
find_package( GTest REQUIRED ) find_package( GTest REQUIRED )
if(GTest_FOUND) if(GTest_FOUND)
@ -63,6 +90,8 @@ else()
message(FATAL_ERROR "GTest not found") message(FATAL_ERROR "GTest not found")
endif() endif()
# CHECK LIBRARIES : Threads
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
if(Threads_FOUND) if(Threads_FOUND)
#include_directories(${Threads_INCLUDE_DIRS}) #include_directories(${Threads_INCLUDE_DIRS})
@ -70,12 +99,16 @@ else()
message(FATAL_ERROR "Threads not found") message(FATAL_ERROR "Threads not found")
endif() endif()
# CHECK LIBRARIES : hdf5
if(DEFINED ENABLE_hdf5) if(DEFINED ENABLE_hdf5)
set(ENABLE_hdf5 ${ENABLE_hdf5} CACHE BOOL "enable hdf5") set(ENABLE_hdf5 ${ENABLE_hdf5} CACHE BOOL "enable hdf5")
else() else()
set(ENABLE_hdf5 TRUE CACHE BOOL "enable hdf5") set(ENABLE_hdf5 TRUE CACHE BOOL "enable hdf5")
endif() endif()
# CHECK LIBRARIES : cereal
if(DEFINED ENABLE_cereal) if(DEFINED ENABLE_cereal)
set(ENABLE_cereal ${ENABLE_cereal} CACHE BOOL "enable hdf5") set(ENABLE_cereal ${ENABLE_cereal} CACHE BOOL "enable hdf5")
else() else()
@ -96,8 +129,12 @@ else()
endif() endif()
endif() endif()
# DEFINES
add_definitions(-DVERSION="${VERSION}") add_definitions(-DVERSION="${VERSION}")
add_definitions(-DGIT_COMMIT="${GIT_HASH}") add_definitions(-DGIT_COMMIT="${GIT_HASH}")
add_definitions(-DCXX_FLAGS="${CMAKE_CXX_FLAGS}") add_definitions(-DCXX_FLAGS="${CMAKE_CXX_FLAGS}")
# CONTINUE WITH SUB-DIRECTORIES
add_subdirectory(src) add_subdirectory(src)