From ccc3669b7c5f0fe6e185b0ed4da8fa9211167ac7 Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Mon, 11 Jun 2012 11:34:24 +0200 Subject: [PATCH] Merge commit '718c486de0b35dccb23a56ae1073c115c5689a2f' into merge_subtree * commit '718c486de0b35dccb23a56ae1073c115c5689a2f': Typo. Added CMake variables value list script. Fixed FindQVTK on Windows. Added FindQVTK.cmake Added FindNetCDF.cmake from https://github.com/jedbrown/cmake-modules Added script for disabling compiler flags. This is release version 5.3.0. White space fixes. SOme small fixes. Cobertura code coverage report generation with gcovr added. Fixed typo. Conflicts: scripts/cmake/cmake/CodeCoverage.cmake --- scripts/cmake/cmake/CodeCoverage.cmake | 16 +++-- scripts/cmake/cmake/FindMsysGit.cmake | 40 +++++++++++ scripts/cmake/cmake/FindNetCDF.cmake | 71 +++++++++++++++++++ scripts/cmake/cmake/FindQVTK.cmake | 27 +++++++ .../cmake/ListAllCMakeVariableValues.cmake | 15 ++++ 5 files changed, 162 insertions(+), 7 deletions(-) create mode 100644 scripts/cmake/cmake/FindMsysGit.cmake create mode 100644 scripts/cmake/cmake/FindNetCDF.cmake create mode 100644 scripts/cmake/cmake/FindQVTK.cmake create mode 100644 scripts/cmake/cmake/ListAllCMakeVariableValues.cmake diff --git a/scripts/cmake/cmake/CodeCoverage.cmake b/scripts/cmake/cmake/CodeCoverage.cmake index 1277a3167d1..3529a098d06 100644 --- a/scripts/cmake/cmake/CodeCoverage.cmake +++ b/scripts/cmake/cmake/CodeCoverage.cmake @@ -39,6 +39,8 @@ LINK_LIBRARIES(gcov) # Param _testrunner The name of the target which runs the tests # Param _outputname lcov output is generated as _outputname.info # HTML report is generated in _outputname/index.html +# Optional fourth parameter is passed as arguments to _testrunner +# Pass them in list form, e.g.: "-j;2" for -j 2 FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) IF(NOT LCOV_PATH) @@ -56,7 +58,7 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) ${LCOV_PATH} --directory . --zerocounters # Run tests - COMMAND ${_testrunner} + COMMAND ${_testrunner} ${ARGV3} # Capturing lcov counters and generating report COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info @@ -64,7 +66,6 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_outputname}.info.cleaned - DEPENDS ${_testrunner} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." ) @@ -79,8 +80,9 @@ ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE # Param _targetname The name of new the custom make target # Param _testrunner The name of the target which runs the tests -# Param _outputname lcov output is generated as _outputname.info -# HTML report is generated in _outputname/index.html +# Param _outputname cobertura output is generated as _outputname.xml +# Optional fourth parameter is passed as arguments to _testrunner +# Pass them in list form, e.g.: "-j;2" for -j 2 FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname) IF(NOT PYTHON_EXECUTABLE) @@ -94,10 +96,10 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname ADD_CUSTOM_TARGET(${_targetname} # Run tests - ${_testrunner} + ${_testrunner} ${ARGV3} # Running gcovr - COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -o ${_outputname}.xml + COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Running gcovr to produce Cobertura code coverage report." ) @@ -108,4 +110,4 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname COMMENT "Cobertura code coverage report saved in ${_outputname}.xml." ) -ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA \ No newline at end of file +ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA diff --git a/scripts/cmake/cmake/FindMsysGit.cmake b/scripts/cmake/cmake/FindMsysGit.cmake new file mode 100644 index 00000000000..2085ed046f8 --- /dev/null +++ b/scripts/cmake/cmake/FindMsysGit.cmake @@ -0,0 +1,40 @@ +# The module defines the following variables: +# MSYSGIT_BIN_DIR - path to the tool binaries +# MSYSGIT_FOUND - true if the command line client was found +# Example usage: +# FIND_PACKAGE(MsysGit) +# IF(MSYSGIT_FOUND) +# MESSAGE("msysGit tools found in: ${MSYSGIT_BIN_DIR}") +# ENDIF() + +if(GIT_EXECUTABLE) + EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} --version + OUTPUT_VARIABLE git_version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + IF (git_version MATCHES "^git version [0-9]") + STRING(REPLACE "git version " "" GIT_VERSION_STRING "${git_version}") + IF (git_version MATCHES "msysgit") + SET(GIT_IS_MSYSGIT TRUE) + ELSE() + SET(GIT_IS_MSYSGIT FALSE) + ENDIF() + ENDIF() + UNSET(git_version) +ENDIF(GIT_EXECUTABLE) + +IF(GIT_IS_MSYSGIT) + GET_FILENAME_COMPONENT(MSYS_DIR ${GIT_EXECUTABLE} PATH) + FIND_PATH(MSYSGIT_BIN_DIR + NAMES date.exe grep.exe unzip.exe git.exe PATHS ${MSYS_DIR}/../bin NO_DEFAULT_PATH) +ELSE() + FIND_PATH(MSYSGIT_BIN_DIR + NAMES date.exe grep.exe unzip.exe git.exe PATH_SUFFIXES Git/bin) +ENDIF() + +# Handle the QUIETLY and REQUIRED arguments and set MSYSGIT_FOUND to TRUE if +# all listed variables are TRUE + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(MsysGit + REQUIRED_VARS MSYSGIT_BIN_DIR) \ No newline at end of file diff --git a/scripts/cmake/cmake/FindNetCDF.cmake b/scripts/cmake/cmake/FindNetCDF.cmake new file mode 100644 index 00000000000..6f40c7e5047 --- /dev/null +++ b/scripts/cmake/cmake/FindNetCDF.cmake @@ -0,0 +1,71 @@ +# - Find NetCDF +# Find the native NetCDF includes and library +# +# NETCDF_INCLUDES - where to find netcdf.h, etc +# NETCDF_LIBRARIES - Link these libraries when using NetCDF +# NETCDF_FOUND - True if NetCDF found including required interfaces (see below) +# +# Your package can require certain interfaces to be FOUND by setting these +# +# NETCDF_CXX - require the C++ interface and link the C++ library +# NETCDF_F77 - require the F77 interface and link the fortran library +# NETCDF_F90 - require the F90 interface and link the fortran library +# +# The following are not for general use and are included in +# NETCDF_LIBRARIES if the corresponding option above is set. +# +# NETCDF_LIBRARIES_C - Just the C interface +# NETCDF_LIBRARIES_CXX - C++ interface, if available +# NETCDF_LIBRARIES_F77 - Fortran 77 interface, if available +# NETCDF_LIBRARIES_F90 - Fortran 90 interface, if available +# +# Normal usage would be: +# set (NETCDF_F90 "YES") +# find_package (NetCDF REQUIRED) +# target_link_libraries (uses_f90_interface ${NETCDF_LIBRARIES}) +# target_link_libraries (only_uses_c_interface ${NETCDF_LIBRARIES_C}) + +if (NETCDF_INCLUDES AND NETCDF_LIBRARIES) + # Already in cache, be silent + set (NETCDF_FIND_QUIETLY TRUE) +endif (NETCDF_INCLUDES AND NETCDF_LIBRARIES) + +find_path (NETCDF_INCLUDES netcdf.h + HINTS NETCDF_DIR ENV NETCDF_DIR) + +find_library (NETCDF_LIBRARIES_C NAMES netcdf) +mark_as_advanced(NETCDF_LIBRARIES_C) + +set (NetCDF_has_interfaces "YES") # will be set to NO if we're missing any interfaces +set (NetCDF_libs "${NETCDF_LIBRARIES_C}") + +get_filename_component (NetCDF_lib_dirs "${NETCDF_LIBRARIES_C}" PATH) + +macro (NetCDF_check_interface lang header libs) + if (NETCDF_${lang}) + find_path (NETCDF_INCLUDES_${lang} NAMES ${header} + HINTS "${NETCDF_INCLUDES}" NO_DEFAULT_PATH) + find_library (NETCDF_LIBRARIES_${lang} NAMES ${libs} + HINTS "${NetCDF_lib_dirs}" NO_DEFAULT_PATH) + mark_as_advanced (NETCDF_INCLUDES_${lang} NETCDF_LIBRARIES_${lang}) + if (NETCDF_INCLUDES_${lang} AND NETCDF_LIBRARIES_${lang}) + list (INSERT NetCDF_libs 0 ${NETCDF_LIBRARIES_${lang}}) # prepend so that -lnetcdf is last + else (NETCDF_INCLUDES_${lang} AND NETCDF_LIBRARIES_${lang}) + set (NetCDF_has_interfaces "NO") + message (STATUS "Failed to find NetCDF interface for ${lang}") + endif (NETCDF_INCLUDES_${lang} AND NETCDF_LIBRARIES_${lang}) + endif (NETCDF_${lang}) +endmacro (NetCDF_check_interface) + +NetCDF_check_interface (CXX netcdfcpp.h netcdf_c++) +NetCDF_check_interface (F77 netcdf.inc netcdff) +NetCDF_check_interface (F90 netcdf.mod netcdff) + +set (NETCDF_LIBRARIES "${NetCDF_libs}" CACHE STRING "All NetCDF libraries required for interface level") + +# handle the QUIETLY and REQUIRED arguments and set NETCDF_FOUND to TRUE if +# all listed variables are TRUE +include (FindPackageHandleStandardArgs) +find_package_handle_standard_args (NetCDF DEFAULT_MSG NETCDF_LIBRARIES NETCDF_INCLUDES NetCDF_has_interfaces) + +mark_as_advanced (NETCDF_LIBRARIES NETCDF_INCLUDES) \ No newline at end of file diff --git a/scripts/cmake/cmake/FindQVTK.cmake b/scripts/cmake/cmake/FindQVTK.cmake new file mode 100644 index 00000000000..b50f40055f5 --- /dev/null +++ b/scripts/cmake/cmake/FindQVTK.cmake @@ -0,0 +1,27 @@ +############################################################################### +# Find QVTK +# +# This sets the following variables: +# +# QVTK_FOUND - True if QVTK was found +# QVTK_INCLUDE_DIR - Directory containing the QVTK include files +# QVTK_LIBRARY - QVTK library +# +# If QVTK_FOUND then QVTK_INCLUDE_DIR is appended to VTK_INCLUDE_DIRS and +# QVTK_LIBRARY is appended to QVTK_LIBRARY_DIR. +# + +find_library (QVTK_LIBRARY QVTK HINTS ${VTK_DIR} ${VTK_DIR}/bin + PATH_SUFFIXES Release Debug) +find_path (QVTK_INCLUDE_DIR QVTKWidget.h HINT ${VTK_INCLUDE_DIRS}) +find_package_handle_standard_args(QVTK DEFAULT_MSG + QVTK_LIBRARY QVTK_INCLUDE_DIR) + +if(NOT QVTK_FOUND) + set (VTK_USE_QVTK OFF) +else(NOT QVTK_FOUND) + get_filename_component (QVTK_LIBRARY_DIR ${QVTK_LIBRARY} PATH) + set (VTK_LIBRARY_DIRS ${VTK_LIBRARY_DIRS} ${QVTK_LIBRARY_DIR}) + set (VTK_INCLUDE_DIRS ${VTK_INCLUDE_DIRS} ${QVTK_INCLUDE_DIR}) + set (VTK_USE_QVTK ON) +endif(NOT QVTK_FOUND) diff --git a/scripts/cmake/cmake/ListAllCMakeVariableValues.cmake b/scripts/cmake/cmake/ListAllCMakeVariableValues.cmake new file mode 100644 index 00000000000..e39367ca8b1 --- /dev/null +++ b/scripts/cmake/cmake/ListAllCMakeVariableValues.cmake @@ -0,0 +1,15 @@ +# From http://www.kitware.com/blog/home/post/300 +# +# Usage: +# +# INCLUDE(ListAllCMakeVariableValues) +# list_all_cmake_variable_values() + +function(list_all_cmake_variable_values) + message(STATUS "") + get_cmake_property(vs VARIABLES) + foreach(v ${vs}) + message(STATUS "${v}='${${v}}'") + endforeach(v) + message(STATUS "") +endfunction() -- GitLab