From af7825516c5cd326e10f0e95fda9efd1299a4ef4 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 17 Jun 2014 12:56:38 +0000 Subject: [PATCH] CMake: Cosmetic fixes wrt CMP0037 in CMake-3.0.0 - Suppress policy warning CMP0037 when using CMake-3.0.0, or newer - restrict target redefinition to ".*Unix Makefiles" Generators - Cleanup help messages to advertise "make info" instead of "make help" git-svn-id: https://svn.dealii.org/trunk@33055 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/CMakeLists.txt | 2 + .../macro_deal_ii_invoke_autopilot.cmake | 46 ++++++++----------- deal.II/cmake/setup_custom_targets.cmake | 15 ++++-- deal.II/cmake/setup_write_config.cmake | 6 +-- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/deal.II/CMakeLists.txt b/deal.II/CMakeLists.txt index 3b5c724258..4b0913a50c 100644 --- a/deal.II/CMakeLists.txt +++ b/deal.II/CMakeLists.txt @@ -32,6 +32,8 @@ # General configuration for cmake: # CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) +CMAKE_POLICY(VERSION 2.8.8) + MESSAGE(STATUS "This is CMake ${CMAKE_VERSION}") LIST(APPEND CMAKE_MODULE_PATH 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 323a2b229d..1a07962f5c 100644 --- a/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake +++ b/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake @@ -36,14 +36,13 @@ # empty # +CMAKE_POLICY(PUSH) +CMAKE_POLICY(VERSION 2.8.8) + MACRO(DEAL_II_INVOKE_AUTOPILOT) # Generator specific values: IF(CMAKE_GENERATOR MATCHES "Ninja") - # - # Ninja doesn't like a redefinition of the "help" target, so use "info" - # in this case... - # SET(_make_command "$ ninja") ELSE() SET(_make_command " $ make") @@ -209,40 +208,35 @@ ${_switch_targets}# # ") ENDIF() - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake + IF(PERL_FOUND) + 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 +") + ENDIF() + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake +"# ${_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) +# ${_make_command} info - to view this message again # -" - ) - 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(info COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake ) - IF(NOT CMAKE_GENERATOR MATCHES "Ninja") + + # + # In case of the Unix Makefiles generator it is safe to override the + # default 'help' target, which is - frankly - quite unhelpful. + # + IF(CMAKE_GENERATOR MATCHES "Unix Makefiles") ADD_CUSTOM_TARGET(help COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake ) @@ -253,12 +247,10 @@ ${_switch_targets}# INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake) SET(USAGE_PRINTED TRUE CACHE INTERNAL "") ELSE() - 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() + MESSAGE(STATUS "Run ${_make_command} info to print a detailed help message") ENDIF() ENDMACRO() +CMAKE_POLICY(POP) + diff --git a/deal.II/cmake/setup_custom_targets.cmake b/deal.II/cmake/setup_custom_targets.cmake index dbe20b221e..fcb3fbc127 100644 --- a/deal.II/cmake/setup_custom_targets.cmake +++ b/deal.II/cmake/setup_custom_targets.cmake @@ -80,12 +80,12 @@ 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( \"### @@ -105,7 +105,7 @@ IF(CMAKE_GENERATOR MATCHES "Ninja") ") ELSE() FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_info.cmake -"# help - print this help message in the toplevel directory, +"# info - print this help message in the toplevel directory, # otherwise print a list of targets (in subdirectories) # ") @@ -125,8 +125,8 @@ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_info.cmake # # test - run a minimal set of tests # -# setup_tests - set up the testsuite subprojects -# regen_tests - rerun configure stage in every testsuite subprojects +# setup_tests - set up testsuite subprojects +# regen_tests - rerun configure stage in every testsuite subproject # clean_tests - run the 'clean' target in every testsuite subproject # prune_tests - remove all testsuite subprojects # @@ -136,7 +136,12 @@ FILE(APPEND ${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") + +# +# In case of the Unix Makefiles generator it is safe to override the +# default 'help' target, which is - frankly - quite unhelpful. +# +IF(CMAKE_GENERATOR MATCHES "Unix Makefiles") ADD_CUSTOM_TARGET(help COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_info.cmake ) diff --git a/deal.II/cmake/setup_write_config.cmake b/deal.II/cmake/setup_write_config.cmake index 38c0351535..019e5f8d9f 100644 --- a/deal.II/cmake/setup_write_config.cmake +++ b/deal.II/cmake/setup_write_config.cmake @@ -227,10 +227,10 @@ _summary( #\n# Run $ " ) IF(CMAKE_GENERATOR MATCHES "Ninja") - _summary("ninja info") + _summary("ninja ") ELSE() -_summary("make help") +_summary("make ") ENDIF() -_summary(" to print a help message with a list of top level targets\n") +_summary("info to print a help message with a list of top level targets\n") _both("#\n###") -- 2.39.5