diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 554aff8..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,71 +0,0 @@ -cmake_minimum_required(VERSION 3.7) -project(lineclip Fortran) -enable_testing() - - -if(CMAKE_BUILD_TYPE STREQUAL Debug) - add_compile_options(-g -O0) -else() - add_compile_options(-O3) -endif() - -if(${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) - if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 8) - list(APPEND FFLAGS -std=f2018) - endif() - - list(APPEND FFLAGS -mtune=native -Wall -Wextra -Wpedantic -Werror=array-bounds -fbacktrace -fexceptions) - if(UNIX AND NOT (CYGWIN OR APPLE)) - list(APPEND FFLAGS -fstack-protector-all) - endif() -elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL PGI) - -elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL Flang) - list(APPEND FFLAGS -Mallocatable=03) -endif() - - -set(DEMO_COARRAYS FALSE) -if(${CMAKE_Fortran_COMPILER_ID} STREQUAL Intel) - list(APPEND FFLAGS -coarray=shared) - link_libraries(-coarray=shared) - set(DEMO_COARRAYS TRUE) -elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) - find_package(OpenCoarrays) - - if(OpenCoarrays_FOUND) - list(APPEND OpenCoarrays_LIBRARIES caf_mpi) - list(APPEND FFLAGS -fcoarray=lib) - set(DEMO_COARRAYS TRUE) - else() - list(APPEND FFLAGS -fcoarray=single) - endif() -endif() - - -add_library(assert assert.f90) -target_compile_options(assert PRIVATE ${FFLAGS}) - -set(f08 GNU Intel) -if(CMAKE_Fortran_COMPILER_ID IN_LIST f08) - target_sources(assert PRIVATE error2008.f90) -else() - target_sources(assert PRIVATE error2003.f90) -endif() - - -add_library(lineclip lineclipping.f90) -target_compile_options(lineclip PRIVATE ${FFLAGS}) -target_link_libraries(lineclip PRIVATE assert) - -add_executable(RunLineclip DemoLineclip.f90) -target_compile_options(RunLineclip PRIVATE ${FFLAGS}) -target_link_libraries(RunLineclip PRIVATE assert lineclip ${OpenCoarrays_LIBRARIES}) -add_test(NAME clip COMMAND RunLineclip) - -if(DEMO_COARRAYS) - add_executable(CoarrayLineclip DemoCoarrayLineclip.f90) - target_compile_options(CoarrayLineclip PRIVATE ${FFLAGS}) - target_link_libraries(CoarrayLineclip PRIVATE assert lineclip ${OpenCoarrays_LIBRARIES}) - add_test(NAME CoarrayClip COMMAND cafrun CoarrayLineclip) -endif() diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..36fa88f --- /dev/null +++ b/meson.build @@ -0,0 +1,31 @@ +project('lineclip', 'fortran', + version: '1.0.0', + default_options : ['default_library=static', 'buildtype=release', 'warning_level=3']) + +fc = meson.get_compiler('fortran') + +std18 = fc.first_supported_argument(['-std=f2018', '-stand f18', '/stand:f18']) +add_project_arguments(std18, language : 'fortran') + +assert_lib = library('assert', + sources: ['assert.f90', 'error2008.f90']) + +lineclip_lib = library('lineclip', 'lineclipping.f90', + link_with: [assert_lib]) + +lineclip_exe = executable('RunLineclip', 'DemoLineclip.f90', + link_with: [lineclip_lib, assert_lib]) + +test('clip', lineclip_exe, timeout: 10) + +# -- coarray + +coarrays = dependency('coarray', required: false, disabler: true) + +CoarrayLineclip_exe = executable('CoarrayLineclip', 'DemoCoarrayLineclip.f90', + link_with: [assert_lib, lineclip_lib], + dependencies: coarrays) +cafrun = find_program('cafrun', required: false) +test('CoarrayClip', cafrun, + args: CoarrayLineclip_exe, + timeout: 10)