[prev in list] [next in list] [prev in thread] [next in thread]
List: cmake
Subject: [CMake] installing source (or object) files
From: "Kris Thielemans" <kris.f.thielemans () gmail ! com>
Date: 2016-12-27 16:12:20
Message-ID: 000d01d2605c$009506b0$01bf1410$ () gmail ! com
[Download RAW message or body]
This is a multipart message in MIME format.
[Attachment #2 (multipart/alternative)]
This is a multipart message in MIME format.
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
[Attachment #5 (text/html)]
<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" \
CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 \
(filtered medium)"><style><!-- /* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link="#0563C1" \
vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hi all<o:p></o:p></p><p \
class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p \
class=MsoNormal>Add_executable(wonderful_program wonderful_program.cxx \
registry.cxx)<o:p></o:p></p><p \
class=MsoNormal>target_link_libraries(wonderful_program mylib)<o:p></o:p></p><p \
class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>registry.cxx needs to be \
compiled with some of my include files.<o:p></o:p></p><p \
class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>For that, I \
added<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p \
class=MsoNormal>include_directories(“${PROJECT_SOURCE_DIR}/src/include”)<o:p></o:p></p><p \
class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I guess I could just as well \
have added<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p \
class=MsoNormal>SET_PROPERTY(SOURCE registry.cxx PROPERTY COMPILE_FLAG \
"-I${STIR_INCLUDE_DIR}")<o:p></o:p></p><p \
class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p \
class=MsoNormal>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 <o:p></o:p></p><p \
class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>INSTALL(FILES registry.cxx \
…)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p \
class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p \
class=MsoNormal>Any ideas?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p \
class=MsoNormal>Best wishes for 2017!<o:p></o:p></p><p \
class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Kris<o:p></o:p></p><p \
class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>PS: The reason that I need \
registry.cxx is that it contains some variables that have a funky constructor that \
initialises some registries somewhere.<o:p></o:p></p><p class=MsoNormal>PS: Full \
source code is at https://github.com/UCL/STIR<o:p></o:p></p></div></body></html>
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at: \
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more information \
on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at \
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic