]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: deal_ii_invoke_autopilot: mild refactoring
authorMatthias Maier <tamiko@43-1.org>
Sat, 12 Oct 2024 21:10:33 +0000 (16:10 -0500)
committerMatthias Maier <tamiko@43-1.org>
Mon, 14 Oct 2024 01:37:48 +0000 (20:37 -0500)
cmake/macros/macro_deal_ii_invoke_autopilot.cmake

index 88d7f897c13b69d4845637cade68d187e7e44ee9..5406b9f1e5c9e8429a7ca1b69b10930934192880 100644 (file)
 #
 
 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 $<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>: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(
 \"###

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.