[CMake] Using CheckFortranFunctionExists
Hugh Sorby
h.sorby at auckland.ac.nz
Wed Oct 4 23:32:09 EDT 2017
Hi All,
I'm trying to use CheckFortranFunctionExists? to test for getarg which is failing on an Ubuntu 16.04 test machine and OS X test machine. The test I have put together is provided below in text form.
The test for getarg fails, the executable 'bob' fails to link but the executable 'dave' links and runs as expected.
The error from 'bob' is
[ 75%] Linking Fortran executable bob
Undefined symbols for architecture x86_64:
"_getarg_", referenced from:
_MAIN__ in src.f.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [bob] Error 1
make[1]: *** [CMakeFiles/bob.dir/all] Error 2
make: *** [all] Error 2?
The files used in text form:
================== CMakeLists.txt =====================
cmake_minimum_required(VERSION 3.4)
project(getarg_prog VERSION 1.0.0 LANGUAGES Fortran)
include(CheckFortranFunctionExists)
check_fortran_function_exists(getarg HAVE_GETARG)
add_executable(bob src.f)
add_executable(dave dave.f)
======================================================
=================== src.f =========================
program TESTFortran
external getarg
call getarg()
end program TESTFortran
================================================
======================== dave.f ==========================
PROGRAM test_getarg
INTEGER :: i
CHARACTER(len=32) :: arg
DO i = 1, iargc()
CALL getarg(i, arg)
WRITE (*,*) arg
END DO
========================================================
Can anyone explain why this is happening and how I would go about testing for the getarg function if I am doing it wrong.
Thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171005/8f8a6390/attachment.html>
More information about the CMake
mailing list