mirror of
https://github.com/TREX-CoE/trexio.git
synced 2025-01-03 10:06:01 +01:00
Fix cmake compilation.
This includes: * Declare generated source files in include/ as GENERATED in TREXIO_DEVEL mode. * Generate include/config.h with version components from project delcaration, and for good measure have src/templates_front/build.sh set version components to 0 if not present.
This commit is contained in:
parent
e4073d0a8c
commit
12a7454c0c
@ -91,6 +91,8 @@ FortranCInterface_VERIFY()
|
||||
|
||||
# Fortran module
|
||||
set(TREXIO_MOD_FILE ${CMAKE_SOURCE_DIR}/include/trexio_f.f90)
|
||||
# Export to parent scope so tests directory picks this up.
|
||||
set(TREXIO_MOD_FILE ${TREXIO_MOD_FILE} PARENT_SCOPE)
|
||||
# Add TREXIO Fortran module as a library.
|
||||
add_library(trexio_f SHARED)
|
||||
target_sources(trexio_f PUBLIC ${TREXIO_MOD_FILE})
|
||||
@ -114,10 +116,28 @@ if(TREXIO_DEVEL)
|
||||
${TREXIO_PRIVATE_HEADERS}
|
||||
${TREXIO_MOD_FILE}
|
||||
COMMAND ./build_trexio.sh
|
||||
DEPENDS ${ORG_FILES}
|
||||
DEPENDS ${ORG_FILES} ${CMAKE_SOURCE_DIR}/include/config.h
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tools
|
||||
COMMENT "Generating TREXIO source code from org-mode files."
|
||||
VERBATIM)
|
||||
|
||||
set_source_files_properties(${TREXIO_SOURCES}
|
||||
${TREXIO_PUBLIC_HEADERS}
|
||||
${TREXIO_PRIVATE_HEADERS}
|
||||
${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 ==============
|
||||
|
@ -12,10 +12,10 @@ VERSION_PATCH_VAL=`grep "VERSION_PATCH" ../../include/config.h | cut -d " " -f 3
|
||||
|
||||
# grep some usefull constants from the config.h
|
||||
echo "" >> trexio.h
|
||||
echo "#define TREXIO_PACKAGE_VERSION ${VERSION_VAL}" >> trexio.h
|
||||
echo "#define TREXIO_VERSION_MAJOR ${VERSION_MAJOR_VAL}" >> trexio.h
|
||||
echo "#define TREXIO_VERSION_MINOR ${VERSION_MINOR_VAL}" >> trexio.h
|
||||
echo "#define TREXIO_VERSION_PATCH ${VERSION_PATCH_VAL}" >> trexio.h
|
||||
echo "#define TREXIO_PACKAGE_VERSION ${VERSION_VAL:='0.0.0'}" >> trexio.h
|
||||
echo "#define TREXIO_VERSION_MAJOR ${VERSION_MAJOR_VAL:=0}" >> trexio.h
|
||||
echo "#define TREXIO_VERSION_MINOR ${VERSION_MINOR_VAL:=0}" >> trexio.h
|
||||
echo "#define TREXIO_VERSION_PATCH ${VERSION_PATCH_VAL:=0}" >> trexio.h
|
||||
echo "" >> trexio.h
|
||||
|
||||
cat prefix_s_front.h > trexio_s.h
|
||||
|
@ -44,4 +44,8 @@ endforeach()
|
||||
# Add Fortran test and link it with trexio_f (Fortran module) library.
|
||||
add_executable(test_f test_f.f90)
|
||||
target_link_libraries(test_f PRIVATE trexio_f)
|
||||
if(TREXIO_DEVEL)
|
||||
set_source_files_properties(${TREXIO_MOD_FILE}
|
||||
PROPERTIES GENERATED TRUE)
|
||||
endif()
|
||||
add_test(NAME test_f COMMAND $<TARGET_FILE:test_f>)
|
||||
|
Loading…
Reference in New Issue
Block a user