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

Add ExoFMS-RT #165

Merged
merged 2 commits into from
Jul 15, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ external/*.tar.gz

# vscode
.vscode

# cache
.cache/
43 changes: 23 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,37 @@ project(canoe
# search for <Package>_ROOT
cmake_policy(SET CMP0074 NEW)

string(ASCII 27 Esc)
set(ColorReset "${Esc}[m")
set(Green "${Esc}[32m")

message(STATUS "")
message(STATUS "== Setting up canoe library ==")
message(STATUS "${Green}==== ${PROJECT_NAME} configure begin ====${ColorReset}")

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
message(STATUS "Default Build Type = Release")
message(STATUS "")
message(STATUS "Build Type = Release")
else()
message(STATUS "Build Type = ${CMAKE_BUILD_TYPE}")
message(STATUS "")
endif()

# load all modules
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/)

# load all macros
FILE(GLOB _macro_files "${CMAKE_SOURCE_DIR}/cmake/macros/*.cmake")
FOREACH(_file ${_macro_files})
file(GLOB _macro_files "${CMAKE_SOURCE_DIR}/cmake/macros/*.cmake")
foreach(_file ${_macro_files})
MESSAGE(STATUS "Include ${_file}")
INCLUDE(${_file})
ENDFOREACH()
include(${_file})
endforeach()

## 1. set up compiler flags ##
message(STATUS "1. Set up project compiler flags ...")
message(STATUS "${PROJECT_NAME}-1. Setting up project compiler flags ...")
message(STATUS "Include ${CMAKE_SOURCE_DIR}/cmake/compilers.cmake")
include(${CMAKE_SOURCE_DIR}/cmake/compilers.cmake)

## 2. set up project specific configuration ##
message(STATUS "2. Set up project parameters ...")
message(STATUS "${PROJECT_NAME}-2. Setting up project parameters ...")

# load custom task
message(STATUS "Load custom task = ${TASK}")
Expand All @@ -57,15 +59,14 @@ endif()

message(STATUS "Include ${CMAKE_CURRENT_SOURCE_DIR}/cmake/parameters.cmake")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/parameters.cmake)

## 3. set up project system libraries ##
message(STATUS "${PROJECT_NAME}-3. Setting up system libraries")
find_package(Eigen3 REQUIRED)
find_package(Cantera)
#find_package(Torch)

## 3. set up project system libraries ##
message(STATUS "3. Set up system libraries")
if (NOT ${CANTERA_FOUND})
include(${CMAKE_SOURCE_DIR}/cmake/yamlpp.cmake)
endif()
include(${CMAKE_SOURCE_DIR}/cmake/yamlpp.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/gtest.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/athena.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/application.cmake)
Expand All @@ -74,26 +75,25 @@ include(${CMAKE_SOURCE_DIR}/cmake/disort.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/rrtmg.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/pvfmm.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/minichem.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/exofmsrt.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/pybind11.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/c3m.cmake)

## 4. set up project configure file and library ##
message(STATUS "4. Set up project libraries")
message(STATUS "${PROJECT_NAME}-4. Setting up project libraries")
configure_file(${CMAKE_SOURCE_DIR}/configure.hpp.in configure.hpp @ONLY)
add_subdirectory(src)
add_subdirectory(tools)
add_subdirectory(data)

## 5. set up examples and tests
message(STATUS "6. Set up unit tests")
message(STATUS "${PROJECT_NAME}-5. Setting up unit tests")

add_subdirectory(examples)
add_subdirectory(tests)

## 6. set up python binding ##
if (PYTHON_BINDINGS)
add_subdirectory(python)
endif()
add_subdirectory(python)

## 7. add uninstall targets ##
configure_file(
Expand All @@ -103,3 +103,6 @@ configure_file(

add_custom_target(canoe_uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)

message(STATUS "${Green}==== ${PROJECT_NAME} configure done ====${ColorReset}")
message(STATUS "")
7 changes: 7 additions & 0 deletions cmake/exofmsrt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)

set(PACKAGE_NAME exofmsrt)
set(REPO_URL "https://github.com/chengcli/Exo-FMS_column_ck")
set(REPO_TAG "36ba9fad0f87339c3c7b83dd9bf2b53eaba8223f")
add_package(${PACKAGE_NAME} ${REPO_URL} ${REPO_TAG} OFF)
42 changes: 42 additions & 0 deletions cmake/macros/macro_add_package.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
macro(add_package name url tag option)
string(ASCII 27 Esc)
set(ColorReset "${Esc}[m")
set(Yellow "${Esc}[33m")

set(CACHE_DIR "${CMAKE_SOURCE_DIR}/.cache")
set(CACHE_FILE "${CACHE_DIR}/${name}-${tag}.tar.gz")

string(TOUPPER ${name} nameu)
option(${nameu} "Build ${name}" ${option})

if(${nameu})
if(EXISTS ${CACHE_FILE})
if(NOT EXISTS ${CMAKE_BINARY_DIR}/_deps/${name}-src)
message(
STATUS "${Yellow}Find cached file ${name}-${tag}.tar.gz${ColorReset}")
execute_process(COMMAND tar -xzf ${CACHE_FILE} -C ${CACHE_DIR})
execute_process(COMMAND mv ${CACHE_DIR}/${name}-src
${CMAKE_BINARY_DIR}/_deps/)
endif()

FetchContent_Declare(${name} SOURCE_DIR
${CMAKE_BINARY_DIR}/_deps/${name}-src)
else()
FetchContent_Declare(
${name}
GIT_REPOSITORY ${url}
GIT_TAG ${tag})
endif()

FetchContent_MakeAvailable(${name})
include_directories(${${name}_SOURCE_DIR})

if(NOT EXISTS ${CACHE_FILE})
message(STATUS "Creating ${CACHE_FILE}")
execute_process(COMMAND tar -czf ${CACHE_DIR}/${name}-${tag}.tar.gz -C
${CMAKE_BINARY_DIR}/_deps ${name}-src)
endif()
else()
message(STATUS "${Yellow}Not building ${name}${ColorReset}")
endif()
endmacro()
5 changes: 4 additions & 1 deletion cmake/yamlpp.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
include(FetchContent)

set(FETCHCONTENT_QUIET TRUE)

if(CANTERA_FOUND)
return()
endif()

FetchContent_Declare(
yaml-cpp
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
Expand Down
3 changes: 3 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# =========================================
# Wrap all C++ libraries and bind to Python
# =========================================
if (NOT PYTHON_BINDINGS)
return()
endif()

string(TOUPPER ${CMAKE_BUILD_TYPE} buildu)

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ set(CANOE_LIBRARY_${buildu}
"diagnostics_${buildl}"
"forcing_${buildl}"
$<$<BOOL:${MINICHEM}>:minichem::minichem++>
$<$<BOOL:${EXOFMSRT}>:exofmsrt::exofmsrt++>
#"modules_${buildl}"
${YAML_CPP_LIBRARIES}
${CPPDISORT_LIBRARY_${buildu}}
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# A collection of unit tests
# ==========================

include("${CMAKE_SOURCE_DIR}/cmake/macros/macro_setup_test.cmake")
configure_file(globals.cpp.in globals.cpp @ONLY)

# Enable testing functionality
Expand Down
Loading