From 7a2cc2b8258f78b5b35328e905952955f6f82892 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Sat, 12 Oct 2024 16:10:33 -0500 Subject: [PATCH] CMake: deal_ii_invoke_autopilot: mild refactoring --- .../macro_deal_ii_invoke_autopilot.cmake | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/cmake/macros/macro_deal_ii_invoke_autopilot.cmake b/cmake/macros/macro_deal_ii_invoke_autopilot.cmake index 88d7f897c1..5406b9f1e5 100644 --- a/cmake/macros/macro_deal_ii_invoke_autopilot.cmake +++ b/cmake/macros/macro_deal_ii_invoke_autopilot.cmake @@ -35,13 +35,11 @@ # macro(deal_ii_invoke_autopilot) + message(STATUS "Autopilot invoked") - # Generator specific values: - if(CMAKE_GENERATOR MATCHES "Ninja") - set(_make_command "$ ninja") - else() - set(_make_command " $ make") - endif() + # + # Generate compile_commands.json + # set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) @@ -72,9 +70,14 @@ macro(deal_ii_invoke_autopilot) # Define and set up a compilation target: add_executable(${TARGET} ${TARGET_SRC}) - deal_ii_setup_target(${TARGET}) + target_link_libraries(${TARGET} dealii::dealii) - message(STATUS "Autopilot invoked") + # Generator specific values: + if(CMAKE_GENERATOR MATCHES "Ninja") + set(_make_command "$ ninja") + else() + set(_make_command " $ make") + endif() # Define a custom target to easily run the program: if(NOT DEFINED TARGET_RUN) @@ -102,9 +105,7 @@ macro(deal_ii_invoke_autopilot) set(_command ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/run_target.cmake ) - else() - set(_command ${TARGET_RUN}) endif() @@ -112,14 +113,13 @@ macro(deal_ii_invoke_autopilot) add_custom_target(run COMMAND ${_command} DEPENDS ${TARGET} - COMMENT "Run ${TARGET} with ${CMAKE_BUILD_TYPE} configuration" + COMMENT "Run ${TARGET} with $<$:Release>$<$:Debug> configuration" ) set(_run_targets "# ${_make_command} run - to (compile, link and) run the program\n" ) endif() - # # Provide a target to sign the generated executable with a Mac OSX # developer key. This avoids problems with an enabled firewall and MPI @@ -184,18 +184,9 @@ macro(deal_ii_invoke_autopilot) endif() # - # Only mention release and debug targets if it is actually possible to - # switch between them: + # And another custom target to clean up all files generated by the program: # - if(${DEAL_II_BUILD_TYPE} MATCHES "DebugRelease") - set(_switch_targets -"# ${_make_command} debug - to switch the build type to 'Debug' -# ${_make_command} release - to switch the build type to 'Release'\n" - ) - endif() - - # And another custom target to clean up all files generated by the program: if("${CLEAN_UP_FILES}" STREQUAL "") set(CLEAN_UP_FILES *.log *.gmv *.gnuplot *.gpl *.eps *.pov *.vtk *.ucd *.d2) endif() @@ -204,7 +195,10 @@ macro(deal_ii_invoke_autopilot) COMMENT "runclean invoked" ) + # # Define a distclean target to remove every generated file: + # + add_custom_target(distclean COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target clean COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target runclean @@ -215,7 +209,10 @@ macro(deal_ii_invoke_autopilot) COMMENT "distclean invoked" ) + # # Define a strip_comments target: + # + find_package(Perl QUIET) if(PERL_FOUND) add_custom_target(strip_comments @@ -224,8 +221,19 @@ macro(deal_ii_invoke_autopilot) ) endif() + # + # Construct help message: + # + + # Only mention release and debug targets if it is actually possible to + # switch between them: + if(${DEAL_II_BUILD_TYPE} MATCHES "DebugRelease") + set(_switch_targets +"# ${_make_command} debug - to switch the build type to 'Debug' +# ${_make_command} release - to switch the build type to 'Release'\n" + ) + endif() - # Print out some usage information to file: file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake "message( \"### -- 2.39.5