[CMake] SET(CMAKE_Fortran_FLAGS) not always taking effect
Bill Hoffman
bill.hoffman at kitware.com
Tue Jun 23 13:11:21 EDT 2015
On 6/22/2015 9:49 PM, Ette, Anthony (CDS) wrote:
> Yet more info. How foolish of me to think it’s ok to have to run cmake
> twice. I found that the heart of the problem was the use of
> ${CMAKE_BINARY_DIR} in LINK_DIRECTORIES for the FORTRAN target in
> question (a static library, which other parts of the project depend
> on). So I have a CXX project (a subdir in my src tree) that depends on
> a fortran static library (also built from a subdir in my src tree). In
> this situation, the solution is to not use LINK_DIRECTORIES at all to
> point to the FORTRAN target, just specify full path in
> TARGET_LINK_DIRECTORIES. I understand that best practice is to always
> specify full path in TARGET_LINK_DIRECTORIES, but this can be quite
> cumbersome for large, disparate projects.
>
> Anyway, hope my pain helps someone else.
>
For any target in CMake you should link to just the target name.
add_library(foo foo.c)
add_executable(bar bar.c)
target_link_library(bar foo)
You should not use TARGET_LINK_DIRECTORIES just the target name.
-Bill
More information about the CMake
mailing list