1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-07-22 18:57:39 +02:00

Use cmake's configure_file() as suggested by Evgeny Posenitskiy.

This commit is contained in:
Pablo Lopez Rios 2022-01-19 10:02:34 +00:00
parent 0e9b9f1900
commit 36a05c184d
3 changed files with 8 additions and 12 deletions

View File

@ -16,7 +16,7 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
# Optional configure for developer mode to generate source code from org-mode files.
option(TREXIO_DEVEL "TREXIO developer mode (for code generation)." OFF)
if(EXISTS ".git/config")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git/config")
set(TREXIO_DEVEL ON)
find_package(Python3 REQUIRED)
if(Python3_FOUND)
@ -32,6 +32,8 @@ if(EXISTS ".git/config")
else()
message(FATAL_ERROR "EMACS not found. It is required to produce TREXIO source code from org-mode files.")
endif()
configure_file(${CMAKE_SOURCE_DIR}/include/cmake_config.h.in
${CMAKE_SOURCE_DIR}/include/config.h)
endif()
# Set directories to be included at build time.

View File

@ -0,0 +1,5 @@
#define PACKAGE_VERSION "@PROJECT_VERSION@"
#define VERSION "@PROJECT_VERSION@"
#define VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define VERSION_MINOR @PROJECT_VERSION_MINOR@
#define VERSION_PATCH @PROJECT_VERSION_PATCH@

View File

@ -127,17 +127,6 @@ if(TREXIO_DEVEL)
${TREXIO_MOD_FILE}
PROPERTIES GENERATED TRUE)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/include/config.h
COMMAND bash -c "echo -e '#define TREXIO_PACKAGE_VERSION \"${PROJECT_VERSION}\"\\n#define TREXIO_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}\\n#define TREXIO_VERSION_MINOR ${PROJECT_VERSION_MINOR}\\n#define TREXIO_VERSION_PATCH ${PROJECT_VERSION_PATCH}' > config.h"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/include
COMMENT "Generates minimal include/config.h without using autotools."
VERBATIM)
set_source_files_properties(
${CMAKE_SOURCE_DIR}/include/config.h
PROPERTIES GENERATED TRUE)
endif()
# ============= INSTALL TREXIO ==============