2021-11-13 19:01:21 +01:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
|
2021-11-13 19:49:02 +01:00
|
|
|
# =========== SETUP THE PROJECT =============
|
|
|
|
|
2021-11-15 11:16:28 +01:00
|
|
|
# Initialize the CMake project.
|
2021-12-27 16:26:17 +01:00
|
|
|
project(Trexio
|
2023-10-27 13:07:48 +02:00
|
|
|
VERSION 2.5.0
|
2021-12-27 16:26:17 +01:00
|
|
|
DESCRIPTION "TREX I/O library"
|
2021-11-13 19:01:21 +01:00
|
|
|
LANGUAGES C Fortran
|
|
|
|
)
|
|
|
|
|
2021-11-15 11:16:28 +01:00
|
|
|
# Request the C99 standard.
|
2021-11-13 19:01:21 +01:00
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
|
2021-11-16 17:52:05 +01:00
|
|
|
# Optional configure for developer mode to generate source code from org-mode files.
|
|
|
|
option(TREXIO_DEVEL "TREXIO developer mode (for code generation)." OFF)
|
|
|
|
|
2022-09-26 17:06:04 +02:00
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/.devel")
|
2021-11-16 17:52:05 +01:00
|
|
|
set(TREXIO_DEVEL ON)
|
2021-11-17 10:07:19 +01:00
|
|
|
find_package(Python3 REQUIRED)
|
2021-11-16 17:52:05 +01:00
|
|
|
if(Python3_FOUND)
|
2021-11-17 10:07:19 +01:00
|
|
|
if(Python3_VERSION_MINOR LESS 6)
|
|
|
|
message(FATAL_ERROR "Required Python3 version :: >= 3.6; Found :: ${Python3_VERSION}")
|
|
|
|
else()
|
|
|
|
message(STATUS "Python3 version :: ${Python3_VERSION}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
find_program(EMACS NAMES emacs REQUIRED)
|
|
|
|
if(NOT EMACS-NOTFOUND)
|
|
|
|
message(STATUS "EMACS detected :: ${EMACS}")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "EMACS not found. It is required to produce TREXIO source code from org-mode files.")
|
2021-11-16 17:52:05 +01:00
|
|
|
endif()
|
2022-01-20 14:56:10 +01:00
|
|
|
# in case Git is not available, we default to "unknown"
|
|
|
|
set(GIT_HASH "unknown")
|
|
|
|
# find Git and if available set GIT_HASH variable
|
|
|
|
find_package(Git QUIET)
|
|
|
|
if(GIT_FOUND)
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${GIT_EXECUTABLE} --no-pager show -s --pretty=format:%H -n 1
|
|
|
|
OUTPUT_VARIABLE GIT_HASH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
|
|
ERROR_QUIET)
|
|
|
|
endif()
|
|
|
|
# get the user name from the ${USER} env variable
|
|
|
|
set(TREXIO_USER_NAME $ENV{USER})
|
|
|
|
# replace placeholders in the templace config.h.in file to produce config.h
|
|
|
|
# config.h is needed to insert TREXIO_PACKAGE_VERSION and TREXIO_GIT_HASH into trexio.h
|
2022-01-19 11:02:34 +01:00
|
|
|
configure_file(${CMAKE_SOURCE_DIR}/include/cmake_config.h.in
|
2022-01-20 17:32:01 +01:00
|
|
|
${CMAKE_SOURCE_DIR}/include/config.h
|
|
|
|
@ONLY)
|
2021-11-16 17:52:05 +01:00
|
|
|
endif()
|
|
|
|
|
2021-11-15 11:16:28 +01:00
|
|
|
# Set directories to be included at build time.
|
2021-11-13 19:49:02 +01:00
|
|
|
include_directories(include)
|
2021-11-13 19:01:21 +01:00
|
|
|
|
2021-11-17 14:00:35 +01:00
|
|
|
# Add subdirectory with add_library(trexio) specifications.
|
|
|
|
add_subdirectory(src)
|
2021-11-13 19:49:02 +01:00
|
|
|
|
2021-11-17 14:00:35 +01:00
|
|
|
# Add subdirectory with unit tests.
|
2021-11-13 19:49:02 +01:00
|
|
|
enable_testing()
|
2021-11-17 14:00:35 +01:00
|
|
|
add_subdirectory(tests)
|