I am having this strange issue with building a library and then linking it to 
an executable.

If I have the following in my CMakeList:

add_library(libfoo.a ${srcfiles})
add_executable(foo_exec.Fx foo_exec.F)
target_link_libraries(foo_exec.Fx libfoo.a)

I get an error returned of "no rule to make target libfoo.a needed by 
foo_exec.Fx."
I should mention I have library prefixes and suffixes turned off for both 
linking and building, meaning that the full filename of libraries are specified 
(hence the libfoo.a and not just foo).

But if I change my CMakeList to:

add_library(libfoo.a ${srcfiles})
#add_executable(foo_exec.Fx foo_exec.F)
#target_link_libraries(foo_exec.Fx libfoo.a)

It builds libfoo.a without any complaint.  When I uncomment the executable 
lines after building libfoo.a via the above, the library is linked to the 
executable with no complaints.
I might also mention since the Fortran compiler used is ABSoft and I am 
building on a 64-bit Redhat system, the linker I am using for Fortran 
executables is g++, but that may be irrelevant.

How do I specify that the library needs to be built before the executable which 
links to it, so that CMake does not return an error when it tries to build and 
link the executable before building its dependent library?
This almost seems like a bug in CMake.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to