Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake cleaning #64

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 25 additions & 67 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
##################################

#Minimum required CMake Version
cmake_minimum_required(VERSION 2.8.8)
cmake_minimum_required(VERSION 2.8.9)

#Project Name
project(netCDF C)
Expand Down Expand Up @@ -137,13 +137,8 @@ INCLUDE(GenerateExportHeader)

# Default building shared libraries.
OPTION(BUILD_SHARED_LIBS "Configure netCDF as a shared library." ON)
SET(LIB_TYPE STATIC)
IF(BUILD_SHARED_LIBS)
SET(LIB_TYPE SHARED)
IF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fPIC")
ENDIF()
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
ENDIF()

# Set some default linux gcc & apple compiler options for
Expand Down Expand Up @@ -334,7 +329,7 @@ MACRO(print_conf_summary)
MESSAGE("")
ENDIF()

MESSAGE("Tests Enabled: ${ENABLE_TESTS}")
MESSAGE("Tests Enabled: ${ENABLE_TESTS}")
IF(ENABLE_TESTS)
MESSAGE(STATUS "DAP Remote Tests: ${ENABLE_DAP_REMOTE_TESTS}")
MESSAGE(STATUS "DAP AUTH Tests: ${ENABLE_DAP_AUTH_TESTS}")
Expand Down Expand Up @@ -465,8 +460,6 @@ ENDIF()
# Option checks
################################

SET(CMAKE_INCLUDE_CURRENT_DIR ON)

# HDF5 cache variables.
SET(DEFAULT_CHUNK_SIZE 4194304 CACHE STRING "Default Chunk Cache Size.")
SET(DEFAULT_CHUNKS_IN_CACHE 10 CACHE STRING "Default number of chunks in cache.")
Expand Down Expand Up @@ -642,7 +635,7 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
FIND_PACKAGE(HDF5 COMPONENTS C HL REQUIRED)
ENDIF()
ENDIF()

IF(NOT MSVC)
# Depending on the install, either HDF5_hdf_library or
# HDF5_C_LIBRARY may be defined. We must check for either.
Expand Down Expand Up @@ -691,7 +684,7 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
ELSE()
IF(${HDF5_VERSION} VERSION_LESS ${HDF5_VERSION_REQUIRED})
MESSAGE(FATAL_ERROR
"netCDF requires at least HDF5 ${HDF5_VERSION_REQUIRED}. Found ${HDF5_VERSION}.")
"netCDF requires at least HDF5 ${HDF5_VERSION_REQUIRED}. Found ${HDF5_VERSION}.")
ENDIF()
ENDIF()

Expand Down Expand Up @@ -747,23 +740,27 @@ IF(ENABLE_DAP)
ADD_DEFINITIONS(-DCURL_STATICLIB=1)
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})

