diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b20e22c..b6da5e74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,24 +2,42 @@ cmake_minimum_required (VERSION 3.17) cmake_policy (SET CMP0053 NEW) cmake_policy (SET CMP0054 NEW) -project ( - GOCART - VERSION 2.1.1 - LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF - -if ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") - message(SEND_ERROR "In-source builds are disabled. Please - issue cmake command in separate build directory.") -endif ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") - -# Set the default build type to release -if (NOT CMAKE_BUILD_TYPE) - message (STATUS "Setting build type to 'Release' as none was specified.") - set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) - # Set the possible values of build type for cmake-gui - set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Release" "MinSizeRel" "RelWithDebInfo") -endif () +# mepo can now clone subrepos in three styles +set (ESMA_CMAKE_DIRS + cmake + @cmake + cmake@ + ) + +foreach (dir IN LISTS ESMA_CMAKE_DIRS) + if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/${dir}) + list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/${dir}") + set (ESMA_CMAKE_PATH "${CMAKE_CURRENT_LIST_DIR}/${dir}" CACHE PATH "Path to ESMA_cmake code") + include (esma) + set(GOCART_STANDALONE TRUE) + endif () +endforeach () + +if (GOCART_STANDALONE) + project ( + GOCART + VERSION 2.1.1 + LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF + + if ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") + message(SEND_ERROR "In-source builds are disabled. Please + issue cmake command in separate build directory.") + endif ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") + + # Set the default build type to release + if (NOT CMAKE_BUILD_TYPE) + message (STATUS "Setting build type to 'Release' as none was specified.") + set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui + set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Release" "MinSizeRel" "RelWithDebInfo") + endif () +endif() # Set build options option (UFS_GOCART "Build GOCART component for UFS" OFF) @@ -45,7 +63,9 @@ if (NOT COMMAND esma) include (esma) endif() -ecbuild_declare_project() +if(GOCART_STANDALONE) + ecbuild_declare_project() +endif() if (NOT Baselibs_FOUND) # Find dependencies @@ -81,7 +101,9 @@ include_directories(${MPI_Fortran_INCLUDE_PATH}) add_subdirectory (ESMF) add_subdirectory (Process_Library) -ecbuild_install_project (NAME GOCART) +if(GOCART_STANDALONE) + ecbuild_install_project (NAME GOCART) +endif() # https://www.scivision.dev/cmake-auto-gitignore-build-dir/ # --- auto-ignore build directory