Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
build/*
33 changes: 31 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ endif()
option(WITH_FORTRAN "Fortran interface" on)
if(WITH_FORTRAN)
add_definitions(-DWITH_FORTRAN)
enable_language(Fortran)
message("Enable Fortran interface")
else()
message("Exclude Fortran interface")
Expand All @@ -149,7 +150,7 @@ else()
endif(WITH_CINT2_INTERFACE)

option(BUILD_SHARED_LIBS "build shared libraries" 1)
option(ENABLE_EXAMPLE "build examples" 0)
option(ENABLE_EXAMPLE "build examples" 1)
option(ENABLE_TEST "build tests" 0)
option(ENABLE_STATIC "Enforce static library build" 0)
if(QUICK_TEST)
Expand Down Expand Up @@ -187,14 +188,42 @@ if(QUADMATH_FOUND)
endif()
target_link_libraries(cint "-lm")

# Fortran interface modules
if(WITH_FORTRAN)
add_library(cint_fortran OBJECT
${PROJECT_SOURCE_DIR}/include/libcint_interface.f90
${PROJECT_SOURCE_DIR}/include/libcint_fortran.f90)
target_link_libraries(cint_fortran PUBLIC cint)
set_target_properties(cint_fortran PROPERTIES
Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/include)
target_include_directories(cint_fortran PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
endif()



install(TARGETS cint COMPONENT "lib")
install(FILES ${CintHeaders} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT "dev")

if(WITH_FORTRAN)
# Install Fortran source files
install(FILES
${PROJECT_SOURCE_DIR}/include/libcint_interface.f90
${PROJECT_SOURCE_DIR}/include/libcint_fortran.f90
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT "dev")
# Install Fortran module files (.mod)
install(DIRECTORY ${PROJECT_BINARY_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT "dev"
FILES_MATCHING PATTERN "*.mod")
endif()


if(ENABLE_EXAMPLE)
enable_language(Fortran)
if(NOT WITH_FORTRAN)
enable_language(Fortran)
endif()
find_package(OpenMP)
if(OPENMP_FOUND)
set(HAVE_OPENMP 1)
Expand Down
61 changes: 50 additions & 11 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
add_executable(cartesian_c c_call_cartesian.c )
add_executable(spheric_c c_call_spheric.c )
add_executable(spinor_c c_call_spinor.c )
add_executable(cartesian_f fortran_call_cartesian.F90)
add_executable(spheric_f fortran_call_spheric.F90 )
add_executable(spinor_f fortran_call_spinor.F90 )
add_executable(time_c2h6 time_c2h6.c )
add_executable(time_c60 time_c60.c )
# C examples
add_executable(cartesian_c c_call_cartesian.c)
add_executable(spheric_c c_call_spheric.c)
add_executable(spinor_c c_call_spinor.c)
add_executable(time_c2h6 time_c2h6.c)
add_executable(time_c60 time_c60.c)

target_link_libraries(cartesian_c cint m)
target_link_libraries(spheric_c cint m)
target_link_libraries(spinor_c cint m)
target_link_libraries(cartesian_f cint m)
target_link_libraries(spheric_f cint m)
target_link_libraries(spinor_f cint m)

target_link_libraries(time_c2h6 cint m)
target_link_libraries(time_c60 cint m)

Expand All @@ -23,3 +19,46 @@ set_target_properties(time_c60 PROPERTIES
COMPILE_FLAGS ${OpenMP_C_FLAGS}
LINK_FLAGS ${OpenMP_C_FLAGS})

if(WITH_FORTRAN)

add_executable(cartesian_f fortran/fortran_call_cartesian.F90)
add_executable(spheric_f fortran/fortran_call_spheric.F90)
add_executable(spinor_f fortran/fortran_call_spinor.F90)

add_executable(modern_cartesian_f fortran/fortran_modern_cartesian.F90)
add_executable(modern_spheric_f fortran/fortran_modern_spheric.F90)
add_executable(modern_spinor_f fortran/fortran_modern_spinor.F90)

add_executable(pure_fortran_f fortran/fortran_pure_example.F90)

add_executable(time_c2h6_f fortran/fortran_time_c2h6.F90)
add_executable(time_c2h6_pure_f fortran/fortran_time_c2h6_pure.F90)

target_link_libraries(cartesian_f cint m)
target_link_libraries(spheric_f cint m)
target_link_libraries(spinor_f cint m)

target_link_libraries(modern_cartesian_f cint_fortran cint m)
target_link_libraries(modern_spheric_f cint_fortran cint m)
target_link_libraries(modern_spinor_f cint_fortran cint m)
target_link_libraries(pure_fortran_f cint_fortran cint m)
target_link_libraries(time_c2h6_f cint_fortran cint m)
target_link_libraries(time_c2h6_pure_f cint_fortran cint m)

# Set module directory for Fortran examples
target_include_directories(modern_cartesian_f PRIVATE ${PROJECT_BINARY_DIR}/include)
target_include_directories(modern_spheric_f PRIVATE ${PROJECT_BINARY_DIR}/include)
target_include_directories(modern_spinor_f PRIVATE ${PROJECT_BINARY_DIR}/include)
target_include_directories(pure_fortran_f PRIVATE ${PROJECT_BINARY_DIR}/include)
target_include_directories(time_c2h6_f PRIVATE ${PROJECT_BINARY_DIR}/include)
target_include_directories(time_c2h6_pure_f PRIVATE ${PROJECT_BINARY_DIR}/include)

set_target_properties(time_c2h6_f PROPERTIES
COMPILE_FLAGS ${OpenMP_C_FLAGS}
LINK_FLAGS ${OpenMP_C_FLAGS})

set_target_properties(time_c2h6_pure_f PROPERTIES
COMPILE_FLAGS ${OpenMP_C_FLAGS}
LINK_FLAGS ${OpenMP_C_FLAGS})

endif()
Loading