-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UGRID-14, UGRID-16, UGRID-17, UGRID-19: Pitchfork layout (#21)
- Loading branch information
1 parent
e7d803f
commit 169cdaf
Showing
56 changed files
with
713 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,130 +1,44 @@ | ||
# Works with 3.14 and tested through 3.18 | ||
cmake_minimum_required(VERSION 3.16...3.18) | ||
|
||
# Set compiler flags | ||
enable_language(C CXX) | ||
|
||
option(PRODUCE_CODE_COVERAGE "Produce code coverage files under GNU compilers" OFF) | ||
|
||
# Project name and a few useful settings. Other commands can pick up the results | ||
project( | ||
UGrid | ||
VERSION 0.0.0 | ||
DESCRIPTION "Library for reading/writing UGrid files." | ||
LANGUAGES CXX C) | ||
|
||
# Make sure all executables and shared libraries end up in one directory, | ||
# otherwise the executables won't run under Windows. This will cause | ||
# the build to fail. | ||
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") | ||
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") | ||
|
||
# Create position independent binaries | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
# Require C++17 | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
# Disable compiler specific extensions | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
# Set cmake installation prefix, so UGrid library gets installed under /UGrid | ||
SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/UGrid") | ||
|
||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -O2 -std=c++17 -Werror -Wall -Wextra -pedantic -Wno-unused-function") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -std=c++17") | ||
else() | ||
set(CMAKE_CXX_FLAGS_RELEASE | ||
"${CMAKE_CXX_FLAGS_RELEASE} /EHsc /MP /std:c++17") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /EHsc /MP /std:c++17") | ||
endif() | ||
|
||
# Create position independent binaries | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
# Disable compiler specific extensions | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
# Let's nicely support folders in IDEs | ||
set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
|
||
# Note this needs to be done in the main CMakeLists since it calls | ||
# enable_testing, which must be in the main CMakeLists. | ||
|
||
include(FetchContent) | ||
set(FETCHCONTENT_QUIET off) | ||
|
||
FetchContent_Declare( | ||
googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG v1.13.0 | ||
) | ||
if(WIN32) | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
endif() | ||
|
||
FetchContent_GetProperties(googletest) | ||
if(NOT googletest_POPULATED) | ||
FetchContent_Populate(googletest) | ||
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL) | ||
endif() | ||
|
||
include(CTest) | ||
|
||
# Docs only available if this is the main app | ||
add_subdirectory(docs) | ||
|
||
endif() | ||
|
||
# Determine version suffix from environment variable | ||
if(DEFINED ENV{VERSION_SUFFIX}) | ||
set(VERSION_SUFFIX $ENV{VERSION_SUFFIX}) | ||
else() | ||
set(VERSION_SUFFIX .0) | ||
endif() | ||
|
||
# Boost | ||
if(WIN32) | ||
# In windows use static libraries | ||
set(Boost_USE_STATIC_LIBS ON) | ||
endif() | ||
find_package(Boost REQUIRED COMPONENTS system filesystem) | ||
include_directories(${Boost_INCLUDE_DIR}) | ||
|
||
# Use NetCDF | ||
find_package(netCDF REQUIRED COMPONENTS C) | ||
if (netCDF_FOUND) | ||
message(STATUS "Found NetCDF ${netCDF_VERSION}") | ||
else() | ||
message(FATAL_ERROR "Could not find NetCDF" ) | ||
endif() | ||
|
||
# Use NetCDF-cxx | ||
find_package(netCDFCxx REQUIRED) | ||
if (netCDFCxx_FOUND) | ||
message(STATUS "Found NetCDFCxx ${netCDFCxx_VERSION}") | ||
else() | ||
message(FATAL_ERROR "Could not find NetCDFCxx") | ||
endif() | ||
|
||
find_package(hdf5 REQUIRED) | ||
if (hdf5_FOUND) | ||
message(STATUS "Found HDF5 ${hdf5_VERSION}") | ||
endif() | ||
|
||
# Run packaging scripts | ||
add_subdirectory(package) | ||
|
||
# The version file | ||
add_subdirectory(include/Version) | ||
|
||
# The static library | ||
add_subdirectory(src/UGrid) | ||
|
||
# The dynamic library | ||
add_subdirectory(src/UGridApi) | ||
|
||
# Testing only available if this is the main app. | ||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) | ||
add_subdirectory(tests) | ||
endif() | ||
cmake_minimum_required(VERSION 3.23) | ||
|
||
set(UGRID_VERSION 0.0.0) | ||
|
||
project( | ||
UGrid | ||
VERSION ${UGRID_VERSION} | ||
DESCRIPTION "Library for reading and writing UGrid files." | ||
LANGUAGES CXX C | ||
) | ||
|
||
# configuration options | ||
if (NOT WIN32) | ||
message(NOTICE "Build type: ${CMAKE_BUILD_TYPE}") | ||
endif() | ||
|
||
# configuration options | ||
include(cmake/user_config_options.cmake) | ||
|
||
# configure the compiler | ||
include(cmake/compiler_config.cmake) | ||
|
||
# fetch dependencies, must appear after options.cmake | ||
include(cmake/fetch_contents.cmake) | ||
|
||
# find required packages | ||
include(cmake/find_packages.cmake) | ||
|
||
# organize targets into folders, can be remove in version > 3.26 (ON by default) | ||
set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
|
||
# Docs only available if this is the main app | ||
add_subdirectory(docs) | ||
|
||
# Run packaging scripts: requires semantic version | ||
add_subdirectory(package) | ||
|
||
# Libraries | ||
add_subdirectory(libs) | ||
|
||
# Add unit tests | ||
if(ENABLE_UNIT_TESTING) | ||
add_subdirectory(tests) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Set the C++ standard | ||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
# Disable compiler-specific extensions | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
# Create position-independent executables and shared libraries | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
# Add compiler-specific options and definitions per supported platform | ||
if (UNIX) | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
add_compile_options("-fvisibility=hidden;-Werror;-Wall;-Wextra;-pedantic;-Wno-unused-function") | ||
add_compile_options("$<$<CONFIG:RELEASE>:-O2>") | ||
add_compile_options("$<$<CONFIG:DEBUG>:-g>") | ||
else() | ||
message(FATAL_ERROR "Unsupported compiler. Only GNU is supported under Linux. Found ${CMAKE_CXX_COMPILER_ID}.") | ||
endif() | ||
elseif(WIN32) | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
add_compile_options("/EHsc;/MP;/W3;/WX") | ||
add_compile_options("$<$<CONFIG:RELEASE>:/O2>") | ||
add_compile_options("$<$<CONFIG:DEBUG>:/Od;/DEBUG>") | ||
add_compile_definitions("_USE_MATH_DEFINES") | ||
add_compile_definitions("_CRT_SECURE_NO_WARNINGS") | ||
else() | ||
message(FATAL_ERROR "Unsupported compiler. Only MSVC is supported under Windows. Found ${CMAKE_CXX_COMPILER_ID}.") | ||
endif() | ||
else() | ||
message(FATAL_ERROR "Unsupported platform. Only Linux and Windows are supported.") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
include(FetchContent) | ||
set(FETCHCONTENT_QUIET off) | ||
|
||
if(ENABLE_UNIT_TESTING) | ||
# Fetch google test | ||
FetchContent_Declare( | ||
googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG v1.13.0 | ||
) | ||
|
||
if(WIN32) | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
endif() | ||
|
||
FetchContent_GetProperties(googletest) | ||
if(NOT googletest_POPULATED) | ||
FetchContent_Populate(googletest) | ||
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL) | ||
endif() | ||
|
||
include(CTest) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Boost | ||
set(BOOST_MIN_REQ_VERSION "1.78.0") | ||
find_package(Boost ${BOOST_MIN_REQ_VERSION} REQUIRED) | ||
if (NOT Boost_FOUND) | ||
message(FATAL_ERROR "Could not find Boost (minimum required version is ${BOOST_MIN_REQ_VERSION})") | ||
endif() | ||
|
||
# netCDF | ||
find_package(netCDF REQUIRED COMPONENTS C) | ||
if (netCDF_FOUND) | ||
message(STATUS "Found NetCDF ${netCDF_VERSION}") | ||
else() | ||
message(FATAL_ERROR "Could not find NetCDF" ) | ||
endif() | ||
|
||
# netCDFCxx | ||
find_package(netCDFCxx REQUIRED) | ||
if (netCDFCxx_FOUND) | ||
message(STATUS "Found NetCDFCxx ${netCDFCxx_VERSION}") | ||
else() | ||
message(FATAL_ERROR "Could not find NetCDFCxx") | ||
endif() | ||
|
||
# hdf5 | ||
find_package(hdf5 REQUIRED) | ||
if (hdf5_FOUND) | ||
message(STATUS "Found HDF5 ${hdf5_VERSION}") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# unit testing option | ||
option( | ||
ENABLE_UNIT_TESTING | ||
"Enables building the unit test executables" | ||
ON | ||
) | ||
|
||
# code coverage option | ||
if(LINUX AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
option( | ||
ENABLE_CODE_COVERAGE | ||
"Generates code coverage statistics." | ||
OFF | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Add UGrid static lib | ||
add_subdirectory(UGrid) | ||
|
||
# Add UGridAPI dynamic lib | ||
add_subdirectory(UGridAPI) |
Oops, something went wrong.