From 6af175f206985d1466c300e85c353543af7b21aa Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 3 Dec 2013 12:38:09 +0000 Subject: [PATCH] CMake: Improve $ (make|ninja) (help|info) considerably, do not define a "help" target when the ninja generator is used git-svn-id: https://svn.dealii.org/trunk@31849 0785d39b-7218-0410-832d-ea1e28bc413d --- .../macro_deal_ii_invoke_autopilot.cmake | 83 ++++++++++++++----- deal.II/cmake/setup_custom_targets.cmake | 31 ++++++- deal.II/cmake/setup_finalize.cmake | 8 +- 3 files changed, 96 insertions(+), 26 deletions(-) diff --git a/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake b/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake index c0207506c9..6ea8b00511 100644 --- a/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake +++ b/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake @@ -38,6 +38,17 @@ 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() diff --git a/deal.II/cmake/setup_custom_targets.cmake b/deal.II/cmake/setup_custom_targets.cmake index 02e242c08d..4db3c2b4db 100644 --- a/deal.II/cmake/setup_custom_targets.cmake +++ b/deal.II/cmake/setup_custom_targets.cmake @@ -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 ): +# The following targets are available (invoke by $ ${_make_command} ): # # 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() diff --git a/deal.II/cmake/setup_finalize.cmake b/deal.II/cmake/setup_finalize.cmake index cb01181acf..45ed9f36a5 100644 --- a/deal.II/cmake/setup_finalize.cmake +++ b/deal.II/cmake/setup_finalize.cmake @@ -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###") -- 2.39.5