Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config.cmake #154

Merged
merged 3 commits into from
Mar 13, 2025
Merged
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
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,15 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
CACHE STRING "Choose the installation directory. Default location is ${default_install_prefix}"
FORCE)
endif()

install(
EXPORT greenXTargets
NAMESPACE greenX::
FILE greenXTargets.cmake
DESTINATION lib/cmake/greenX
)

install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/greenXConfig.cmake"
DESTINATION lib/cmake/greenX
)
17 changes: 12 additions & 5 deletions GX-AnalyticContinuation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ set_target_properties(LibGXAC
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_Fortran_LIB_DIRECTORY}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_Fortran_LIB_DIRECTORY})

target_include_directories(LibGXAC PUBLIC src/)
#target_include_directories(LibGXAC PUBLIC src/)
target_include_directories(LibGXAC
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include/modules>
)
if(GMPXX_FOUND)
add_definitions(-DGMPXX_FOUND)
target_sources(LibGXAC PRIVATE src/pade_approximant.f90 src/ComplexGMP.cpp src/Symmetry_pade.cpp src/pade_mp.cpp api/gx_ac.F90)
Expand All @@ -33,7 +38,7 @@ endif()
# -----------------------------------------------
# Install library
# Destination relative to ${CMAKE_INSTALL_PREFIX}, defined in top-level CMake
install(TARGETS LibGXAC ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
install(TARGETS LibGXAC EXPORT greenXTargets ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)

# Install modules
# Destination relative to ${CMAKE_INSTALL_PREFIX}, defined in top-level CMake
Expand All @@ -50,8 +55,10 @@ include(../cmake/testFunctions.cmake)
# Set name of test sub-directory in the build directory
set(TEST_TARGET_DIR "analytic_continuation")

target_include_directories(LibGXAC PUBLIC test/)

target_include_directories(LibGXAC
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test>
)
# Set pytest conftest for Localized basis library tests
add_custom_command(
TARGET LibGXAC POST_BUILD
Expand Down Expand Up @@ -135,4 +142,4 @@ add_test(
NAME test_gx_analytic_continuation_reference_0
COMMAND pytest -s test_gx_analytic_continuation_reference_0.py --build-dir ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test/${TEST_TARGET_DIR}
)
)
20 changes: 17 additions & 3 deletions GX-LocalizedBasis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ set_target_properties(LibGXLBasis
)

# Add include directories to the LibGXMiniMax
target_include_directories(LibGXLBasis PUBLIC src/ api/)
#target_include_directories(LibGXLBasis PUBLIC src/ api/)
target_include_directories(LibGXLBasis
PUBLIC
# Build-time includes (point to actual source dirs)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/api>

# Install-time includes (point to the location where headers/modules land when installed)
$<INSTALL_INTERFACE:include/modules>
)

# Define source that comprise LibGXLBasis
target_sources(LibGXLBasis PRIVATE
Expand All @@ -43,8 +52,10 @@ target_link_libraries(LibGXLBasis GXCommon ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}
# Install library
# Destination relative to ${CMAKE_INSTALL_PREFIX}, defined in top-level CMake
install(TARGETS LibGXLBasis
EXPORT greenXTargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
LIBRARY DESTINATION lib
)

# Install modules
# Destination relative to ${CMAKE_INSTALL_PREFIX}, defined in top-level CMake
Expand All @@ -60,7 +71,10 @@ include(../cmake/testFunctions.cmake)
# Set name of test sub-directory in the build directory
set(TEST_TARGET_DIR "localized_basis")

target_include_directories(LibGXLBasis PUBLIC test/)
target_include_directories(LibGXLBasis
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test>
)

# Set pytest conftest for Localized basis library tests
add_custom_command(
Expand Down
22 changes: 18 additions & 4 deletions GX-TimeFrequency/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ set_target_properties(LibGXMiniMax
)

# Add include directories to the LibGXMiniMax
target_include_directories(LibGXMiniMax PUBLIC src/ api/ utilities/)

#target_include_directories(LibGXMiniMax PUBLIC src/ api/ utilities/)
target_include_directories(LibGXMiniMax
PUBLIC
# Build-time includes (point to actual source dirs)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/api>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/utilities>

# Install-time includes (point to the location where headers/modules land when installed)
$<INSTALL_INTERFACE:include/modules>
)
# Define source that comprise LibGXMiniMax
target_sources(LibGXMiniMax PRIVATE
src/gx_common.h
Expand Down Expand Up @@ -65,8 +74,10 @@ target_link_libraries(GXTabulateGrids
# Install library
# Destination relative to ${CMAKE_INSTALL_PREFIX}, defined in top-level CMake
install(TARGETS LibGXMiniMax
EXPORT greenXTargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
LIBRARY DESTINATION lib
)

# Install modules
# Destination relative to ${CMAKE_INSTALL_PREFIX}, defined in top-level CMake
Expand All @@ -86,7 +97,10 @@ include(../cmake/testFunctions.cmake)
# Set name of test sub-directory in the build directory
set(TEST_TARGET_DIR "time-frequency")

target_include_directories(LibGXMiniMax PUBLIC test/)
target_include_directories(LibGXMiniMax
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test>
)

# Set pytest conftest for Time-Frequency library tests
add_custom_command(
Expand Down
14 changes: 11 additions & 3 deletions GX-common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CMakeLists.txt for GreenX Common Modules, required by all other libs in
# the package


add_library(GXCommon "")

set_target_properties(GXCommon
Expand All @@ -12,7 +13,12 @@ set_target_properties(GXCommon
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_Fortran_LIB_DIRECTORY}
)

target_include_directories(GXCommon PUBLIC src/)
#target_include_directories(GXCommon PUBLIC src/)
target_include_directories(GXCommon
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> # used when building in the source tree
$<INSTALL_INTERFACE:include/modules> # used after 'make install'
)

target_sources(GXCommon PRIVATE
src/kinds.f90
Expand All @@ -26,8 +32,10 @@ target_sources(GXCommon PRIVATE
# Destination relative to ${CMAKE_INSTALL_PREFIX}, defined in the top-level
# CMakeLists.txt
install(TARGETS GXCommon
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
EXPORT greenXTargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)

# Install modules
# Destination relative to ${CMAKE_INSTALL_PREFIX}, defined in the top-level
Expand Down
7 changes: 7 additions & 0 deletions cmake/greenXConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include(CMakeFindDependencyMacro)

# If greenX depends on other libraries, do:
find_dependency(BLAS REQUIRED)
find_dependency(LAPACK REQUIRED)
# Finally, pull in the targets you exported:
include("${CMAKE_CURRENT_LIST_DIR}/greenXTargets.cmake")