mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-02-17 16:50:18 +08:00
Reformatted CMakeLists.txt to move compiler options into a single unified block at the top.
This commit is contained in:
parent
dedeffc822
commit
3d681fa183
@ -104,7 +104,7 @@ INCLUDE(GenerateExportHeader)
|
||||
################################
|
||||
|
||||
|
||||
# Default to shared libs on.
|
||||
# Default building shared libraries.
|
||||
OPTION(BUILD_SHARED_LIBS "Configure netCDF as a shared library." ON)
|
||||
SET (LIB_TYPE STATIC)
|
||||
IF (BUILD_SHARED_LIBS)
|
||||
@ -114,26 +114,59 @@ IF (BUILD_SHARED_LIBS)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Supress unused variable and parameter warnings, for the time being,
|
||||
# on GCC.
|
||||
#
|
||||
# Also, set some other default compiler flags.
|
||||
# Set some default linux gcc & apple compiler options for
|
||||
# debug builds.
|
||||
IF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
|
||||
|
||||
OPTION (ENABLE_COVERAGE_TESTS "Enable compiler flags needed to perform coverage tests." OFF)
|
||||
OPTION (ENABLE_CONVERSION_WARNINGS "Enable warnings for implicit conversion from 64 to 32-bit datatypes." ON)
|
||||
OPTION (ENABLE_USED_VAR_PAR_WARNINGS "Enable warnings for unused parameters and variables. Creates very noisy output." OFF)
|
||||
|
||||
# Debugging flags
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT ENABLE_COVERAGE_TESTS)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -O2")
|
||||
ENDIF()
|
||||
# Coverage tests need to have optimization turned off.
|
||||
IF(NOT ENABLE_COVERAGE_TESTS)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -O2")
|
||||
ELSE()
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -profile-arcs -ftest-coverage")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
MESSAGE(STATUS "Coverage Tests: On.")
|
||||
ENDIF()
|
||||
|
||||
# Unused var and parameter warnings create a lot of noise.
|
||||
IF(NOT ENABLE_UNUSED_VAR_PAR_WARNINGS)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable -Wno-unused-parameter")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Wno-unused-parameter")
|
||||
ENDIF()
|
||||
|
||||
# Warnings for 64-to-32 bit conversions.
|
||||
IF(ENABLE_CONVERSION_WARNINGS)
|
||||
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(ENABLE_CONVERSION_WARNINGS)
|
||||
|
||||
IF(NOT ENABLE_UNUSED_VAR_PAR_WARNINGS)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-varaible -Wno-unused-parameter")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Wno-unused-parameter")
|
||||
ENDIF()
|
||||
# On 64-bit linux builds with large file tests enabled, we need to
|
||||
# specify the mcmodel flag.
|
||||
IF(CMAKE_SIZEOF_VOID EQUAL 8 AND CMAKE_COMPILER_IS_GNUCC AND ENABLE_LARGE_FILE_TESTS) # 64-bit gcc platform
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcmodel=large")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcmodel=large")
|
||||
ENDIF()
|
||||
|
||||
|
||||
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
|
||||
|
||||
# End default linux gcc & apple compiler options.
|
||||
|
||||
ADD_DEFINITIONS()
|
||||
|
||||
# Supress CRT Warnings.
|
||||
@ -269,6 +302,9 @@ MACRO(print_conf_summary)
|
||||
ENDIF()
|
||||
MESSAGE(STATUS "\tUsing pnetcdf:\t\t\t" ${STATUS_PNETCDF})
|
||||
MESSAGE(STATUS "\tUsing Parallel IO:\t\t" ${STATUS_PARALLEL})
|
||||
MESSAGE(STATUS "\tCMAKE_C_FLAGS:\t\t" ${CMAKE_C_FLAGS})
|
||||
MESSAGE(STATUS "\tCMAKE_CXX_FLAGS:\t\t" ${CMAKE_CXX_FLAGS})
|
||||
|
||||
MESSAGE(STATUS "\tLinking against:\t\t" "${ALL_TLL_LIBS}")
|
||||
|
||||
MESSAGE("")
|
||||
@ -426,18 +462,6 @@ IF(ENABLE_DISKLESS)
|
||||
SET(USE_DISKLESS ON)
|
||||
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)
|
||||
@ -685,18 +709,6 @@ IF(ENABLE_LARGE_FILE_SUPPORT)
|
||||
ENDIF()
|
||||
|
||||
|
||||
# Provide the option to perform coverage tests.
|
||||
IF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
|
||||
OPTION (ENABLE_COVERAGE_TESTS "Enable compiler flags needed to perform coverage tests." OFF)
|
||||
IF(ENABLE_COVERAGE_TESTS)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -profile-arcs -ftest-coverage")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
MESSAGE(STATUS "Coverage Tests: On.")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
|
||||
OPTION (ENABLE_EXAMPLE_TESTS "Run extra example tests. Requires GNU Sed. Ignored if netCDF-4 is not Enabled" OFF)
|
||||
IF(NOT ENABLE_NETCDF_4 AND ENABLE_EXAMPLE_TESTS)
|
||||
SET (ENABLE_EXAMPLE_TESTS OFF)
|
||||
|
Loading…
Reference in New Issue
Block a user