mirror of
https://github.com/TREX-CoE/trexio.git
synced 2025-01-03 10:06:01 +01:00
Use cmake's configure_file() as suggested by Evgeny Posenitskiy.
This commit is contained in:
parent
0e9b9f1900
commit
36a05c184d
@ -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.
|
||||
|
5
include/cmake_config.h.in
Normal file
5
include/cmake_config.h.in
Normal 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@
|
@ -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 ==============
|
||||
|
Loading…
Reference in New Issue
Block a user