Added new option to enable/disable 'Data Conversion warnings', ENABLE_CONVERSION_WARNINGS, when using CMake-based builds.

Added a custom cmake test configuration file to override the default '50' warnings when submitting to a remote dashboard.
Updated Building-with-CMake file.
This commit is contained in:
Ward Fisher 2013-09-16 11:45:34 -06:00
parent c238435853
commit 49ad32e610
4 changed files with 57 additions and 12 deletions

View File

@ -41,6 +41,9 @@ ENDIF()
ENABLE_TESTING()
INCLUDE(CTest)
# Copy the CTest customization file into binary directory, as required.
FILE(COPY ${CMAKE_SOURCE_DIR}/CTestCustom.cmake DESTINATION ${CMAKE_BINARY_DIR})
# For CMAKE_INSTALL_LIBDIR
INCLUDE(GNUInstallDirs)
@ -332,11 +335,25 @@ IF(ENABLE_DISKLESS)
ENDIF()
IF(ENABLE_COVERAGE_TESTS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -Wall -W -fprofile-arcs -ftest-coverage")
SET(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -Wall -W -fprofile-arcs -ftest-coverage")
SET(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
ENDIF()
ENDIF()
OPTION(ENABLE_CONVERSION_WARNINGS "Enable warnings for implicit conversion from 64 to 32-bit datatypes." ON)
IF(ENABLE_CONVERSION_WARNINGS)
IF(NOT MSVC)
IF(APPLE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshorten-64-to-32")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshorten-64-to-32")
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconversion")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion")
ENDIF(APPLE)
ENDIF(NOT MSVC)
ENDIF(ENABLE_CONVERSION_WARNINGS)
# Option Logging, only valid for netcdf4.
OPTION (ENABLE_LOGGING "Enable Logging." OFF)
IF(ENABLE_LOGGING)
@ -760,7 +777,7 @@ ENDIF()
# Create config.h file, nc-config
configure_file("${netCDF_SOURCE_DIR}/config.h.in.cmake"
"${netCDF_BINARY_DIR}/config.h")
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
INSTALL(PROGRAMS ${netCDF_BINARY_DIR}/nc-config DESTINATION bin COMPONENT utilities)
INCLUDE_DIRECTORIES(${netCDF_BINARY_DIR})
# End autotools-style checs for config.h

8
CTestCustom.cmake Normal file
View File

@ -0,0 +1,8 @@
## This file is used to customize CTest.
## See:
##
## http://public.kitware.com/Wiki/CTest:Using_CTEST_and_CDASH_without_CMAKE
##
## for more information.
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS "10000")

View File

@ -1,6 +1,5 @@
#ifndef CONFIG_H
#define CONFIG_H
#define HAVE_CONFIG_H
/* Eliminate a number of warnings which come up based on deprecated
POSIX naming conventions. */

View File

@ -118,18 +118,30 @@ or
## <a id="faqtoc"></a> Table of Contents
* [How can I see the options available to CMake?](#listoptions)
* [How do I specify how to build a shared or static library?](#sharedstatic)
* [Can I build both shared and static libraries at the same time with cmake?](#sharedstaticboth)
* [What if I want to link against multiple libraries in a non-standard location?](#nonstdloc)
* [How can I see the options available to CMake?](#listoptions)
* [How can I specify a Parallel Build using HDF5](#parallelhdf)
## Frequently Asked Questions
* **How can I see the options available to CMake?** <a id="listoptions"></a>
> cmake [path to source tree] -L - This will show the basic options.
> cmake [path to source tree] -LA - This will show the basic and advanced options.
[Back to the top of the FAQ](#faqtoc)
--
* **How do I specify how to build a shared or static library?** <a id="sharedstatic"></a>
-DBUILD_SHARED_LIBS=[ON/OFF]
[Back to the top of FAQ](#faqtoc)
[Back to the top of the FAQ](#faqtoc)
--
@ -139,7 +151,7 @@ or
Not at this time; it is required to instead build first one version, and then the other, if you need both.
[Back to the top of FAQ](#faqtoc)
[Back to the top of the FAQ](#faqtoc)
--
@ -159,7 +171,7 @@ Not at this time; it is required to instead build first one version, and then th
* -DHDF5_LIBRARIES="/path/to/hdf5.lib;/path/to/hdf5_hl.lib" -DHDF5_INCLUDE_DIRS=/path/to/hdf5/include/
[Back to the top of FAQ](#faqtoc)
[Back to the top of the FAQ](#faqtoc)
--
@ -171,14 +183,23 @@ Not at this time; it is required to instead build first one version, and then th
or
> cmake [Source Directory] -DCMAKE_PREFIX_PATH=/usr/custom_library_locations/
[Back to the top of FAQ](#faqtoc)
[Back to the top of the FAQ](#faqtoc)
--
* **How can I see the options available to CMake?** <a id="listoptions"></a>
* **How can I specify a Parallel Build using HDF5** <a id="parallelhdf"></a>
> cmake [path to source tree] -L - This will show the basic options.
> cmake [path to source tree] -LA - This will show the basic and advanced options.
If cmake is having problems finding the parallel HDF5 install, you can specify the location manually:
-DENABLE_PARALLEL=ON
-DHDF5_LIB=/usr/lib64/openmpi/lib/libhdf5.so
-DHDF5_HL_LIB=/usr/lib64/openmpi/lib/libhdf5.hl.so
-DHDF5_INCLUDE_DIR=/usr/include/openmpi-x86_64
You will, of course, need to use the location of the libraries specific to your development environment.
[Back to the top of FAQ](#faqtoc)