IAP GITLAB

Skip to content
Snippets Groups Projects
Commit b658dc52 authored by Ralf M Ulrich's avatar Ralf M Ulrich
Browse files

fix cmake parse

parent f2c318b5
No related branches found
No related tags found
1 merge request!199Resolve "remove examples from coverage"
Pipeline #1338 failed
...@@ -127,20 +127,19 @@ endmacro(CORSIKA_ADD_FILES_ABSOLUTE) ...@@ -127,20 +127,19 @@ endmacro(CORSIKA_ADD_FILES_ABSOLUTE)
# TEMPORARY: All sanitizers are currently globally disabled by default, to enable them, # TEMPORARY: All sanitizers are currently globally disabled by default, to enable them,
# set CORSIKA_SANITIZERS_ENABLED to TRUE. # set CORSIKA_SANITIZERS_ENABLED to TRUE.
function (CORSIKA_ADD_TEST) function (CORSIKA_ADD_TEST)
cmake_parse_arguments (PARSE_ARGV 1 _ "" "SANITIZE" "SOURCES") cmake_parse_arguments (PARSE_ARGV 1 C8_ADD_TEST "" "SANITIZE" "SOURCES")
set (name ${ARGV0}) set (name ${ARGV0})
if (NOT __SOURCES) if (NOT C8_ADD_TEST_SOURCES)
set (sources ${name}.cc) set (sources ${name}.cc)
else () else ()
set (sources ${__SOURCES}) set (sources ${C8_ADD_TEST_SOURCES})
endif () endif ()
if (NOT __SANITIZE) if (NOT C8_ADD_TEST_SANITIZE)
set(sanitize "address,undefined") set(sanitize "address,undefined")
else () else ()
set(sanitize ${__SANITIZE}) set(sanitize ${C8_ADD_TEST_SANITIZE})
endif () endif ()
add_executable (${name} ${sources}) add_executable (${name} ${sources})
...@@ -181,24 +180,19 @@ endfunction (CORSIKA_ADD_TEST) ...@@ -181,24 +180,19 @@ endfunction (CORSIKA_ADD_TEST)
# target_link_libraries(testSomething ...) and so on. # target_link_libraries(testSomething ...) and so on.
# #
function (CORSIKA_ADD_EXAMPLE) function (CORSIKA_ADD_EXAMPLE)
set (options "") cmake_parse_arguments (PARSE_ARGV 1 C8_ADD_EXAMPLE "" "RUN_OPTIONS" "SOURCES")
set (oneValueArgs RUN_OPTIONS)
set (multiValueArgs SOURCES)
cmake_parse_arguments (CORSKA_ADD_EXAMPLE "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )
set (name ${ARGV0}) set (name ${ARGV0})
if (NOT CORSIKA_ADD_EXAMPLE_SOURCES) if (NOT C8_ADD_EXAMPLE_SOURCES)
set (sources ${name}.cc) set (sources ${name}.cc)
else () else ()
set (sources ${CORSIKA_ADD_EXAMPLE_SOURCES}) set (sources ${C8_ADD_EXAMPLE_SOURCES})
endif () endif ()
if (NOT CORSIKA_ADD_EXAMPLE_RUN_OPTIONS) if (NOT C8_ADD_EXAMPLE_RUN_OPTIONS)
set (run_options "") set (run_options "")
else () else ()
set (run_option ${CORSIKA_ADD_EXAMPLE_RUN_OPTIONS}) set (run_options ${C8_ADD_EXAMPLE_RUN_OPTIONS})
endif () endif ()
add_executable (${name} ${sources}) add_executable (${name} ${sources})
...@@ -209,11 +203,12 @@ function (CORSIKA_ADD_EXAMPLE) ...@@ -209,11 +203,12 @@ function (CORSIKA_ADD_EXAMPLE)
else () else ()
add_custom_target (run_examples) add_custom_target (run_examples)
endif () endif ()
add_dependencies (run_examples ${name})
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}" COMMAND ${CMAKE_COMMAND} -E echo "***** running example: ${name} ${run_options}"
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name} ${run_options} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name} ${run_options}
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)
......
CORSIKA_ADD_EXAMPLE (helix_example) CORSIKA_ADD_EXAMPLE (helix_example SOURCES helix_example.cc)
target_link_libraries (helix_example CORSIKAgeometry CORSIKAunits) target_link_libraries (helix_example CORSIKAgeometry CORSIKAunits)
CORSIKA_ADD_EXAMPLE (particle_list_example) CORSIKA_ADD_EXAMPLE (particle_list_example RUN_OPTIONS aha)
target_link_libraries (particle_list_example CORSIKAparticles CORSIKAunits CORSIKAprocesses ProcessSibyll ProcessQGSJetII) target_link_libraries (particle_list_example CORSIKAparticles CORSIKAunits CORSIKAprocesses ProcessSibyll ProcessQGSJetII)
CORSIKA_ADD_EXAMPLE (geometry_example) CORSIKA_ADD_EXAMPLE (geometry_example SOURCES geometry_example.cc RUN_OPTIONS test)
target_link_libraries (geometry_example CORSIKAgeometry CORSIKAunits) target_link_libraries (geometry_example CORSIKAgeometry CORSIKAunits)
CORSIKA_ADD_EXAMPLE (logger_example) CORSIKA_ADD_EXAMPLE (logger_example)
......
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