Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
0beb9abf
Commit
0beb9abf
authored
2 months ago
by
Oliver Heidmann
Browse files
Options
Downloads
Patches
Plain Diff
CMake addtions: CMOR, threads, printing results of imported targets, fftw
parent
3c0e057f
No related branches found
Branches containing commit
No related tags found
1 merge request
!312
CMake Improvements and fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CMakeLists.txt
+90
-24
90 additions, 24 deletions
CMakeLists.txt
with
90 additions
and
24 deletions
CMakeLists.txt
+
90
−
24
View file @
0beb9abf
cmake_minimum_required
(
VERSION 3.30 FATAL_ERROR
)
cmake_minimum_required
(
VERSION 3.30 FATAL_ERROR
)
set
(
CMAKE_POSITION_INDEPENDENT_CODE ON
)
set
(
CMAKE_POSITION_INDEPENDENT_CODE ON
)
project
(
cdo VERSION 2.4.0 LANGUAGES C CXX
)
project
(
cdo VERSION 2.4.0 LANGUAGES C CXX
)
# --- Additional functionalities for CMake
include
(
CTest
)
include
(
CTest
)
include
(
CheckIncludeFileCXX
)
include
(
CheckIncludeFileCXX
)
include
(
CheckIncludeFiles
)
include
(
CheckIncludeFiles
)
include
(
CMakePrintHelpers
)
# --- Language Standards
set
(
CMAKE_C_STANDARD 11
)
set
(
CMAKE_C_STANDARD 11
)
set
(
CMAKE_CXX_STANDARD 20
)
set
(
CMAKE_CXX_STANDARD 20
)
# --- Evaluate variables in .in and copy do build
configure_file
(
configure_file
(
"
${
PROJECT_SOURCE_DIR
}
/cmake/cdo_config.h.in"
"
${
PROJECT_SOURCE_DIR
}
/cmake/cdo_config.h.in"
"
${
PROJECT_BINARY_DIR
}
/src/config.h"
"
${
PROJECT_BINARY_DIR
}
/src/config.h"
)
)
list
(
APPEND CMAKE_MODULE_PATH
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake
)
list
(
APPEND CMAKE_MODULE_PATH
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake
)
set
(
pthread_flag HAVE_LIBPTHREAD
)
# Finding libraries
check_include_files
(
"pthread.h"
${
pthread_flag
}
)
### -------------- Pthread ---------------------------
IF
(
${
pthread_flag
}
)
message
(
"Start check for pthread"
)
add_compile_definitions
(
${
pthread_flag
}
=1
)
include
(
FindThreads
)
ELSE
()
find_package
(
Threads
)
message
(
FATAL_ERROR
"pthread.h is not found"
)
set_target_properties
(
Threads::Threads PROPERTIES THREADS_PREFER_PTHREAD_FLAG TRUE
)
ENDIF
()
### -------------- WordExp ---------------------------
message
(
"Start check for wordexp"
)
set
(
wordexp_flag HAVE_WORDEXP_H
)
set
(
wordexp_flag HAVE_WORDEXP_H
)
check_include_files
(
"wordexp.h"
${
wordexp_flag
}
)
check_include_files
(
"wordexp.h"
${
wordexp_flag
}
)
IF
(
${
wordexp_flag
}
)
IF
(
${
wordexp_flag
}
)
add
_compile_defin
i
tions
(
${
wordexp_flag
}
=1
)
list
(
APPEND cdo
_compile_defintions
${
wordexp_flag
}
=1
)
ELSE
()
ELSE
()
message
(
STATUS
"wordexp.h is not found"
)
message
(
"wordexp.h is not found"
)
ENDIF
()
ENDIF
()
### -------------- fftw3 ---------------------------
message
(
"Start check for fftw3"
)
find_package
(
FFTW3 3.0 REQUIRED
)
if
(
NOT FFTW3_LIBRARIES
)
message
(
"FFTW3 not found, skipping FFTW3"
)
else
()
if
(
TARGET FFTW3::fftw3q
)
set
(
precision_fftw
"q"
)
elseif
(
TARGET FFTW3::fftw3l
)
set
(
precision_fftw
"l"
)
elseif
(
TARGET FFTW3::fftw3f
)
set
(
precision_fftw
"l"
)
endif
()
set_target_properties
(
FFTW3::
${
FFTW3_LIBRARIES
}${
precision_fftw
}
PROPERTIES IMPORTED_LOCATION
"
${
FFTW3_LIBRARIES
}
"
INTERFACE_INCLUDE_DIRECTORIES
"
${
FFTW3_INCLUDE_DIRS
}
"
)
endif
()
### -------------- NETCDF ---------------------------
message
(
"Start check for netCDF4"
)
find_package
(
netCDF 4.0 REQUIRED
)
find_package
(
netCDF 4.0 REQUIRED
)
set
(
netcdf_flag HAVE_LIBNETCDF
)
set
(
netcdf_flag HAVE_LIBNETCDF
)
message
(
STATUS netCDF::netcdf
)
if
(
TARGET netCDF::netcdf
)
if
(
TARGET netCDF::netcdf
)
add_compile_definitions
(
${
netcdf_flag
}
=
${
netCDF_FOUND
}
)
message
(
DEBUG
"Checking for netCDF_HAS_NC4 flag equal 'yes' : flag is:
${
netCDF_HAS_NC4
}
"
)
if
(
NOT
"
${
netCDF_HAS_NC4
}
"
STREQUAL
"yes"
)
message
(
WARNING
"NetCDF4 installation does not support nc4"
)
endif
()
list
(
APPEND cdo_compile_defintions
${
netcdf_flag
}
=
${
netCDF_FOUND
}
)
else
()
else
()
message
(
WARNING
"
n
etcdf not found, compiling without netcdf"
)
message
(
WARNING
"
N
etcdf not found, compiling without netcdf"
)
endif
()
endif
()
message
(
STATUS
${
pthread_flag
}
": "
${${
pthread_flag
}}
)
### -------------- CMOR -----------------------------
message
(
STATUS
${
wordexp_flag
}
": "
${${
wordexp_flag
}}
)
message
(
"Start check for CMOR"
)
message
(
STATUS
${
netcdf_flag
}
": "
${
netCDF_FOUND
}
)
if
(
CMOR_ROOT
)
message
(
"checking for CMOR requirements"
)
find_package
(
Uuid REQUIRED
)
find_package
(
json-c REQUIRED
)
find_package
(
Udunits REQUIRED
)
message
(
"CMOR requirements found: checking cmor itself"
)
find_package
(
CMOR
)
if
(
TARGET CMOR::CMOR
)
list
(
APPEND cdo_compile_defintions
"HAVE_LIBCMOR=1"
)
endif
()
endif
()
# ----------------------------------------------------------------------
### -------------- Status ---------------------------
message
(
"Printing Status"
)
message
(
"Internal Flags"
)
message
(
"Entering Subdirectories"
)
add_subdirectory
(
libcdi
)
add_subdirectory
(
libcdi
)
add_subdirectory
(
test
)
add_subdirectory
(
src
)
add_subdirectory
(
src
)
add_subdirectory
(
test
)
#use this to print all variables set to true
message
(
"STATUS:"
)
get_property
(
target_names DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
PROPERTY IMPORTED_TARGETS
)
foreach
(
_target
${
target_names
}
)
message
(
STATUS
"
${
_target
}
"
)
get_target_property
(
_imported_location
${
_target
}
IMPORTED_LOCATION
)
get_target_property
(
_imported_incl_dirs
${
_target
}
INTERFACE_INCLUDE_DIRECTORIES
)
get_target_property
(
_interface_link_lib
${
_target
}
INTERFACE_LINK_LIBRARIES
)
message
(
STATUS
" include paths:
${
_imported_incl_dirs
}
"
)
if
(
_imported_location
)
message
(
STATUS
" linker target:
${
_imported_location
}
"
)
endif
()
if
(
_interface_link_lib
)
message
(
STATUS
" interf_li_lib:
${
_interface_link_lib
}
"
)
endif
()
endforeach
()
if
(
FALSE
)
get_cmake_property
(
_variableNames VARIABLES
)
list
(
SORT _variableNames
)
foreach
(
_variableName
${
_variableNames
}
)
message
(
VERBOSE
"
${
_variableName
}
=
${${
_variableName
}}
"
)
endforeach
()
endif
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment