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

CMake: streamline install of plotfile tools #1661

Merged
merged 1 commit into from
Dec 18, 2020
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
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ set_default_config_flags ()
# Source files for all binaries and libraries found under src
#
add_subdirectory(Src)
get_property(_amrex_targets
DIRECTORY Src
PROPERTY BUILDSYSTEM_TARGETS)

#
# Tutorials and "test_install" target
Expand All @@ -123,9 +126,20 @@ if (AMReX_PLOTFILE_TOOLS)
# If this get executed, it cannot be EXCLUDED_FROM_ALL
# because it needs to get installed
add_subdirectory(Tools/Plotfile)
get_property(_plotfile_targets
DIRECTORY Tools/Plotfile
PROPERTY BUILDSYSTEM_TARGETS)
list(APPEND _amrex_targets ${_plotfile_targets})
endif ()


#
# Install amrex -- Export
#
include(AMReXInstallHelpers)
install_amrex_targets(${_amrex_targets})


#
# Enable CTests
#
Expand Down
2 changes: 2 additions & 0 deletions Docs/sphinx_documentation/source/BuildingAMReX.rst
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ A list of AMReX component names and related configure options are shown in the t
+------------------------------+-----------------+
| AMReX_HYPRE | HYPRE |
+------------------------------+-----------------+
| AMReX_PLOTFILE_TOOLS | PFTOOLS |
+------------------------------+-----------------+

.. raw:: latex

Expand Down
10 changes: 0 additions & 10 deletions Src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,3 @@ endif ()
#
include(AMReXGenerateConfigHeader)
generate_config_header()

#
# Install amrex -- Export
#
include(AMReXInstallHelpers)
set(_amrex_targets Flags_CXX Flags_Fortran Flags_FPE )
if (AMReX_DPCPP)
list(APPEND _amrex_targets SYCL)
endif()
install_amrex(${_amrex_targets})
5 changes: 4 additions & 1 deletion Tools/CMake/AMReXConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ set(AMReX_OMP_FOUND @AMReX_OMP@)
set(AMReX_CUDA_FOUND @AMReX_CUDA@)
set(AMReX_SYCL_FOUND @AMReX_DPCPP@)
set(AMReX_HIP_FOUND @AMReX_HIP@)
set(AMReX_@AMReX_PRECISION@_FOUND ON)
set(AMReX_@AMReX_PRECISION@_FOUND ON)
set(AMReX_FORTRAN_FOUND @AMReX_FORTRAN@)

# Actual components selection
Expand Down Expand Up @@ -90,6 +90,9 @@ set(AMReX_MEMP_FOUND @AMReX_MEM_PROFILE@)
set(AMReX_COMMP_FOUND @AMReX_COMM_PROFILE@)
set(AMReX_PROFPARSER_FOUND @AMReX_PROFPARSER@)

# Plotfile tools
set(AMReX_PFTOOLS_FOUND @AMReX_PLOTFILE_TOOLS@)

#
# Parallel backends
#
Expand Down
7 changes: 4 additions & 3 deletions Tools/CMake/AMReXInstallHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Manage AMReX installation process
# Extra arguments are the targets to install
#
function (install_amrex)
function (install_amrex_targets)

# Check if the given arguments are valid targets
set(_targets amrex)
set(_targets)
foreach (_arg IN LISTS ARGV)
if (TARGET ${_arg})
set(_targets ${_targets} ${_arg})
Expand Down Expand Up @@ -54,6 +54,7 @@ function (install_amrex)
LIBRARY DESTINATION lib
INCLUDES DESTINATION include # Adds proper directory to INTERFACE_INCLUDE_DIRECTORIES
PUBLIC_HEADER DESTINATION include
RUNTIME DESTINATION bin
)

install( EXPORT AMReXTargets
Expand All @@ -62,7 +63,7 @@ function (install_amrex)

# Install fortran modules if Fortran is enabled
get_property(_lang GLOBAL PROPERTY ENABLED_LANGUAGES)
if ("Fortran" IN_LIST _lang )
if ("Fortran" IN_LIST _lang AND "amrex" IN_LIST _targets)
get_target_property(_mod_dir amrex Fortran_MODULE_DIRECTORY )
install( DIRECTORY ${_mod_dir}/ DESTINATION include ) # Trailing backslash is crucial here!
endif ()
Expand Down
12 changes: 3 additions & 9 deletions Tools/Plotfile/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ project(AMReX-PlotfileTools
# Plotfile tools requires only AMReX sources from Src/Base which get always
# compiled, so no need to check which part of AMReX is enabled by user


# General Target to build all tools at once
add_custom_target(plotfile_tools)

# List of plotfile targets
set(_exe_names
fboxinfo
fcompare
Expand All @@ -23,11 +20,11 @@ set(_exe_names
# Build targets one by one
foreach( _exe IN LISTS _exe_names)
add_executable(${_exe} ${_exe}.cpp)
add_executable(AMReX::${_exe} ALIAS ${_exe})
target_link_libraries(${_exe} PRIVATE amrex)
if (AMReX_CUDA)
set_source_files_properties(${_exe}.cpp PROPERTIES LANGUAGE CUDA)
endif()
add_dependencies(plotfile_tools ${_exe})
endforeach()


Expand All @@ -36,8 +33,5 @@ target_include_directories(fsnapshot PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(fsnapshot PRIVATE AMReX_PPMUtil.H AMReX_PPMUtil.cpp)
if (AMReX_CUDA)
set_source_files_properties(AMReX_PPMUtil.cpp PROPERTIES LANGUAGE CUDA)
target_compile_features(fsnapshot PUBLIC cxx_std_14)
target_compile_features(fsnapshot PUBLIC cxx_std_14)
endif()

# Installation
install(TARGETS ${_exe_names} RUNTIME DESTINATION bin)