IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 2e24b2d2 authored by ralfulrich's avatar ralfulrich
Browse files

added gdb option in cmake macro

parent 7d34338f
No related branches found
No related tags found
1 merge request!269Resolve "Distinguish between alternative interaction processes and competing processes"
...@@ -174,13 +174,15 @@ endfunction (CORSIKA_ADD_TEST) ...@@ -174,13 +174,15 @@ endfunction (CORSIKA_ADD_TEST)
# specify the sources. # specify the sources.
# #
# Example: CORSIKA_ADD_EXAMPLE (testSomething # Example: CORSIKA_ADD_EXAMPLE (testSomething
# SOURCES source1.cc source2.cc someheader.h) # SOURCES source1.cc source2.cc someheader.h
# RUN_OPTION "extra command line options"
# RUN_IN_GDB)
# #
# In all cases, you can further customize the target with # In all cases, you can further customize the target with
# target_link_libraries(testSomething ...) and so on. # target_link_libraries(testSomething ...) and so on.
# #
function (CORSIKA_ADD_EXAMPLE) function (CORSIKA_ADD_EXAMPLE)
cmake_parse_arguments (PARSE_ARGV 1 C8_ADD_EXAMPLE "" "" "SOURCES;RUN_OPTIONS") cmake_parse_arguments (PARSE_ARGV 1 C8_ADD_EXAMPLE "RUN_IN_GDB" "" "SOURCES;RUN_OPTIONS")
set (name ${ARGV0}) set (name ${ARGV0})
if (NOT C8_ADD_EXAMPLE_SOURCES) if (NOT C8_ADD_EXAMPLE_SOURCES)
...@@ -204,15 +206,21 @@ function (CORSIKA_ADD_EXAMPLE) ...@@ -204,15 +206,21 @@ function (CORSIKA_ADD_EXAMPLE)
add_custom_target (run_examples) add_custom_target (run_examples)
endif () endif ()
add_dependencies (run_examples ${name}) add_dependencies (run_examples ${name})
if (C8_ADD_EXAMPLE_RUN_IN_GDB)
# convert cmake list into real string:
string (REPLACE ";" " " run_options_str "${run_options}")
# run the command in gdb and study backtrace a bit
set (CMD gdb -q --batch -ex "run ${run_options_str}" -ex bt -ex "info locals" -ex "up" -ex "info locals" -ex "up" -ex "info locals" -ex "up" -ex "info locals" -ex quit "${CMAKE_CURRENT_BINARY_DIR}/${name}")
else (C8_ADD_EXAMPLE_RUN_IN_GDB)
# just run the command as-is
set (CMD ${CMAKE_CURRENT_BINARY_DIR}/${name} ${run_options})
endif (C8_ADD_EXAMPLE_RUN_IN_GDB)
add_custom_command (TARGET run_examples add_custom_command (TARGET run_examples
POST_BUILD POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "" COMMAND ${CMAKE_COMMAND} -E echo ""
COMMAND ${CMAKE_COMMAND} -E echo "**************************************" COMMAND ${CMAKE_COMMAND} -E echo "**************************************"
COMMAND ${CMAKE_COMMAND} -E echo "***** running example: ${name} " ${run_options} VERBATIM COMMAND ${CMAKE_COMMAND} -E echo "***** running example: ${name} " ${run_options} VERBATIM
COMMAND gdb -q --batch -ex "run ${run_options}" -ex bt -ex "info locals" -ex "up" -ex "info locals" COMMAND ${CMD} VERBATIM
-ex "up"-ex "info locals" -ex "up" -ex "info locals"
-ex quit ${CMAKE_CURRENT_BINARY_DIR}/${name}
VERBATIM
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/example_outputs) WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/example_outputs)
install (TARGETS ${name} DESTINATION share/examples) install (TARGETS ${name} DESTINATION share/examples)
endfunction (CORSIKA_ADD_EXAMPLE) endfunction (CORSIKA_ADD_EXAMPLE)
...@@ -84,7 +84,7 @@ if (Pythia8_FOUND) ...@@ -84,7 +84,7 @@ if (Pythia8_FOUND)
CORSIKAprocesssequence CORSIKAprocesssequence
) )
CORSIKA_ADD_EXAMPLE (vertical_EAS RUN_OPTIONS "4 2 10000.") CORSIKA_ADD_EXAMPLE (vertical_EAS RUN_OPTIONS 4 2 10000.)
target_link_libraries (vertical_EAS target_link_libraries (vertical_EAS
CORSIKAsetup CORSIKAsetup
CORSIKAunits CORSIKAunits
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment