Description
Hi team,
Here is how I currently build qpid-proton (on RHEL 8.3):
~/qpid-proton/$ rm -rf ./build/ && mkdir ./build/ && cd ./build/ ~/qpid-proton/build/$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/proton ~/qpid-proton/build/$ make -j && make install
Now, I really wanted to change include directory to something else in my install layout. So, I tried to set CMAKE_INSTALL_INCLUDEDIR (as per https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html) – qpid build ignored it, and even gave me a warning at configuration time:
~/qpid-proton/$ rm -rf ./build/ && mkdir ./build/ && cd ./build/ ~/qpid-proton/build/$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/proton -DCMAKE_INSTALL_INCLUDEDIR=include64 ... CMake Warning: Manually-specified variables were not used by the project: CMAKE_INSTALL_INCLUDEDIR ... ~/qpid-proton/build/$ make -j && make install ... ~/qpid-proton/build/$ ls ~/proton include lib64 share
I browsed through CMakeLists a little bit, found INCLUDE_INSTALL_DIR which sounded like something I would need. Well, I tried to set it and got soooo many errors:
~/qpid-proton/build/$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/proton -DINCLUDE_INSTALL_DIR=include64 CMake Error in c/CMakeLists.txt: Target "qpid-proton" INTERFACE_INCLUDE_DIRECTORIES property contains path: "/export/home/nikita.akatiev/qpid-proton/build/include64" which is prefixed in the build directory. CMake Error in c/CMakeLists.txt: Target "qpid-proton" INTERFACE_INCLUDE_DIRECTORIES property contains path: "/export/home/nikita.akatiev/qpid-proton/build/include64" which is prefixed in the build directory.Target "qpid-proton" INTERFACE_INCLUDE_DIRECTORIES property contains path: "/export/home/nikita.akatiev/qpid-proton/build/include64" which is prefixed in the source directory. CMake Error in c/CMakeLists.txt: Target "qpid-proton-core" INTERFACE_INCLUDE_DIRECTORIES property contains path: "/export/home/nikita.akatiev/qpid-proton/build/include64" which is prefixed in the build directory.
Checked on 0.36 that I use and on main@e63708, error still exists. I browsed cache variables just to understand where my include64 value was being saved, and found that CMake saved my overriden INCLUDE_INSTALL_DIR as an absolute path to build directory:
~/qpid-proton/build/$ grep include64 CMakeCache.txt INCLUDE_INSTALL_DIR:PATH=/export/home/nikita.akatiev/qpid-proton/build/include64 INSTALL_INCLUDE_DIR:UNINITIALIZED=include64
AFAIU this is due to the variable type (PATH) – it is even a documented behaviour for set() operation: link. As a workaround, explicitly specifying variable type as STRING seems to work correctly:
~/qpid-proton/$ rm -rf ./build/ && mkdir ./build/ && cd ./build/ ~/qpid-proton/build/$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/proton -DINCLUDE_INSTALL_DIR:STRING=include64 ... ~/qpid-proton/build/$ make -j && make install ... ~/qpid-proton/build/$ ls ~/proton include64 lib64 share
Maybe setting INCLUDE_INSTALL_DIR as a STRING variable here https://github.com/apache/qpid-proton/blob/e637082ac62c6caefbc3ac94ef01e98a3c0b5902/CMakeLists.txt#L249 would help, or you could just use more standard GNUInstallDirs module which already handles that.