Skip to content

Commit 2ddc226

Browse files
committed
Add a config option to compile & link against OC
- Passing `-fcoarray=lib` to gfortran causes the compiler to generate different modules & symbols. This is likely a bug in gfortran, but, a consequence is that you need to build libraries you link to with the same `-fcoarray=...` flag.
1 parent 42e731a commit 2ddc226

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ cmake_minimum_required ( VERSION 2.8.8 FATAL_ERROR )
1414
# Use MSVS folders to organize projects on windows
1515
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1616

17+
option(JSON_FORTRAN_USE_OpenCoarrays
18+
"Build VTKmofo with support for linking against OpenCoarray programs" OFF)
19+
1720
set(PROJECT_DESCRIPTION "A Fortran 2008 JSON API")
1821
set(PROJECT_URL "https://github.com/jacobwilliams/json-fortran")
1922

@@ -36,6 +39,10 @@ include ( "cmake/checkOutOfSource.cmake" )
3639
#---------------------
3740
project ( jsonfortran NONE )
3841

42+
if(JSON_FORTRAN_USE_OpenCoarrays)
43+
find_package(OpenCoarrays)
44+
endif()
45+
3946
#---------------------
4047
# Real and Integer kinds
4148
#---------------------
@@ -161,6 +168,14 @@ endif ()
161168
set ( LIB_NAME ${CMAKE_PROJECT_NAME} )
162169
add_library ( ${LIB_NAME} SHARED ${JF_LIB_SRCS} )
163170
add_library ( ${LIB_NAME}-static STATIC ${JF_LIB_SRCS} )
171+
172+
if(JSON_FORTRAN_USE_OpenCoarrays)
173+
target_link_libraries(${LIB_NAME}
174+
PRIVATE OpenCoarrays::caf_mpi_static)
175+
target_link_libraries(${LIB_NAME}-static
176+
PRIVATE OpenCoarrays::caf_mpi_static)
177+
endif()
178+
164179
set_target_properties ( ${LIB_NAME}-static
165180
PROPERTIES
166181
OUTPUT_NAME ${LIB_NAME}

0 commit comments

Comments
 (0)