Skip to content

Commit

Permalink
Fortran fixes (LLNL#108)
Browse files Browse the repository at this point in the history
* Enable GTest by default only when CXX is enabled

 - If GTest is enabled without CXX we throw a `FATAL_ERROR` and explain to the
   user that enabling CXX is a hard requirement for using GTest.
 - Fixes LLNL#105

* Default 2 enabling Fortran if use already detected

 - If user explicitly enables Fortran via `project()` or `enable_language()`
   they should not have to reenable it again.

* Remove BLT Fortran format setting

 - Fixes LLNL#106
 - Users should explicitly set the `CMAKE_Fortran_FORMAT` variable for
   the project themselves, or set the target property as appropriate.

* Use more canonical Fortran file naming convention

 - Move `blt_fruit_smoke.f` to `blt_fruit_smoke.f90`
  • Loading branch information
zbeekman authored and cyrush committed Nov 16, 2017
1 parent cb98cad commit a647ccd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion SetupBLT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ if (NOT BLT_LOADED)
endif()

################################
# Enable ctest support
# Enable ctest support
################################
if(ENABLE_TESTS)
enable_testing()
Expand Down
22 changes: 19 additions & 3 deletions cmake/BLTOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ option(ENABLE_COVERAGE "Enables code coverage support" OFF)
################################
# Build Options
################################
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if(_languages MATCHES "Fortran")
set(_fortran_already_enabled TRUE)
else()
set(_fortran_already_enabled FALSE)
endif()
option(ENABLE_COPY_HEADERS "Copy headers to build directory" OFF)
option(ENABLE_FORTRAN "Enables Fortran compiler support" OFF)
option(ENABLE_FORTRAN "Enables Fortran compiler support" ${_fortran_already_enabled})
option(ENABLE_SHARED_LIBS "Enables shared libraries." OFF)

option(ENABLE_MPI "Enables MPI support" OFF)
Expand All @@ -72,10 +78,20 @@ mark_as_advanced(BLT_CLANG_CUDA_ARCH)
#
# Google Mock requires and always builds Google Test, so ENABLE_GMOCK=ON implies ENABLE_GTEST=ON.
#
option(ENABLE_GTEST "Enable Google Test testing support (if ENABLE_TESTS=ON)" ON)
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if(_languages MATCHES "CXX")
set(_CXX_enabled ON)
else()
set(_CXX_enabled OFF)
endif()
option(ENABLE_GTEST "Enable Google Test testing support (if ENABLE_TESTS=ON)" ${_CXX_enabled})
option(ENABLE_GMOCK "Enable Google Mock testing support (if ENABLE_TESTS=ON)" OFF)
option(ENABLE_FRUIT "Enable Fruit testing support (if ENABLE_TESTS=ON and ENABLE_FORTRAN=ON)" ON)


if( (NOT _CXX_enabled) AND ENABLE_GTEST )
message( FATAL_ERROR
"You must have CXX enabled in your project to use GTEST!" )
endif()

################################
# Compiler Options
Expand Down
3 changes: 0 additions & 3 deletions cmake/SetupCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,6 @@ if(ENABLE_FORTRAN)
message(FATAL_ERROR "Fortran support selected, but no Fortran compiler was found.")
endif()

# default property to free form
set(CMAKE_Fortran_FORMAT FREE)

list(APPEND langFlags "CMAKE_Fortran_FLAGS")
else()
message(STATUS "Fortran support disabled.")
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ endif()
################
if (ENABLE_FORTRAN AND ENABLE_FRUIT)
blt_add_executable(NAME blt_fruit_smoke
SOURCES blt_fruit_smoke.f
SOURCES blt_fruit_smoke.f90
OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY}
DEPENDS_ON fruit
FOLDER blt/tests )
Expand Down
2 changes: 1 addition & 1 deletion tests/blt_fruit_smoke.f → tests/blt_fruit_smoke.f90
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

!------------------------------------------------------------------------------
!
! blt_fruit_smoke.f
! blt_fruit_smoke.f90
!
!------------------------------------------------------------------------------
module fruit_smoke
Expand Down

0 comments on commit a647ccd

Please sign in to comment.