1
1
cmake_minimum_required (VERSION 3.16)
2
2
3
+ set (CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR} /submodules/vcpkg/scripts/buildsystems/vcpkg.cmake"
4
+ CACHE STRING "Vcpkg toolchain file" )
5
+
3
6
project (APCEMM)
4
7
5
8
# Options
@@ -27,66 +30,41 @@ execute_process(COMMAND git rev-parse --short HEAD
27
30
OUTPUT_STRIP_TRAILING_WHITESPACE)
28
31
29
32
set (APCEMM_VERSION_BUILD_NUMBER "${APCEMM_VERSION_BUILD_NUMBER} " CACHE STRING "Git Version/Commit Hash" )
30
- set (CMAKE_CXX_STANDARD 17 )
33
+ set (CMAKE_CXX_STANDARD 20 )
31
34
configure_file (${CMAKE_SOURCE_DIR} /include /APCEMM.h.in ${CMAKE_SOURCE_DIR} /include /APCEMM.h @ONLY)
32
35
33
- # Include .cmake files in this directory to find the required packages
34
- list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR} /cmake)
35
-
36
- # Automated discovert of netCDF using netCDF config
37
- # Find nc-config and ncxx4-config
38
- find_program (NC_CONFIG NAMES "nc-config" DOC "Location of nc-config utility" )
39
- find_program (NCXX_CONFIG NAMES "ncxx4-config" DOC "Location of ncxx4-config utility" )
40
-
41
- # A function to call nx-config with an argument, and append the resulting path to a list
42
- function (inspect_netcdf_config VAR NX_CONFIG ARG)
43
- execute_process (
44
- COMMAND ${NX_CONFIG} ${ARG}
45
- OUTPUT_VARIABLE NX_CONFIG_OUTPUT
46
- OUTPUT_STRIP_TRAILING_WHITESPACE
47
- )
48
- if (EXISTS "${NX_CONFIG_OUTPUT} " )
49
- list (APPEND ${VAR} ${NX_CONFIG_OUTPUT} )
50
- set (${VAR} ${${VAR} } PARENT_SCOPE)
51
- endif ()
52
- endfunction ()
36
+ # Defines the 'main' file we want to create a binary of
37
+ add_executable (${PROJECT_NAME} ${CMAKE_SOURCE_DIR} /src/Core/Main.cpp)
38
+
39
+
40
+ # Dependencies managed by vcpkg:
41
+
42
+ find_package (Boost REQUIRED)
43
+ # All the Boost libraries we use are header-only, so no need to link here.
44
+
45
+ find_package (Catch2 CONFIG REQUIRED)
46
+ target_link_libraries (${PROJECT_NAME} PRIVATE Catch2::Catch2 Catch2::Catch2WithMain)
53
47
54
- # Add nc-config and ncxx4-config paths to CMAKE_PREFIX_PATH
55
- inspect_netcdf_config(CMAKE_PREFIX_PATH "${NC_CONFIG} " "--prefix" )
56
- inspect_netcdf_config(CMAKE_PREFIX_PATH "${NCXX_CONFIG} " "--prefix" )
48
+ find_package (Eigen3 CONFIG REQUIRED)
49
+ target_link_libraries (${PROJECT_NAME} PRIVATE Eigen3::Eigen)
50
+
51
+ find_package (FFTW3 CONFIG REQUIRED)
52
+ target_link_libraries (${PROJECT_NAME} PRIVATE FFTW3::fftw3)
53
+
54
+ find_package (netCDFCxx CONFIG REQUIRED)
55
+ target_link_libraries (${PROJECT_NAME} PRIVATE netCDF::netcdf netCDF::netcdf-cxx4)
56
+
57
+ find_package (yaml-cpp CONFIG REQUIRED)
58
+ target_link_libraries (${PROJECT_NAME} PRIVATE yaml-cpp::yaml-cpp)
59
+
60
+ # Other dependencies:
57
61
58
- # Find packages
59
- find_package (NetCDF REQUIRED)
60
- find_package (netCDFCxx REQUIRED)
61
- find_package (FFTW REQUIRED)
62
62
find_package (OpenMP REQUIRED)
63
- #find_package(Catch2 3 REQUIRED)
64
- find_package (yaml-cpp REQUIRED)
65
- find_package (Eigen3 3.3 REQUIRED)
66
-
67
- # Try to get Catch2 automatically
68
- Include (FetchContent)
69
-
70
- FetchContent_Declare(
71
- Catch2
72
- GIT_REPOSITORY https://github.com/catchorg/Catch2.git
73
- GIT_TAG v3.0.1 # or a later release
74
- # FIND_PACKAGE_ARGS # No specific args - but this ensure find_package runs first
75
- )
76
- #TODO: Figure out why FIND_PACKAGE_ARGS causes chaos
77
-
78
- #FetchContent_Declare(
79
- # yaml-cpp
80
- # GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
81
- # GIT_TAG 4aad2b1666a4742743b04e765a34742512915674
82
- #)
83
-
84
- #set(YAML_CPP_BUILD_TESTS OFF)
85
- # This should attempt to find the package, and will download if not found
86
- FetchContent_MakeAvailable(Catch2)
87
- #FetchContent_MakeAvailable(Catch2 yaml-cpp)
63
+ target_link_libraries (${PROJECT_NAME} PRIVATE OpenMP::OpenMP_CXX)
64
+
88
65
89
66
# This ensures the header files of the necessary libraries are included
67
+ include_directories (${Boost_INCLUDES} )
90
68
include_directories (${OpenMP_INCLUDES} )
91
69
include_directories (${FFTW_INCLUDES} )
92
70
include_directories (${NETCDF_INCLUDES} )
@@ -99,13 +77,9 @@ include_directories(${CMAKE_SOURCE_DIR}/include)
99
77
# This ensures that the CMakeLists.txt in src/ gets build
100
78
add_subdirectory (${CMAKE_SOURCE_DIR} /src)
101
79
102
- # Defines the 'main' file we want to create a binary of
103
- add_executable (${PROJECT_NAME} ${CMAKE_SOURCE_DIR} /src/Core/Main.cpp)
104
-
105
80
# Defines the libraries necessary for compiling the executable
106
- target_link_libraries (${PROJECT_NAME}
107
- ${netCDFCxx_LIBRARIES} ${NETCDF_LIBRARIES} ${FFTW_LIBRARIES} ${YAML_CPP_LIBRARIES}
108
- OpenMP::OpenMP_CXX Eigen3::Eigen FVM_ANDS Util AIM KPP EPM Core YamlInputReader LAGRID)
81
+ target_link_libraries (${PROJECT_NAME} PRIVATE
82
+ FVM_ANDS Util AIM KPP EPM Core YamlInputReader LAGRID)
109
83
110
84
# Tests
111
85
#if (BUILD_TEST)
0 commit comments