[CMake] Question about add_custom_command

David Aldrich David.Aldrich at EU.NEC.COM
Mon Sep 13 07:03:45 EDT 2010


Hi Michael

> set(SRCS a.c b.c d.c e.c)
> 
> add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/f.c
>   COMMAND ...
>   DEPENDS ${SRCS}
>   COMMENT "Generating f.c"
>   VERBATIM)
> list(APPEND SRCS ${CMAKE_BINARY_DIR}/f.c)
> 
> add_executable(main ${SRCS})

Thanks - that worked nicely.

Now I have another problem. I need to link to the Python libraries. So I specify:

FIND_PACKAGE(PythonLibs REQUIRED)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})

<snip>

message (${PYTHON_LIBRARY})
add_library( Kernel STATIC ${SRCS} )
TARGET_LINK_LIBRARIES(Kernel ${PYTHON_LIBRARY})

The message shows:

/usr/lib64/libpython2.4.so

but this path does not appear in the link command so the build fails.

I am trying to build a static library so am worried why ${PYTHON_LIBRARY} is a shared library.

By the way, is it normal CMake style to write CMAKE commands in upper or lower case?

Can you help with these questions please?

BR

David


More information about the CMake mailing list