# Check to see if CURLOPT_USERNAME is defined. It is present starting version 7.19.1
# Check to see if CURLOPT_USERNAME is defined.
# It is present starting version 7.19.1.
CHECK_C_SOURCE_COMPILES("
#include <curl/curl.h>
int main() {int x = CURLOPT_USERNAME;}" HAVE_CURLOPT_USERNAME)

# Check to see if CURLOPT_PASSWORD is defined. It is present starting version 7.19.1
CHECK_C_SOURCE_COMPILES("
# Check to see if CURLOPT_PASSWORD is defined.
# It is present starting version 7.19.1.
CHECK_C_SOURCE_COMPILES("
#include <curl/curl.h>
int main() {int x = CURLOPT_PASSWORD;}" HAVE_CURLOPT_PASSWORD)

# Check to see if CURLOPT_KEYPASSWD is defined. It is present starting version 7.16.4
CHECK_C_SOURCE_COMPILES("
# Check to see if CURLOPT_KEYPASSWD is defined.
# It is present starting version 7.16.4.
CHECK_C_SOURCE_COMPILES("
#include <curl/curl.h>
int main() {int x = CURLOPT_KEYPASSWD;}" HAVE_CURLOPT_KEYPASSWD)

# Check to see if CURLINFO_RESPONSE_CODE is defined. It showed up in curl 7.10.7
CHECK_C_SOURCE_COMPILES("
# Check to see if CURLINFO_RESPONSE_CODE is defined.
# It showed up in curl 7.10.7.
CHECK_C_SOURCE_COMPILES("
#include <curl/curl.h>
int main() {int x = CURLINFO_RESPONSE_CODE;}" HAVE_CURLINFO_RESPONSE_CODE)
ENDIF()
Expand Down Expand Up @@ -851,7 +848,7 @@ IF(ENABLE_FSYNC)
SET(USE_FSYNC ON)
ENDIF()

# Temporary
# Temporary
OPTION (ENABLE_JNA "Enable jna bug fix code." OFF)
IF(ENABLE_JNA)
SET(JNA ON)
Expand Down Expand Up @@ -927,7 +924,7 @@ IF(ENABLE_DOXYGEN)
ELSE()
SET(BUILD_INTERNAL_DOCS NO CACHE STRING "")
ENDIF()

# Option to turn on the TODO list in the doxygen-generated documentation.
OPTION(ENABLE_DOXYGEN_TASKS "Turn on test, todo, bug lists in documentation. This is of interest to developers only." OFF)
IF(ENABLE_DOXYGEN_TASKS)
Expand Down Expand Up @@ -1168,12 +1165,12 @@ ADD_SUBDIRECTORY(docs)
# Moving on to CPack, install packages.
#####
INSTALL(FILES ${netCDF_SOURCE_DIR}/include/netcdf.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT headers)

IF(ENABLE_PNETCDF OR ENABLE_PARALLEL)
INSTALL(FILES ${netCDF_SOURCE_DIR}/include/netcdf_par.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT headers)
ENDIF()

Expand Down Expand Up @@ -1266,7 +1263,7 @@ INSTALL(FILES ${netCDF_BINARY_DIR}/netcdf.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT utilities)

INSTALL(PROGRAMS ${netCDF_BINARY_DIR}/nc-config
INSTALL(PROGRAMS ${netCDF_BINARY_DIR}/nc-config
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT utilities)

Expand Down Expand Up @@ -1369,49 +1366,10 @@ SET(abs_top_builddir "${CMAKE_BINARY_DIR}")

SET(CC_VERSION "${CMAKE_C_COMPILER}")


# Build CFLAGS from debug and release flags as needed.
SET(CFLAGS_TMP "${CMAKE_C_FLAGS}")

IF("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
SET(CFLAGS_TMP "${CFLAGS_TMP} ${CMAKE_C_FLAGS_DEBUG}")
ENDIF()

IF("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
SET(CFLAGS_TMP "${CFLAGS_TMP} ${CMAKE_C_FLAGS_RELEASE}")
ENDIF()

SET(CFLAGS "${CFLAGS_TMP} ${CFLAGS}")
# End CFLAGS

# Build CPPFLAGS from debug and release flags as needed.
SET(CPPFLAGS_TMP "${CMAKE_CPP_FLAGS}")

IF("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
SET(CPPFLAGS_TMP "${CPPFLAGS_TMP} ${CMAKE_CPP_FLAGS_DEBUG}")
ENDIF()

IF("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
SET(CPPFLAGS_TMP "${CPPFLAGS_TMP} ${CMAKE_CPP_FLAGS_RELEASE}")
ENDIF()

SET(CPPFLAGS "${CPPFLAGS_TMP} ${CPPFLAGS}")
# End CPPFLAGS

# Build LDFLAGS from debug and release flags as needed.
SET(LDFLAGS_TMP "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_LINKER_FLAGS}")

IF("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
SET(LDFLAGS_TMP "${LDFLAGS_TMP} ${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${CMAKE_LINKER_FLAGS_DEBUG}")
ENDIF()

IF("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
SET(LDFLAGS_TMP "${LDFLAGS_TMP} ${CMAKE_SHARED_LINKER_FLAGS_RELEASE} ${CMAKE_LINKER_FLAGS_RELEASE}")
ENDIF()

SET(LDFLAGS "${LDFLAGS_TMP} ${LDFLAGS}")
# End LDFLAGS

# Build *FLAGS for libnetcdf.settings.
SET(CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}")
SET(CPPFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${CMAKE_BUILD_TYPE}}")
SET(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE}}")

is_disabled(BUILD_SHARED_LIBS enable_static)
is_enabled(BUILD_SHARED_LIBS enable_shared)
Expand Down
27 changes: 11 additions & 16 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
SET(CMAKE_INCLUDE_CURRENT_DIR ON)

INCLUDE_DIRECTORIES(".")


#####
# Build doxygen documentation, if need be.
#####
IF(ENABLE_DOXYGEN)
# The following is redundant but does not hurt anything.
# The following is redundant but does not hurt anything.

FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.html ${CMAKE_CURRENT_SOURCE_DIR}/images ${CMAKE_CURRENT_SOURCE_DIR}/*.doc ${CMAKE_CURRENT_SOURCE_DIR}/*.xml ${CMAKE_CURRENT_SOURCE_DIR}/*.m4 ${CMAKE_CURRENT_SOURCE_DIR}/*.texi)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)

# Set abs_top_srcdir to work with the autotools
# doxyfile template.
SET(abs_top_srcdir ${CMAKE_SOURCE_DIR})
Expand All @@ -23,7 +18,7 @@ IF(ENABLE_DOXYGEN)
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.guide @ONLY)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.tutorial.in
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.tutorial @ONLY)

# We need to loop through twice. First to generate tags.
ADD_CUSTOM_TARGET(all_doc_tags ALL
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
Expand All @@ -40,7 +35,7 @@ IF(ENABLE_DOXYGEN)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating Tutorial Tags" VERBATIM
)

# Second, generate documentation that uses the tags.
ADD_CUSTOM_TARGET(doc_all ALL
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
Expand All @@ -58,19 +53,19 @@ IF(ENABLE_DOXYGEN)
COMMENT "Generating Tutorial Tags" VERBATIM
)

# Copy the image files used by markdown documentation
# Copy the image files used by markdown documentation
# manually.
FILE(GLOB IMG_FILES ${CMAKE_CURRENT_BINARY_DIR}/images/*.jpg
FILE(GLOB IMG_FILES ${CMAKE_CURRENT_BINARY_DIR}/images/*.jpg
${CMAKE_CURRENT_BINARY_DIR}/images/*.png)
FILE(COPY ${IMG_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/html)

FILE(COPY ${IMG_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/html)

INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT documentation)

ENDIF(ENABLE_DOXYGEN)

SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am netcdf.m4 DoxygenLayout.xml Doxyfile.in Doxyfile.guide.in footer.html mainpage.dox tutorial.dox install.dox dispatch.dox guide.dox types.dox notes.dox cdl.dox architecture.dox internal.dox install-fortran.dox Doxyfile.in.cmake windows-binaries.md building-with-cmake.md)

ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
6 changes: 1 addition & 5 deletions examples/C/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
SET(CMAKE_INCLUDE_CURRENT_DIR ON)

INCLUDE_DIRECTORIES(".")

SET(exam_C_tests simple_xy_wr simple_xy_rd sfc_pres_temp_wr sfc_pres_temp_rd pres_temp_4D_wr pres_temp_4D_rd)
SET(exam_C_tests_source "")
FOREACH(F ${exam_C_tests})
FOREACH(F ${exam_C_tests})
set(exam_C_tests_source ${exam_C_test_source} ${F}.c)
ENDFOREACH()

Expand Down
5 changes: 0 additions & 5 deletions examples/CDL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
SET(CMAKE_INCLUDE_CURRENT_DIR ON)

INCLUDE_DIRECTORIES(".")


SET(CDL_EXAMPLE_TESTS create_sample_files do_comps)

FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl)
Expand Down
6 changes: 0 additions & 6 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
SET(CMAKE_INCLUDE_CURRENT_DIR ON)

INCLUDE_DIRECTORIES(".")

ADD_SUBDIRECTORY(C)

IF(BUILD_UTILITIES)
Expand All @@ -10,5 +6,3 @@ ENDIF()

SET(CUR_EXTRA_DIST CMakeLists.txt Makefile.am)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")


4 changes: 0 additions & 4 deletions h5_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
SET(CMAKE_INCLUDE_CURRENT_DIR ON)

INCLUDE_DIRECTORIES(".")

SET(H5TESTS tst_h_files tst_h_files2 tst_h_files4 tst_h_atts tst_h_atts3 tst_h_atts4 tst_h_vars tst_h_vars2 tst_h_vars3 tst_h_grps tst_h_compounds tst_h_compounds2 tst_h_wrt_cmp tst_h_rd_cmp tst_h_vl tst_h_opaques tst_h_strings tst_h_strings1 tst_h_strings2 tst_h_ints tst_h_dimscales tst_h_dimscales1 tst_h_dimscales2 tst_h_dimscales3 tst_h_enums tst_h_dimscales4)

FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h5 ${CMAKE_CURRENT_SOURCE_DIR}/*.nc)
Expand Down
4 changes: 0 additions & 4 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
SET(CMAKE_INCLUDE_CURRENT_DIR ON)

INCLUDE_DIRECTORIES(".")

FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} Makefile.am CMakeLists.txt)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
6 changes: 1 addition & 5 deletions libdap2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
SET(CMAKE_INCLUDE_CURRENT_DIR ON)

INCLUDE_DIRECTORIES(".")

SET(dap2_SOURCES constraints.c dapcvt.c dapalign.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)

add_library(dap2 OBJECT ${dap2_SOURCES})
add_library(dap2 OBJECT ${dap2_SOURCES})

###
# Options related to the man page generation.
Expand Down
10 changes: 3 additions & 7 deletions libdispatch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
SET(CMAKE_INCLUDE_CURRENT_DIR ON)

INCLUDE_DIRECTORIES(".")

SET(libdispatch_SOURCES dparallel.c dcopy.c dfile.c ddim.c datt.c dattinq.c dattput.c dattget.c derror.c dvar.c dvarget.c dvarput.c dvarinq.c ddispatch.c nclog.c dstring.c dutf8proc.c ncuri.c nclist.c ncbytes.c nchashmap.c nctime.c dsubstrate.c nc.c nclistmgr.c)

IF(USE_NETCDF4)
Expand All @@ -10,10 +6,10 @@ ENDIF(USE_NETCDF4)

IF(BUILD_V2)
SET(libdispatch_SOURCES ${libdispatch_SOURCES} dv2i.c)
ENDIF(BUILD_V2)
ENDIF(BUILD_V2)

add_library(dispatch OBJECT ${libdispatch_SOURCES})
add_library(dispatch OBJECT ${libdispatch_SOURCES})

FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
6 changes: 1 addition & 5 deletions liblib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
SET(CMAKE_INCLUDE_CURRENT_DIR ON)

INCLUDE_DIRECTORIES(".")

SET(liblib_LIBS dispatch netcdf3)

#####
Expand All @@ -28,7 +24,7 @@ FOREACH(LIBS ${liblib_LIBS})
SET(LARGS ${LARGS} $<TARGET_OBJECTS:${LIBS}>)
ENDFOREACH()

ADD_LIBRARY(netcdf ${LIB_TYPE} stub.c ${LARGS} )
ADD_LIBRARY(netcdf stub.c ${LARGS} )
IF(MOD_NETCDF_NAME)
SET_TARGET_PROPERTIES(netcdf PROPERTIES LIBRARY_OUTPUT_NAME ${NETCDF_LIB_NAME})
SET_TARGET_PROPERTIES(netcdf PROPERTIES ARCHIVE_OUTPUT_NAME ${NETCDF_LIB_NAME})
Expand Down
11 changes: 3 additions & 8 deletions libsrc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
## This is a CMake file, part of Unidata's netCDF package.
# Copyright 2012-2013, see the COPYRIGHT file for more information.

SET(CMAKE_INCLUDE_CURRENT_DIR ON)

INCLUDE_DIRECTORIES(".")


# Process these files with m4.
SET(m4_SOURCES attr ncx putget t_ncxx)
foreach (f ${m4_SOURCES})
foreach (f ${m4_SOURCES})
GEN_m4(${f})
endforeach(f)

Expand All @@ -29,7 +24,7 @@ ELSE (USE_FFIO)
SET(libsrc_SOURCES ${libsrc_SOURCES} posixio.c)
ENDIF (USE_FFIO)

add_library(netcdf3 OBJECT ${libsrc_SOURCES})
add_library(netcdf3 OBJECT ${libsrc_SOURCES})

# The C API man page.

Expand Down Expand Up @@ -67,6 +62,6 @@ ENDIF()
FILE(GLOB libsrc_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
SET(CUR_EXTRA_DIST attr.m4 ncx.m4 putget.m4 XGetopt.c memio.c mmapio.c ffio.c posixio.c CMakeLists.txt Makefile.am)
ADD_EXTRA_DIST("${libsrc_SOURCES}")
ADD_EXTRA_DIST("${libsrc_HEADERS}")
ADD_EXTRA_DIST("${libsrc_HEADERS}")
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

Loading