Skip to content

Commit

Permalink
CMake: add test_install to be XSDK compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
mic84 committed Jul 7, 2018
1 parent 0038c22 commit 3ce935a
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ unset (TMP)
add_subdirectory (Src)

#
# Tutorials
# Tutorials and "test_install" target)
#
add_subdirectory (Tutorials)



63 changes: 63 additions & 0 deletions Tutorials/Basic/HeatEquation_EX1_C/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
get_filename_component ( DIRNAME ${CMAKE_CURRENT_LIST_DIR} NAME )

set ( TESTNAME ${DIRNAME} )
set ( EXENAME ${DIRNAME}.exe )
set ( SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/Source )
set ( EXE_DIR ${CMAKE_CURRENT_LIST_DIR}/Exec )

#
# Create target (executable) for this tutorial
#
add_executable ( ${EXENAME} EXCLUDE_FROM_ALL "" )

target_sources ( ${EXENAME}
PRIVATE
${SRC_DIR}/advance_${DIM}d.f90
${SRC_DIR}/advance.cpp
${SRC_DIR}/init_phi_${DIM}d.f90
${SRC_DIR}/main.cpp
${SRC_DIR}/myfunc_F.H
${SRC_DIR}/myfunc.H )

set_target_properties ( ${EXENAME} PROPERTIES
INCLUDE_DIRECTORIES
"${SRC_DIR};${CMAKE_CURRENT_BINARY_DIR}/mod_files"
Fortran_MODULE_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/mod_files
RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR} )

target_link_libraries ( ${EXENAME} amrex )


#
# Copy input files to corresponding build dir
# First copy operation is run when builddir is setup
set (INPUT_FILES ${EXE_DIR}/inputs_${DIM}d )

file ( COPY ${INPUT_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )

add_custom_target ( run_${EXENAME}
COMMAND
cp ${INPUT_FILES} ${CMAKE_CURRENT_BINARY_DIR}
COMMAND
${EXENAME} inputs_${DIM}d nsteps = 10
DEPENDS
${INPUT_FILES}
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
COMMENT
"Running ${EXENAME}"
VERBATIM
)


#
# Add to the "tutorial" target
#
#add_tutorial (${EXENAME})
add_tutorial (run_${EXENAME})




19 changes: 14 additions & 5 deletions Tutorials/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
set ( AMREX_TUTORIALS_DIR ${CMAKE_CURRENT_LIST_DIR} )

set ( AMREX_TUTORIALS_SUBDIRS Amr ) # For now only Amr
set ( AMREX_TUTORIALS_SUBDIRS Amr Basic ) # For now only Amr

prepend ( AMREX_TUTORIALS_SUBDIRS ${AMREX_TUTORIALS_DIR})

#
# Create a target to build all tutorials
# Create a target to build all tutorials and an indentical one for
# test_install
#
# !!!!!! ATTENTION: target "tutorial" and "test_install" are the same for
# the time being until we decide what to do with test_install
#
add_custom_target (tutorials)
add_custom_target (test_install)

#
# Here we define a macro to accumulate all the tutorial targets
Expand All @@ -16,6 +21,7 @@ set ( TUTORIAL_TARGETS )

macro (add_tutorial targets_list)
add_dependencies (tutorials ${targets_list})
add_dependencies (test_install ${targets_list})
endmacro ()

#
Expand All @@ -26,11 +32,14 @@ foreach (subdir ${AMREX_TUTORIALS_SUBDIRS})
file ( GLOB_RECURSE ALL_TUTORIALS "${subdir}/*CMakeLists.txt" )

foreach ( this_tutorial ${ALL_TUTORIALS})

get_filename_component (dir ${this_tutorial} DIRECTORY )
add_subdirectory (${dir})

endforeach ()


endforeach ()


# Just write something if
add_custom_command(TARGET test_install POST_BUILD
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan
"AMReX installation is working")

0 comments on commit 3ce935a

Please sign in to comment.