[CMake] installing source (or object) files

Kris Thielemans kris.f.thielemans at gmail.com
Tue Dec 27 11:12:20 EST 2016


Hi all

 

I have a non-standard set-up where I have a library that needs to be linked
together with some extra source files that contain "registries"). So in my
CMakeLists.txt I use

 

Add_executable(wonderful_program wonderful_program.cxx registry.cxx)

target_link_libraries(wonderful_program mylib)

 

registry.cxx needs to be compiled with some of my include files.

 

For that, I added

 

include_directories("${PROJECT_SOURCE_DIR}/src/include")

 

I guess I could just as well have added

 

SET_PROPERTY(SOURCE registry.cxx PROPERTY COMPILE_FLAG
"-I${STIR_INCLUDE_DIR}")

 

 

This works fine, but now I want to export my library (relocatable). I have
created a config file etc, added mylib as an install target, installed the
include files etc. All of that works great for the library. However, I have
no idea how to install registry.cxx. I could just 

 

INSTALL(FILES registry.cxx .)

 

However, that doesn't copy the properties of the source files anywhere. In
particular, it means that a "client" doesn't know what compilation flags to
use.

 

Any ideas?

 

Best wishes for 2017!

 

Kris

 

PS: The reason that I need registry.cxx is that it contains some variables
that have a funky constructor that initialises some registries somewhere.

PS: Full source code is at https://github.com/UCL/STIR

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161227/7f384077/attachment.html>


More information about the CMake mailing list