Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ CMakeFiles
CMakeCache.txt
cmake_install.cmake

/Code.v05-00/vcpkg_installed/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Code.v05-00/submodules/vcpkg"]
path = Code.v05-00/submodules/vcpkg
url = https://github.com/Microsoft/vcpkg.git
92 changes: 33 additions & 59 deletions Code.v05-00/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.16)

set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/submodules/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")

project(APCEMM)

# Options
Expand Down Expand Up @@ -27,66 +30,41 @@ execute_process(COMMAND git rev-parse --short HEAD
OUTPUT_STRIP_TRAILING_WHITESPACE)

set(APCEMM_VERSION_BUILD_NUMBER "${APCEMM_VERSION_BUILD_NUMBER}" CACHE STRING "Git Version/Commit Hash")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
configure_file(${CMAKE_SOURCE_DIR}/include/APCEMM.h.in ${CMAKE_SOURCE_DIR}/include/APCEMM.h @ONLY)

# Include .cmake files in this directory to find the required packages
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

# Automated discovert of netCDF using netCDF config
# Find nc-config and ncxx4-config
find_program(NC_CONFIG NAMES "nc-config" DOC "Location of nc-config utility")
find_program(NCXX_CONFIG NAMES "ncxx4-config" DOC "Location of ncxx4-config utility")

# A function to call nx-config with an argument, and append the resulting path to a list
function(inspect_netcdf_config VAR NX_CONFIG ARG)
execute_process(
COMMAND ${NX_CONFIG} ${ARG}
OUTPUT_VARIABLE NX_CONFIG_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(EXISTS "${NX_CONFIG_OUTPUT}")
list(APPEND ${VAR} ${NX_CONFIG_OUTPUT})
set(${VAR} ${${VAR}} PARENT_SCOPE)
endif()
endfunction()
# Defines the 'main' file we want to create a binary of
add_executable(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/src/Core/Main.cpp)


# Dependencies managed by vcpkg:

find_package(Boost REQUIRED)
# All the Boost libraries we use are header-only, so no need to link here.

find_package(Catch2 CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE Catch2::Catch2 Catch2::Catch2WithMain)

# Add nc-config and ncxx4-config paths to CMAKE_PREFIX_PATH
inspect_netcdf_config(CMAKE_PREFIX_PATH "${NC_CONFIG}" "--prefix")
inspect_netcdf_config(CMAKE_PREFIX_PATH "${NCXX_CONFIG}" "--prefix")
find_package(Eigen3 CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE Eigen3::Eigen)

find_package(FFTW3 CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE FFTW3::fftw3)

find_package(netCDFCxx CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE netCDF::netcdf netCDF::netcdf-cxx4)

find_package(yaml-cpp CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE yaml-cpp::yaml-cpp)

# Other dependencies:

# Find packages
find_package(NetCDF REQUIRED)
find_package(netCDFCxx REQUIRED)
find_package(FFTW REQUIRED)
find_package(OpenMP REQUIRED)
#find_package(Catch2 3 REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(Eigen3 3.3 REQUIRED)

# Try to get Catch2 automatically
Include(FetchContent)

FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.0.1 # or a later release
# FIND_PACKAGE_ARGS # No specific args - but this ensure find_package runs first
)
#TODO: Figure out why FIND_PACKAGE_ARGS causes chaos

#FetchContent_Declare(
# yaml-cpp
# GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
# GIT_TAG 4aad2b1666a4742743b04e765a34742512915674
#)

#set(YAML_CPP_BUILD_TESTS OFF)
# This should attempt to find the package, and will download if not found
FetchContent_MakeAvailable(Catch2)
#FetchContent_MakeAvailable(Catch2 yaml-cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE OpenMP::OpenMP_CXX)


# This ensures the header files of the necessary libraries are included
include_directories(${Boost_INCLUDES})
include_directories(${OpenMP_INCLUDES})
include_directories(${FFTW_INCLUDES})
include_directories(${NETCDF_INCLUDES})
Expand All @@ -99,13 +77,9 @@ include_directories(${CMAKE_SOURCE_DIR}/include)
# This ensures that the CMakeLists.txt in src/ gets build
add_subdirectory(${CMAKE_SOURCE_DIR}/src)

# Defines the 'main' file we want to create a binary of
add_executable(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/src/Core/Main.cpp)

# Defines the libraries necessary for compiling the executable
target_link_libraries(${PROJECT_NAME}
${netCDFCxx_LIBRARIES} ${NETCDF_LIBRARIES} ${FFTW_LIBRARIES} ${YAML_CPP_LIBRARIES}
OpenMP::OpenMP_CXX Eigen3::Eigen FVM_ANDS Util AIM KPP EPM Core YamlInputReader LAGRID)
target_link_libraries(${PROJECT_NAME} PRIVATE
FVM_ANDS Util AIM KPP EPM Core YamlInputReader LAGRID)

# Tests
#if (BUILD_TEST)
Expand Down
107 changes: 0 additions & 107 deletions Code.v05-00/cmake/FindEigen3.cmake

This file was deleted.

Loading