[CMake] Differentiate between Linux and FreeBSD

Amitha Perera amitha-cmake at thepereras.org
Tue Apr 22 21:48:21 EDT 2008


Horacio Sanson wrote:
> The problem is that in linux I have to add the sctp library (i.e.
> -lsctp) if not compilation fails and in FreeBSD adding that library
> would cause the compiler to complain.
> 
> if there is a better way to do this I am eager to learn it.

Not necessarily "better", but if sctp exists on Linux, but not on 
FreeBSD (or more generally, if sctp should be linked against whenever it 
is found), an option is

find_library( SCTP_LIBRARY sctp )

target_link_libraries( your_exec ${SCTP_LIBRARY} )


cmake --help-command find_library should be helpful.

Cheers,
Amitha.


More information about the CMake mailing list