diff --git a/CMakeLists.txt b/CMakeLists.txt index a4ff9319..756d729b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,12 @@ string(TIMESTAMP YEAR "%Y") # Set the CMake module path list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +#------------------------------------------------------------------------------ +# Set MPI preprocessor flag for legacy CCPP-FV3v0 +if (PROJECT STREQUAL "CCPP-FV3v0") + add_definitions("-DMPI") +endif (PROJECT STREQUAL "CCPP-FV3v0") + #------------------------------------------------------------------------------ # Set OpenMP flags for C/C++/Fortran if (OPENMP) @@ -48,10 +54,14 @@ if (OPENMP) set (CMAKE_Fortran_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set (CMAKE_Fortran_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}") + # Set OpenMP preprocessor flag for legacy CCPP-FV3v0 + if (PROJECT STREQUAL "CCPP-FV3v0") + add_definitions("-DOPENMP") + endif (PROJECT STREQUAL "CCPP-FV3v0") message(STATUS "Enable OpenMP support for C/C++/Fortran compiler") -else(OPENMP) +else (OPENMP) message (STATUS "Disable OpenMP support for C/C++/Fortran compiler") -endif() +endif (OPENMP) #------------------------------------------------------------------------------ # The Fortran compiler/linker flag inserted by cmake to create shared libraries @@ -81,7 +91,7 @@ endif() # This is due to how it labels subroutines within a modules. # For example the subroutine b() in the moduel a(), gets named a_b. # GCC and Intel do NOT do this, it is name simply as b. -if ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "PGI") +if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "PGI") message(STATUS "WARNING: PGI compiler is not fully ISO_C compliant; working solution involves a hack pgifix.py") endif() @@ -91,7 +101,7 @@ option(BUILD_SHARED_LIBS "Build a shared library" ON) #------------------------------------------------------------------------------ # Enable code coverage -if ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU" AND (CMAKE_BUILD_TYPE STREQUAL "Coverage")) +if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU" AND (CMAKE_BUILD_TYPE STREQUAL "Coverage")) include(code_coverage) list(APPEND LIBS "gcov") endif() diff --git a/schemes/check/CMakeLists.txt b/schemes/check/CMakeLists.txt index 1da718cd..f4916c4b 100644 --- a/schemes/check/CMakeLists.txt +++ b/schemes/check/CMakeLists.txt @@ -7,10 +7,6 @@ endif (NOT PROJECT) # Use rpaths on MacOSX set(CMAKE_MACOSX_RPATH 1) -message (INFO "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}") -message (INFO "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") -#message (FATAL_ERROR "BLA") - #------------------------------------------------------------------------------ cmake_minimum_required(VERSION 2.8.11) @@ -46,7 +42,7 @@ option(BUILD_SHARED_LIBS "Build a shared library" ON) #------------------------------------------------------------------------------ # Add the CCPP include/module directory and libraries, currently depends on build # see FV3_current_trunk/ccpp/CMakeLists.txt on how to set CCPP_INCLUDE_DIRS etc. -if (PROJECT MATCHES "CCPP-FV3") +if (PROJECT STREQUAL "CCPP-FV3") # Add the CCPP include/module directory set(CCPP_INCLUDE_DIRS "" CACHE FILEPATH "Path to ccpp includes") set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES ${CCPP_INCLUDE_DIRS}) @@ -54,13 +50,13 @@ if (PROJECT MATCHES "CCPP-FV3") set(CCPP_LIB_DIRS "" CACHE FILEPATH "Path to ccpp library") link_directories(${CCPP_LIB_DIRS}) list(APPEND LIBS "ccpp") -else (PROJECT MATCHES "CCPP-FV3") +else (PROJECT STREQUAL "CCPP-FV3") # Add the CCPP include/module directory INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/../../../../src") # Add the CCPP library LINK_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/../../../../src") list(APPEND LIBS "ccpp") -endif (PROJECT MATCHES "CCPP-FV3") +endif (PROJECT STREQUAL "CCPP-FV3") #------------------------------------------------------------------------------ # Set the sources diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 62ff4765..8e6608ae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -118,17 +118,17 @@ file(GLOB HEADERS_C "${CMAKE_CURRENT_SOURCE_DIR}/ccpp*.h" ) -if (PROJECT MATCHES "CCPP-FV3") +if (PROJECT STREQUAL "CCPP-FV3") target_include_directories(ccpp PUBLIC $ $ ) -else (PROJECT MATCHES "CCPP-FV3") +else (PROJECT STREQUAL "CCPP-FV3") target_include_directories(ccpp PUBLIC $ $ ) -endif (PROJECT MATCHES "CCPP-FV3") +endif (PROJECT STREQUAL "CCPP-FV3") # Define where to install the library install(TARGETS ccpp @@ -144,12 +144,12 @@ install(EXPORT ccpp-targets DESTINATION lib/cmake ) -if (PROJECT MATCHES "CCPP-FV3") +if (PROJECT STREQUAL "CCPP-FV3") # Define where to install the C headers and Fortran modules install(FILES ${HEADERS_C} DESTINATION include) install(FILES ${MODULES_F90} DESTINATION include) -else (PROJECT MATCHES "CCPP-FV3") +else (PROJECT STREQUAL "CCPP-FV3") # Define where to install the C headers and Fortran modules install(FILES ${HEADERS_C} DESTINATION include/${PROJECT_NAME}) install(FILES ${MODULES_F90} DESTINATION include/${PROJECT_NAME}) -endif (PROJECT MATCHES "CCPP-FV3") +endif (PROJECT STREQUAL "CCPP-FV3")