[CMake] question about version details in source code

hex hex7c3 at gmail.com
Wed Jul 17 09:38:56 EDT 2019


hello community,

I am receiving a|fatal error: foobar_version.h: No such file or 
directory|for|foobar_version.h|. The reason is that the source file is 
generated in|${CMAKE_CURRENT_BINARY_DIR}/foobar_version.cpp|while the 
header file is in|${CMAKE_CURRENT_SOURCE_DIR}|as seen here:

1234|configure_file(foobar_version.cpp.in foobar_version.cpp @ONLY) # 
configure_file(foobar_version.h foobar_version.h @ONLY) 
add_library(foobar_version STATIC 
${CMAKE_CURRENT_BINARY_DIR}/foobar_version.cpp) |//

In the source I simply|#include "foobar_version.h"|but the file is in a 
different location.

Why is this|CMakeLists.txt|file placing the files in different 
locations? What should I do about it?

------------------------------------------------------------------------

also, what is the purpose of|mylib.cpp|, I had to create it otherwise I 
receive:|No SOURCES given to target: fooToolkit|. The build is 
successful but my file is currently empty. Here are all build steps:

123456789|configure_file(foobar_version.cpp.in foobar_version.cpp @ONLY) 
configure_file(foobar_version.h foobar_version.h @ONLY) 
add_library(foobar_version STATIC 
${CMAKE_CURRENT_BINARY_DIR}/foobar_version.cpp) add_executable(foobar 
main.cpp) target_link_libraries(foobar PRIVATE foobar_version) 
add_library(fooToolkit mylib.cpp) target_link_libraries(fooToolkit 
PRIVATE foobar_version) |//

------------------------------------------------------------------------

thank you

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190717/cffbc0aa/attachment-0001.html>


More information about the CMake mailing list