Hi
I haven't had any replies to my message below, hopefully because it was sent at the wrong time of year. So I'm reposting, but with some clarifications. I wrote the message about include_flags only. I've currently solved this by adding a variable Set(STIR_INCLUDE_DIRS blabla) in my STIRConfig.cmake.in (which is at <https://github.com/UCL/UCL-STIR/blob/master/src/cmake/STIRConfig.cmake.in> https://github.com/UCL/UCL-STIR/blob/master/src/cmake/STIRConfig.cmake.in) and tell the user of the library that they have to do include_directories(${STIR_INCLUDE_DIRS}) This works but only for include directories, not for other compiler flags. I've currently solved that by putting all (most?) of these in a STIRConfig.h.in. I don't particularly like the include_directories solution however. I believe CMake's eport facility is trying to get away from this. Indeed, for the library, its include path (and other compilation flags) get automatically exported, so the user doesn't have to do anything else than target_link_libraries to inherit all necessary flags. Also, my current solution relies on exporting the .cxx. It seems safer to export the object file as that is guaranteed to have been compiled with the correct flags, but I don't know how to do that. I hope my message below makes more sense now. Thanks Kris From: Kris Thielemans Sent: 27 December 2016 16:12 To: cmake@cmake.org Subject: installing source (or object) files 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
-- 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