]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Improve $ (make|ninja) (help|info) considerably, do not define a
authorMatthias Maier <tamiko@kyomu.43-1.org>
Tue, 3 Dec 2013 12:38:09 +0000 (12:38 +0000)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Tue, 3 Dec 2013 12:38:09 +0000 (12:38 +0000)
"help" target when the ninja generator is used

git-svn-id: https://svn.dealii.org/trunk@31849 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake
deal.II/cmake/setup_custom_targets.cmake
deal.II/cmake/setup_finalize.cmake

index c0207506c9bb569ccc4524b660dd00e7dc397698..6ea8b005119e4a0b75a6770d1bf24c35e800a9db 100644 (file)
 
 MACRO(DEAL_II_INVOKE_AUTOPILOT)
 
+  # Generator specific values:
+  IF(CMAKE_GENERATOR MATCHES "Ninja")
+    #
+    # Ninja doesn't like a redifinition of the "help" target, so use "info"
+    # in this case...
+    #
+    SET(_make_command "$ ninja")
+  ELSE()
+    SET(_make_command " $ make")
+  ENDIF()
+
   # Define and setup a compilation target:
   ADD_EXECUTABLE(${TARGET} ${TARGET_SRC})
   DEAL_II_SETUP_TARGET(${TARGET})
@@ -84,7 +95,7 @@ MACRO(DEAL_II_INVOKE_AUTOPILOT)
       COMMENT "Run ${TARGET} with ${CMAKE_BUILD_TYPE} configuration"
       )
     SET(_run_targets
-      "#      $ make run            - to (compile, link and) run the program\n"
+      "#      ${_make_command} run            - to (compile, link and) run the program\n"
       )
   ENDIF()
 
@@ -122,7 +133,7 @@ MACRO(DEAL_II_INVOKE_AUTOPILOT)
     ENDIF()
 
     SET(_run_targets
-      "${_run_targets}#\n#      $ make sign           - to sign the executable with the supplied OSX developer key\n"
+      "${_run_targets}#\n#      ${_make_command} sign           - to sign the executable with the supplied OSX developer key\n"
       )
   ENDIF()
 
@@ -143,8 +154,8 @@ MACRO(DEAL_II_INVOKE_AUTOPILOT)
   # switch between them:
   IF(${DEAL_II_BUILD_TYPE} MATCHES "DebugRelease")
     SET(_switch_targets
-"#      $ make debug          - to switch the build type to \"Debug\"
-#      $ make release        - to switch the build type to \"Release\"\n"
+"#      ${_make_command} debug          - to switch the build type to \"Debug\"
+#      ${_make_command} release        - to switch the build type to \"Release\"\n"
       )
   ENDIF()
 
@@ -175,50 +186,78 @@ MACRO(DEAL_II_INVOKE_AUTOPILOT)
       )
   ENDIF()
 
+
   # Print out some usage information to file:
   FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake
 "MESSAGE(
 \"###
 #
-#  Successfully set up project  ${TARGET}  with  ${DEAL_II_PACKAGE_NAME}-${DEAL_II_PACKAGE_VERSION}  found at
+#  Project  ${TARGET}  set up with  ${DEAL_II_PACKAGE_NAME}-${DEAL_II_PACKAGE_VERSION}  found at
 #      ${DEAL_II_PATH}
 #
-#  CMAKE_BUILD_TYPE:         ${CMAKE_BUILD_TYPE}
+#  CMAKE_BUILD_TYPE:          ${CMAKE_BUILD_TYPE}
 #
 #  You can now run
-#      $ make                - to compile and link the program
+#      ${_make_command}                - to compile and link the program
 ${_run_targets}#
 ${_switch_targets}#
-#      $ make edit_cache     - to change (cached) configuration variables
-#                              and rerun the configure and generate phases of CMake
-#
-#      $ make strip_comments - to strip the source files in this
-#                              directory off the documentation comments
-#      $ make clean          - to remove the generated executable as well as
-#                              all intermediate compilation files
-#      $ make runclean       - to remove all output generated by the program
-#      $ make distclean      - to clean the directory from _all_ generated
-#                              files (includes clean, runclean and the removal
-#                              of the generated build system)
+")
+  IF(NOT CMAKE_GENERATOR MATCHES "Ninja")
+    FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake
+"#      ${_make_command} edit_cache     - to change (cached) configuration variables
+#                               and rerun the configure and generate phases of CMake
 #
-#      $ make help           - to view this message again
+")
+  ENDIF()
+  FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake
+"#      ${_make_command} strip_comments - to strip the source files in this
+#                               directory off the documentation comments
+#      ${_make_command} clean          - to remove the generated executable as well as
+#                               all intermediate compilation files
+#      ${_make_command} runclean       - to remove all output generated by the program
+#      ${_make_command} distclean      - to clean the directory from _all_ generated
+#                               files (includes clean, runclean and the removal
+#                               of the generated build system)
 #
+"
+    )
+   IF(CMAKE_GENERATOR MATCHES "Ninja")
+     FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake
+"#      $ ninja info           - to view this message again
+"
+       )
+   ELSE()
+     FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake
+"#       $ make help           - to view this message again
+"      )
+   ENDIF()
+   FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake
+"#
 #  Have a nice day!
 #
 ###\")"
-    )
+     )
 
   # A custom target to print the message:
-  ADD_CUSTOM_TARGET(help
+  ADD_CUSTOM_TARGET(info
     COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake
     )
+  IF(NOT CMAKE_GENERATOR MATCHES "Ninja")
+    ADD_CUSTOM_TARGET(help
+      COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake
+      )
+  ENDIF()
 
   # Print this message once:
   IF(NOT USAGE_PRINTED)
     INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake)
     SET(USAGE_PRINTED TRUE CACHE INTERNAL "")
   ELSE()
-    MESSAGE(STATUS "Run   $ make help   to print a detailed help message")
+    IF(CMAKE_GENERATOR MATCHES "Ninja")
+      MESSAGE(STATUS "Run  $ ninja info  to print a detailed help message")
+    ELSE()
+      MESSAGE(STATUS "Run  $ make help  to print a detailed help message")
+    ENDIF()
   ENDIF()
 
 ENDMACRO()
index 02e242c08dc7371971320e35027ce7aab718a036..4db3c2b4db7bfa7a652fce582cdbb465a3e87383 100644 (file)
@@ -63,19 +63,38 @@ ENDFOREACH()
 # Provide an "info" target to print a help message:
 #
 
+IF(CMAKE_GENERATOR MATCHES "Ninja")
+  SET(_make_command "ninja")
+ELSE()
+  SET(_make_command "make")
+ENDIF()
 FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_info.cmake
 "MESSAGE(
 \"###
 #
-#  The following targets are available (invoke by $ make <target>):
+#  The following targets are available (invoke by $ ${_make_command} <target>):
 #
 #    all            - compiles the library and all enabled components
 #    clean          - removes all generated files
 #    install        - installs into CMAKE_INSTALL_PREFIX
+")
+
+IF(CMAKE_GENERATOR MATCHES "Ninja")
+  FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_info.cmake
+"#    info           - prints this help message
 #    help           - prints a list of valid top level targets
-#    info           - prints this help message
 #
-#    edit_cache     - runs ccmake for changing (cached) configuration variables
+")
+ELSE()
+  FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_info.cmake
+"#    help           - prints this help message in the toplevel directory,
+#                     otherwise prints a list of targets (in subdirectories)
+#
+")
+ENDIF()
+
+FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_info.cmake
+"#    edit_cache     - runs ccmake for changing (cached) configuration variables
 #                     and reruns the configure and generate phases of CMake
 #    rebuild_cache  - reruns the configure and generate phases of CMake
 #
@@ -95,6 +114,12 @@ FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_info.cmake
 #
 ###\")"
   )
+
 ADD_CUSTOM_TARGET(info
   COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_info.cmake
   )
+IF(NOT CMAKE_GENERATOR MATCHES "Ninja")
+  ADD_CUSTOM_TARGET(help
+    COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_info.cmake
+    )
+ENDIF()
index cb01181acf7d5ef82182b528e80c33a31580b507..45ed9f36a5872d6d1bb76bfc464b7a42a72f51c7 100644 (file)
@@ -274,8 +274,14 @@ ENDFOREACH()
 
 _summary(
 "#\n#  Detailed information (compiler flags, feature configuration) can be found in detailed.log
-#\n#  Run  $ make info  to print a help message with a list of top level targets\n"
+#\n#  Run  $ "
   )
+IF(CMAKE_GENERATOR MATCHES "Ninja")
+  _summary("ninja info")
+ELSE()
+_summary("make help")
+ENDIF()
+_summary("  to print a help message with a list of top level targets\n")
 
 _both("#\n###")
 

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.