Skip to content

Commit

Permalink
Merge pull request #2839 from jschueller/unity
Browse files Browse the repository at this point in the history
CMake: Add support for UNITY_BUILD
  • Loading branch information
WardF committed Jan 22, 2024
2 parents 850e2f4 + 9faaa05 commit 5b79304
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 0 deletions.
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This file contains a high-level description of this package's evolution. Release

## 4.9.3 - TBD


* Added infrastructure to allow for `CMAKE_UNITY_BUILD`, (thanks \@jschueller). See [Github #2839](https://github.com/Unidata/netcdf-c/pull/2839) for more information.
* [cmake] Move dependency management out of the root-level `CMakeLists.txt` into two different files in the `cmake/` folder, `dependencies.cmake` and `netcdf_functions_macros.cmake`. See [Github #2838](https://github.com/Unidata/netcdf-c/pull/2838/) for more information.
* Obviate a number of irrelevant warnings. See [Github #2781](https://github.com/Unidata/netcdf-c/pull/2781).
* Improve the speed and data quantity for DAP4 queries. See [Github #2765](https://github.com/Unidata/netcdf-c/pull/2765).
Expand Down
18 changes: 18 additions & 0 deletions libdap2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@
# See netcdf-c/COPYRIGHT file for more info.
SET(dap2_SOURCES constraints.c dapcvt.c dapodom.c daputil.c ncdaperr.c cdf.c cache.c dapdump.c dapdebug.c dapattr.c ncd2dispatch.c getvara.c dceconstraints.c dcetab.c dceparse.c dcelex.c)

##
# Turn off inclusion of particular files when using the cmake-native
# option to turn on Unity Builds.
#
# For more information, see:
# * https://github.com/Unidata/netcdf-c/pull/2839/
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD_MODE.html#prop_tgt:UNITY_BUILD_MODE
##
set_property(SOURCE ncd2dispatch.c
PROPERTY
SKIP_UNITY_BUILD_INCLUSION ON)


set_property(SOURCE ncd2dispatch.c
PROPERTY
SKIP_UNITY_BUILD_INCLUSION ON)

add_library(dap2 OBJECT ${dap2_SOURCES})

IF(STATUS_PARALLEL)
Expand Down
13 changes: 13 additions & 0 deletions libdap4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
# See netcdf-c/COPYRIGHT file for more info.
SET(dap4_SOURCES d4curlfunctions.c d4fix.c d4data.c d4file.c d4parser.c d4meta.c d4varx.c d4dump.c d4swap.c d4chunk.c d4printer.c d4read.c d4http.c d4util.c d4odom.c d4cvt.c d4debug.c ncd4dispatch.c)

##
# Turn off inclusion of particular files when using the cmake-native
# option to turn on Unity Builds.
#
# For more information, see:
# * https://github.com/Unidata/netcdf-c/pull/2839/
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD_MODE.html#prop_tgt:UNITY_BUILD_MODE
##
set_property(SOURCE d4meta.c
PROPERTY
SKIP_UNITY_BUILD_INCLUSION ON)

add_library(dap4 OBJECT ${dap4_SOURCES})

IF(STATUS_PARALLEL)
Expand Down
13 changes: 13 additions & 0 deletions libdispatch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ SET(libdispatch_SOURCES dcopy.c dfile.c ddim.c datt.c dattinq.c dattput.c dattge
daux.c dinstance.c dinstance_intern.c
dcrc32.c dcrc32.h dcrc64.c ncexhash.c ncxcache.c ncjson.c ds3util.c dparallel.c dmissing.c)

##
# Turn off inclusion of particular files when using the cmake-native
# option to turn on Unity Builds.
#
# For more information, see:
# * https://github.com/Unidata/netcdf-c/pull/2839/
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD_MODE.html#prop_tgt:UNITY_BUILD_MODE
##
set_property(SOURCE dinstance_intern.c dinstance.c dvarput.c
PROPERTY
SKIP_UNITY_BUILD_INCLUSION ON)

# Netcdf-4 only functions. Must be defined even if not used
SET(libdispatch_SOURCES ${libdispatch_SOURCES} dgroup.c dvlen.c dcompound.c dtype.c denum.c dopaque.c dfilter.c)

Expand Down
13 changes: 13 additions & 0 deletions libsrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
SET(libsrc_SOURCES v1hpg.c putget.c attr.c nc3dispatch.c
nc3internal.c var.c dim.c ncx.c lookup3.c ncio.c)

##
# Turn off inclusion of particular files when using the cmake-native
# option to turn on Unity Builds.
#
# For more information, see:
# * https://github.com/Unidata/netcdf-c/pull/2839/
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD_MODE.html#prop_tgt:UNITY_BUILD_MODE
##
set_property(SOURCE httpio.c posixio.c mmapio.c
PROPERTY
SKIP_UNITY_BUILD_INCLUSION ON)

# Process these files with m4.
SET(m4_SOURCES attr ncx putget)
foreach (f ${m4_SOURCES})
Expand Down
11 changes: 11 additions & 0 deletions nc_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ TARGET_LINK_LIBRARIES(nc_test
${HAVE_LIBM}
)

##
# Turn off inclusion of particular files when using the cmake-native
# option to turn on Unity Builds.
#
# For more information, see:
# * https://github.com/Unidata/netcdf-c/pull/2839/
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD_MODE.html#prop_tgt:UNITY_BUILD_MODE
##
set_property(TARGET nc_test PROPERTY UNITY_BUILD OFF)

# Some extra stand-alone tests
SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta tst_inq_type tst_utf8_phrases tst_global_fillval tst_max_var_dims tst_formats tst_def_var_fill tst_err_enddef tst_default_format)

Expand Down
13 changes: 13 additions & 0 deletions ncdump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ SET(ncpathcvt_FILES ncpathcvt.c ${XGETOPTSRC})
SET(ncfilteravail_FILES ncfilteravail.c ${XGETOPTSRC})
SET(nchdf5version_FILES nchdf5version.c)

##
# Turn off inclusion of particular files when using the cmake-native
# option to turn on Unity Builds.
#
# For more information, see:
# * https://github.com/Unidata/netcdf-c/pull/2839/
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD_MODE.html#prop_tgt:UNITY_BUILD_MODE
##
set_property(SOURCE dumplib.c
PROPERTY
SKIP_UNITY_BUILD_INCLUSION ON)

ADD_EXECUTABLE(ncdump ${ncdump_FILES})
ADD_EXECUTABLE(nccopy ${nccopy_FILES})
ADD_EXECUTABLE(ncvalidator ${ncvalidator_FILES})
Expand Down
13 changes: 13 additions & 0 deletions ncgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ util.c bytebuffer.h data.h debug.h dump.h
generate.h generr.h genlib.h includes.h list.h
ncgen.h ncgeny.h util.h ${XGETOPTSRC})

##
# Turn off inclusion of particular files when using the cmake-native
# option to turn on Unity Builds.
#
# For more information, see:
# * https://github.com/Unidata/netcdf-c/pull/2839/
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD_MODE.html#prop_tgt:UNITY_BUILD_MODE
##
set_property(SOURCE data.c
PROPERTY
SKIP_UNITY_BUILD_INCLUSION ON)

# Obsolete
SET(OBSOLETE odom.c odom.h jdatastd.c jdatajni.c genjni.c cdfdata.c cmldata.c)

Expand Down
11 changes: 11 additions & 0 deletions nctest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ ADD_EXECUTABLE(nctest ${nctest_SRC})
TARGET_LINK_LIBRARIES(nctest netcdf)
ADD_TEST(nctest ${EXECUTABLE_OUTPUT_PATH}/nctest)

##
# Turn off inclusion of particular files when using the cmake-native
# option to turn on Unity Builds.
#
# For more information, see:
# * https://github.com/Unidata/netcdf-c/pull/2839/
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html
# * https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD_MODE.html#prop_tgt:UNITY_BUILD_MODE
##
set_property(TARGET nctest PROPERTY UNITY_BUILD OFF)

add_bin_test_no_prefix(tst_rename)
IF(BUILD_UTILITIES)
add_sh_test(nctest compare_test_files)
Expand Down

0 comments on commit 5b79304

Please sign in to comment.