I need the files to be copied at build time, not a compile time: They are files I am editing and I need the build system to export the files to the binary directory tree whenever they are changed.
I know it looks stupid and probably is as well :-) The reason is that when the project is being used by clients, I want them to include each file as follows (something which I use myself): #include "Braceless/Frontend/Scanner.hpp" And the only way I could figure out to get it working was by naming the build directory "Braceless" and then do that thing I'm doing. The project is organized like this: src/AST src/Driver src/Frontend ... And I want to be able to write "Braceless" in front so that it works also when the header files and libraries have been installed on a system. In the LLVM system, they solve this problem by storing the headers in another location than the source files - something I deeply loathe as it makes it very difficult to search for strings and even to edit a given source file and its header at the same time. I'll try out your comments, but I don't see any way of getting rid of that ../.. construct. By the way, I am a CMake newbie so I just did what I could do to make it work somehow. Cheers, Mikael 2012/6/27 Rolf Eike Beer <e...@sf-mail.de> > > Sigh, now I sent you the code from the wrong directory, but the code for > > the "Backend" component is virtually identical. I don't know how to use > > functions with CMake, so I simply made a verbatim copy of the below code > > in > > each subfolder and edited it to match the subfolder. So the Backend > > project looks like this: > > > > project(Backend) > > > > set(PublicHeaders > > "Backend.hpp" > > "Context.hpp" > > ) > > set(PublishedHeaders "") > > foreach(Header IN LISTS PublicHeaders) > > get_filename_component(HeaderFilename "${Header}" NAME) > > set(Source "${CMAKE_CURRENT_SOURCE_DIR}/${Header}") > > set(Output "${CMAKE_CURRENT_BINARY_DIR}/${HeaderFilename}") > > list(APPEND PublishedHeaders "${Output}") > > add_custom_command( > > OUTPUT "${Output}" > > COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${Source}" > > "${Output}" > > MAIN_DEPENDENCY "${Source}" > > COMMENT "Publishing ${HeaderFilename}" > > VERBATIM > > ) > > Why don't you simply use configure_file(... COPYONLY) here? > > > endforeach() > > add_custom_target( > > publish_backend_headers > > ALL > > DEPENDS ${PublishedHeaders} > > SOURCES ${PublicHeaders} > > ) > > include_directories("${CMAKE_BINARY_DIR}/../") > > This is almost certainly wrong. Guess my build dir is /tmp/foo, why on > earth do you want to include /tmp? I could understand if it would be > ${CMAKE_CURRENT_BINARY_DIR}/.. if you are in a subdirectory, but otherwise > this is likely completely bogus. > > > include_directories("$ENV{LLVM}/include") > > > > add_definitions(-D__STDC_CONSTANT_MACROS) > > add_definitions(-D__STDC_LIMIT_MACROS) > > > > add_library(Backend > > "Backend.cpp" > > ) > > > > add_dependencies(Backend publish_backend_headers) > > I think you can avoid the whole add_custom_target/add_library by just > writing > > add_library(Backend Backend.cpp ${PublishedHeaders}) > > (Untested. May only reliably work if you use configure_file. ymmv). > > Eike > -- > > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake >
-- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake