userver
userver copied to clipboard
Impossible to change binary dir for userver subdirectory
https://t.me/vfarme
Basically I have a monorepo with a structure like
- service_1 - service_2 - service_3 - third_party - userver
Each service can be deployed separately (or together) in a separate docker container. Every time I deploy or develop a service I need to rebuild userver along with the service source code, which takes really long time.
make install
would allow me to install userver in a separate docker image that I could use to build services. I do the same with Qt for example. When you install Qt you can just select modules you need to viafind_package
, so you don't need to constantly rebuild Qt.
@Anton3
build userver in a separate build dir, specify a custom build dir for userver in add_subdirectory, and bake the prebuilt userver build dir into the docker image
https://t.me/vfarme
So here is what I did (only for debug build in purpose).
I cloned userver to the docker under
/opt/userver/userver
, built userver in the docker under/opt/userver/userver/build-debug
. Then in myCMakeLists.txt
I didset(USERVER_DIR /opt/userver/userver) include(${USERVER_DIR}/cmake/SetupEnvironment.cmake) include(GNUInstallDirs) add_subdirectory(${USERVER_DIR} ${USERVER_DIR}/build-debug)
Now when I try to build my service I am getting a compilation error: https://pastebin.com/uP6fWicd
Looks like for some reason it's starting building userver again in project directory
@Anton3
I see, that's because we use
CMAKE_BINARY_DIR
instead ofCMAKE_CURRENT_BINARY_DIR
in quite a lot of places